summaryrefslogtreecommitdiff
path: root/test/net/http/test_http_request.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-19 22:43:38 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-19 22:43:38 +0000
commitb1a0509b5465ce77f52e0384159237889a8d60ec (patch)
treeea22ccb90a2367364e0c740f15ad571558b025f4 /test/net/http/test_http_request.rb
parentef19dcf96dd2e84c4fe0a46888a5afd0cd457f80 (diff)
* lib/net/http/response.rb: Automatically inflate gzip and
deflate-encoded response bodies. [Feature #6942] * lib/net/http/generic_request.rb: Automatically accept gzip and deflate content-encoding for requests. [Feature #6494] * lib/net/http/request.rb: Updated documentation for #6494. * lib/net/http.rb: Updated documentation for #6492 and #6494, removed Content-Encoding handling now present in Net::HTTPResponse. * test/net/http/test_httpresponse.rb: Tests for #6492 * test/net/http/test_http_request.rb: Tests for #6494 * test/open-uri/test_open-uri.rb (test_content_encoding): Updated test for automatic content-encoding handling. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net/http/test_http_request.rb')
-rw-r--r--test/net/http/test_http_request.rb57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/net/http/test_http_request.rb b/test/net/http/test_http_request.rb
new file mode 100644
index 0000000000..c01e52c0b4
--- /dev/null
+++ b/test/net/http/test_http_request.rb
@@ -0,0 +1,57 @@
+require 'net/http'
+require 'test/unit'
+require 'stringio'
+
+class HTTPRequestTest < Test::Unit::TestCase
+
+ def test_initialize_GET
+ req = Net::HTTP::Get.new '/'
+
+ assert_equal 'GET', req.method
+ refute req.request_body_permitted?
+ assert req.response_body_permitted?
+
+ expected = {
+ 'accept' => %w[*/*],
+ 'user-agent' => %w[Ruby],
+ }
+
+ expected['accept-encoding'] = %w[gzip;q=1.0,deflate;q=0.6,identity;q=0.3] if
+ Net::HTTP::HAVE_ZLIB
+
+ assert_equal expected, req.to_hash
+ end
+
+ def test_initialize_GET_range
+ req = Net::HTTP::Get.new '/', 'Range' => 'bytes=0-9'
+
+ assert_equal 'GET', req.method
+ refute req.request_body_permitted?
+ assert req.response_body_permitted?
+
+ expected = {
+ 'accept' => %w[*/*],
+ 'user-agent' => %w[Ruby],
+ 'range' => %w[bytes=0-9],
+ }
+
+ assert_equal expected, req.to_hash
+ end
+
+ def test_initialize_HEAD
+ req = Net::HTTP::Head.new '/'
+
+ assert_equal 'HEAD', req.method
+ refute req.request_body_permitted?
+ refute req.response_body_permitted?
+
+ expected = {
+ 'accept' => %w[*/*],
+ 'user-agent' => %w[Ruby],
+ }
+
+ assert_equal expected, req.to_hash
+ end
+
+end
+