diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-19 10:44:51 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-19 10:44:51 +0000 |
commit | 13112e53367035c28600baf4ac416cadb5e60759 (patch) | |
tree | 89a301540a6748a3e617c5d95be485c6394c05b0 /test | |
parent | 1386c9fd3e9f4b10534be6ba23b3d7a43c129588 (diff) |
merge revision(s) r48948: [Backport #10591]
* lib/net/http/response.rb (Net::HTTPResponse): require one or more
spaces [Bug #10591].
by leriksen <leif.eriksen.au@gmail.com>
https://github.com/ruby/ruby/pull/782 fix GH-782
NOTE: graph.facebook.com returns without SP Reason-Phrase.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@49652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/net/http/test_httpresponse.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 974f8296cc..0193a153e4 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -244,6 +244,65 @@ EOS refute_same uri, response.uri end + def test_ensure_zero_space_does_not_regress + io = dummy_io(<<EOS) +HTTP/1.1 200OK +Content-Length: 5 +Connection: close + +hello +EOS + + assert_raises Net::HTTPBadResponse do + Net::HTTPResponse.read_new(io) + end + end + + def test_allow_trailing_space_after_status + io = dummy_io(<<EOS) +HTTP/1.1 200\s +Content-Length: 5 +Connection: close + +hello +EOS + + res = Net::HTTPResponse.read_new(io) + assert_equal('1.1', res.http_version) + assert_equal('200', res.code) + assert_equal('', res.message) + end + + def test_normal_status_line + io = dummy_io(<<EOS) +HTTP/1.1 200 OK +Content-Length: 5 +Connection: close + +hello +EOS + + res = Net::HTTPResponse.read_new(io) + assert_equal('1.1', res.http_version) + assert_equal('200', res.code) + assert_equal('OK', res.message) + end + + def test_allow_empty_reason_code + io = dummy_io(<<EOS) +HTTP/1.1 200 +Content-Length: 5 +Connection: close + +hello +EOS + + res = Net::HTTPResponse.read_new(io) + assert_equal('1.1', res.http_version) + assert_equal('200', res.code) + assert_equal(nil, res.message) + end + private def dummy_io(str) |