Permalink
Browse files

Fix Rack response mutating request headers

  • Loading branch information...
1 parent 6c50b9a commit b8f65c89348e374b55605dab39fe5506ddce940d @bjeanes bjeanes committed Feb 10, 2014
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/webmock/rack_response.rb
  2. +13 −0 spec/acceptance/webmock_shared.rb
@@ -25,7 +25,7 @@ def body_from_rack_response(response)
def build_rack_env(request)
uri = request.uri
- headers = request.headers || {}
+ headers = (request.headers || {}).dup
body = request.body || ''
env = {
@@ -22,6 +22,19 @@
WebMock.reset!
end
+ it "preserves content-type header when proxying to a rack app" do
+ stub_request(:any, //).to_rack(lambda {|req| [200, {}, ["OK"]] })
+
+ url = "https://google.com/hi/there"
+ headers = {
+ "Accept" => "application/json",
+ "Content-Type" => "application/json"
+ }
+
+ http_request(:get, url, :headers => headers)
+ WebMock.should have_requested(:get, url).with(:headers => headers)
+ end
+
include_context "allowing and disabling net connect", *adapter_info
include_context "stubbing requests", *adapter_info

0 comments on commit b8f65c8

Please sign in to comment.