summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-24 01:42:35 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-24 01:42:45 +0900
commit11662c70b073da21dcd5213b61434bce2ed6af8f (patch)
tree2ac75b7b38d83b080035b20ddd8a42188ce21171 /test/net
parentafea8db8c7a6bca9042002dd305d45494eb2656f (diff)
Test missing Content-Type warnings
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_http.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 0344ad786b..b5c4463544 100644
--- a/test/net/http/test_http.rb
+++ b/test/net/http/test_http.rb
@@ -469,9 +469,11 @@ module TestNetHTTP_version_1_1_methods
def test_s_post
url = "http://#{config('host')}:#{config('port')}/?q=a"
- res = Net::HTTP.post(
+ res = assert_warning(/Content-Type did not set/) do
+ Net::HTTP.post(
URI.parse(url),
"a=x")
+ end
assert_equal "application/x-www-form-urlencoded", res["Content-Type"]
assert_equal "a=x", res.body
assert_equal url, res["X-request-uri"]
@@ -542,7 +544,11 @@ module TestNetHTTP_version_1_1_methods
th = Thread.new do
err = !windows? ? Net::WriteTimeout : Net::ReadTimeout
- assert_raise(err) { conn.post('/', "a"*50_000_000) }
+ assert_raise(err) do
+ assert_warning(/Content-Type did not set/) do
+ conn.post('/', "a"*50_000_000)
+ end
+ end
end
assert th.join(EnvUtil.apply_timeout_scale(10))
}
@@ -989,7 +995,7 @@ class TestNetHTTPContinue < Test::Unit::TestCase
raise WEBrick::HTTPStatus::Forbidden
}
start {|http|
- uheader = {'content-length' => '5', 'expect' => '100-continue'}
+ uheader = {'content-type' => 'application/x-www-form-urlencoded', 'content-length' => '5', 'expect' => '100-continue'}
http.continue_timeout = 1 # allow the server to respond before sending
http.request_post('/continue', 'data', uheader) {|res|
assert_equal(res.code, '403')
@@ -1041,7 +1047,8 @@ class TestNetHTTPSwitchingProtocols < Test::Unit::TestCase
}
start {|http|
http.continue_timeout = 0.2
- http.request_post('/continue', 'body=BODY') {|res|
+ http.request_post('/continue', 'body=BODY',
+ 'content-type' => 'application/x-www-form-urlencoded') {|res|
assert_equal('BODY', res.read_body)
}
}