[前][次][番号順一覧][スレッド一覧]

ruby-changes:56632

From: Nobuyoshi <ko1@a...>
Date: Wed, 24 Jul 2019 01:46:02 +0900 (JST)
Subject: [ruby-changes:56632] Nobuyoshi Nakada: 11662c70b0 (master): Test missing Content-Type warnings

https://git.ruby-lang.org/ruby.git/commit/?id=11662c70b0

From 11662c70b073da21dcd5213b61434bce2ed6af8f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 24 Jul 2019 01:42:35 +0900
Subject: Test missing Content-Type warnings


diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb
index 0344ad7..b5c4463 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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L469
 
   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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L544
 
       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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L995
       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 https://github.com/ruby/ruby/blob/trunk/test/net/http/test_http.rb#L1047
     }
     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)
       }
     }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]