Skip to content
Browse files

Don't stomp on Content-Type's supplied via #header

  • Loading branch information...
1 parent a7a059f commit 42173cea4201b67e4170763c73aca8a0482bd6cc @brynary brynary committed May 26, 2010
Showing with 10 additions and 1 deletion.
  1. +1 −0 History.txt
  2. +2 −1 lib/rack/test.rb
  3. +7 −0 spec/rack/test_spec.rb
View
1 History.txt
@@ -2,6 +2,7 @@
* Bug fixes
+ * Don't stomp on Content-Type's supplied via #header (Bryan Helmkamp)
* Fixed build_multipart to allow for arrays of files (Louis Rose)
* Don't raise an error if raw cookies contain a blank line (John Reilly)
* Handle parameter names with brackets properly (Tanner Donovan)
View
3 lib/rack/test.rb
@@ -255,7 +255,8 @@ def headers_for_env
converted_headers = {}
@headers.each do |name, value|
- env_key = "HTTP_" + name.upcase.gsub("-", "_")
+ env_key = name.upcase.gsub("-", "_")
+ env_key = "HTTP_" + env_key unless "CONTENT_TYPE" == env_key
converted_headers[env_key] = value
end
View
7 spec/rack/test_spec.rb
@@ -212,6 +212,13 @@ def close
last_request.env["HTTP_USER_AGENT"].should == "Firefox"
end
+ it "sets a Content-Type to be sent with requests" do
+ header "Content-Type", "application/json"
+ request "/"
+
+ last_request.env["CONTENT_TYPE"].should == "application/json"
+ end
+
it "persists across multiple requests" do
header "User-Agent", "Firefox"
request "/"

0 comments on commit 42173ce

Please sign in to comment.
Something went wrong with that request. Please try again.