Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

httpclient response header receives request_method, request_uri, and …

…request_query transferred from httpclient request header
  • Loading branch information...
commit 50da9b4dacb4f21cb8755f44382e68fdadf6485c 1 parent 2a587b2
@trlorenz trlorenz authored
View
6 lib/webmock/http_lib_adapters/httpclient_adapter.rb
@@ -46,7 +46,7 @@ def do_get(req, proxy, conn, stream = false, &block)
if webmock_responses[request_signature]
webmock_response = webmock_responses.delete(request_signature)
- response = build_httpclient_response(webmock_response, stream, &block)
+ response = build_httpclient_response(webmock_response, stream, req.header, &block)
@request_filter.each do |filter|
filter.filter_response(req, response)
end
@@ -89,9 +89,9 @@ def do_request_async(method, uri, query, body, extheader)
end
end
- def build_httpclient_response(webmock_response, stream = false, &block)
+ def build_httpclient_response(webmock_response, stream = false, req_header = nil, &block)
body = stream ? StringIO.new(webmock_response.body) : webmock_response.body
- response = HTTP::Message.new_response(body)
+ response = HTTP::Message.new_response(body, req_header)
response.header.init_response(webmock_response.status[0])
response.reason=webmock_response.status[1]
webmock_response.headers.to_a.each { |name, value| response.header.set(name, value) }
View
7 spec/acceptance/httpclient/httpclient_spec.rb
@@ -152,4 +152,11 @@ def filter_response(request, response)
end
+ context 'httpclient response header' do
+ it 'receives request_method, request_uri, and request_query from the request header' do
+ stub_request :get, 'www.example.com'
+ message = HTTPClient.new.get 'www.example.com'
+ message.header.request_uri.to_s.should == 'www.example.com'
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.