class WebMock::HttpLibAdapters::NetHttpAdapter
def build_net_http_response(webmock_response, request_uri, &block)
def build_net_http_response(webmock_response, request_uri, &block) response = Net::HTTPResponse.send(:response_class, webmock_response.status[0].to_s).new("1.0", webmock_response.status[0].to_s, webmock_response.status[1]) body = webmock_response.body body = nil if webmock_response.status[0].to_s == '204' response.instance_variable_set(:@body, body) webmock_response.headers.to_a.each do |name, values| values = [values] unless values.is_a?(Array) values.each do |value| response.add_field(name, value) end end response.instance_variable_set(:@read, true) response.uri = request_uri response.extend Net::WebMockHTTPResponse if webmock_response.should_timeout raise Net::OpenTimeout, "execution expired" end webmock_response.raise_error_if_any yield response if block_given? response end