diff options
author | Marcel Molina <marcel@vernix.org> | 2006-04-26 22:13:31 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-04-26 22:13:31 +0000 |
commit | 8ee378f3c46c164cf8d7559bbb6a65ce1bb786fb (patch) | |
tree | cd2e829c2750593ea689c16736a1be6cc6e4a017 /actionpack/lib/action_controller | |
parent | 3ba7c53b5a985ab04fd1c94da076231fe5e51c0b (diff) | |
download | rails-8ee378f3c46c164cf8d7559bbb6a65ce1bb786fb.tar.gz rails-8ee378f3c46c164cf8d7559bbb6a65ce1bb786fb.tar.bz2 rails-8ee378f3c46c164cf8d7559bbb6a65ce1bb786fb.zip |
Enhance documentation for setting headers in integration tests. Skip auto HTTP prepending when its already there. Closes #4079. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4286 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/integration.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index 33ec1a0107..c96dd9c513 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -140,14 +140,18 @@ module ActionController # Performs a GET request with the given parameters. The parameters may # be +nil+, a Hash, or a string that is appropriately encoded - # (application/x-www-form-urlencoded or multipart/form-data). + # (application/x-www-form-urlencoded or multipart/form-data). The headers + # should be a hash. The keys will automatically be upcased, with the + # prefix 'HTTP_' added if needed. def get(path, parameters=nil, headers=nil) process :get, path, parameters, headers end # Performs a POST request with the given parameters. The parameters may # be +nil+, a Hash, or a string that is appropriately encoded - # (application/x-www-form-urlencoded or multipart/form-data). + # (application/x-www-form-urlencoded or multipart/form-data). The headers + # should be a hash. The keys will automatically be upcased, with the + # prefix 'HTTP_' added if needed. def post(path, parameters=nil, headers=nil) process :post, path, parameters, headers end @@ -155,7 +159,9 @@ module ActionController # Performs an XMLHttpRequest request with the given parameters, mimicing # the request environment created by the Prototype library. The parameters # may be +nil+, a Hash, or a string that is appropriately encoded - # (application/x-www-form-urlencoded or multipart/form-data). + # (application/x-www-form-urlencoded or multipart/form-data). The headers + # should be a hash. The keys will automatically be upcased, with the + # prefix 'HTTP_' added if needed. def xml_http_request(path, parameters=nil, headers=nil) headers = (headers || {}).merge("X-Requested-With" => "XMLHttpRequest") post(path, parameters, headers) @@ -218,7 +224,7 @@ module ActionController (headers || {}).each do |key, value| key = key.to_s.upcase.gsub(/-/, "_") - key = "HTTP_#{key}" unless env.has_key?(key) + key = "HTTP_#{key}" unless env.has_key?(key) || env =~ /^X|HTTP/ env[key] = value end |