aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/integration.rb2
-rw-r--r--actionpack/test/controller/integration_test.rb9
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 1a5e5c9687..5730d897a2 100644
--- a/actionpack/CHANGELOG
+++ b/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:
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index 18050ae903..75e6796dc9 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -187,7 +187,7 @@ module ActionController
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
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index 00269ca3b8..771e243b00 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -179,6 +179,15 @@ class SessionTest < Test::Unit::TestCase
@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