diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-18 06:24:50 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-18 06:24:50 +0000 |
commit | d2ed32d5929f9d837280e2354e9a7e5c99fc445f (patch) | |
tree | 7ac2c4e932b825d2874b0bedc6e2a7766ac3d71a /actionpack/test/controller/raw_post_test.rb | |
parent | b6541b8dcc6df9c92d946e1f76ec03f448d7fba4 (diff) | |
download | rails-d2ed32d5929f9d837280e2354e9a7e5c99fc445f.tar.gz rails-d2ed32d5929f9d837280e2354e9a7e5c99fc445f.tar.bz2 rails-d2ed32d5929f9d837280e2354e9a7e5c99fc445f.zip |
Parse url-encoded and multipart requests ourselves instead of delegating to CGI.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6764 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/raw_post_test.rb')
-rw-r--r-- | actionpack/test/controller/raw_post_test.rb | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/actionpack/test/controller/raw_post_test.rb b/actionpack/test/controller/raw_post_test.rb deleted file mode 100644 index 5fd2c84ff0..0000000000 --- a/actionpack/test/controller/raw_post_test.rb +++ /dev/null @@ -1,74 +0,0 @@ -require "#{File.dirname(__FILE__)}/../abstract_unit" - -class RawPostDataTest < Test::Unit::TestCase - def setup - ENV.delete('RAW_POST_DATA') - @request_body = 'a=1' - end - - def test_post_with_urlencoded_body - ENV['REQUEST_METHOD'] = 'POST' - ENV['CONTENT_TYPE'] = ' apPlication/x-Www-form-urlEncoded; charset=utf-8' - assert_equal ['1'], cgi.params['a'] - assert_raw_post_data - end - - def test_post_with_empty_content_type_treated_as_urlencoded - ENV['REQUEST_METHOD'] = 'POST' - ENV['CONTENT_TYPE'] = '' - assert_equal ['1'], cgi.params['a'] - assert_raw_post_data - end - - def test_post_with_unrecognized_content_type_ignores_body - ENV['REQUEST_METHOD'] = 'POST' - ENV['CONTENT_TYPE'] = 'foo/bar' - assert cgi.params.empty? - assert_no_raw_post_data - end - - def test_put_with_urlencoded_body - ENV['REQUEST_METHOD'] = 'PUT' - ENV['CONTENT_TYPE'] = 'application/x-www-form-urlencoded' - assert_equal ['1'], cgi.params['a'] - assert_raw_post_data - end - - def test_put_with_empty_content_type_ignores_body - ENV['REQUEST_METHOD'] = 'PUT' - ENV['CONTENT_TYPE'] = '' - assert cgi.params.empty? - assert_no_raw_post_data - end - - def test_put_with_unrecognized_content_type_ignores_body - ENV['REQUEST_METHOD'] = 'PUT' - ENV['CONTENT_TYPE'] = 'foo/bar' - assert cgi.params.empty? - assert_no_raw_post_data - end - - private - def cgi - unless defined? @cgi - ENV['CONTENT_LENGTH'] = @request_body.size.to_s - @cgi = CGI.new('query', StringIO.new(@request_body.dup)) - end - - @cgi - end - - def assert_raw_post_data - assert_not_nil ENV['RAW_POST_DATA'] - assert ENV['RAW_POST_DATA'].frozen? - assert_equal @request_body, ENV['RAW_POST_DATA'] - - assert_equal '', cgi.stdinput.read - end - - def assert_no_raw_post_data - assert_nil ENV['RAW_POST_DATA'] - - assert_equal @request_body, cgi.stdinput.read - end -end |