Skip to content
Browse files

Allow headers[Accept] to be set by hand when calling xml_http_request…

… (closes #10461) [BMorearty]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8426 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 26e1021 commit 436da684dc3e85c4251d6e586913b8520add8638 @dhh dhh committed Dec 17, 2007
View
2 actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*2.0.2* (December 16th, 2007)
+* Allow headers['Accept'] to be set by hand when calling xml_http_request #10461 [BMorearty]
+
* Added OPTIONS to list of default accepted HTTP methods #10449 [holoway]
* Added option to pass proc to ActionController::Base.asset_host for maximum configurability #10521 [chuyeow]. Example:
View
2 actionpack/lib/action_controller/integration.rb
@@ -187,7 +187,7 @@ def head(path, parameters = nil, headers = nil)
def xml_http_request(request_method, path, parameters = nil, headers = nil)
headers ||= {}
headers['X-Requested-With'] = 'XMLHttpRequest'
- headers['Accept'] = 'text/javascript, text/html, application/xml, text/xml, */*'
+ headers['Accept'] ||= 'text/javascript, text/html, application/xml, text/xml, */*'
process(request_method, path, parameters, headers)
end
View
9 actionpack/test/controller/integration_test.rb
@@ -179,6 +179,15 @@ def test_xml_http_request_head
@session.expects(:process).with(:head,path,params,headers_after_xhr)
@session.xml_http_request(:head,path,params,headers)
end
+
+ def test_xml_http_request_override_accept
+ path = "/index"; params = "blah"; headers = {:location => 'blah', "Accept" => "application/xml"}
+ headers_after_xhr = headers.merge(
+ "X-Requested-With" => "XMLHttpRequest"
+ )
+ @session.expects(:process).with(:post,path,params,headers_after_xhr)
+ @session.xml_http_request(:post,path,params,headers)
+ end
end
class IntegrationTestTest < Test::Unit::TestCase

0 comments on commit 436da68

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