diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-14 07:32:00 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-14 07:32:00 +0000 |
commit | f9d88c6059f8b3e512401790ad82574e12c8ccb1 (patch) | |
tree | a82eb6cdb9004ce7cf9ac817600d3255510b7f4c | |
parent | 0638301255a0e2781edca0b1f6d1f23d76cd6d66 (diff) |
merge revision(s) 48948: [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_0_0@49250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib/net/http/response.rb | 2 | ||||
-rw-r--r-- | test/net/http/test_httpresponse.rb | 59 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 69 insertions, 2 deletions
@@ -1,3 +1,11 @@ +Wed Jan 14 16:30:51 2015 NARUSE, Yui <naruse@ruby-lang.org> + + * 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. + Wed Jan 14 16:23:49 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * ext/openssl/ossl_cipher.c (ossl_cipher_update_long): update huge diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index da3e4b4c8c..9aaa0b3208 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -37,7 +37,7 @@ class Net::HTTPResponse def read_status_line(sock) str = sock.readline - m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or + m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or raise Net::HTTPBadResponse, "wrong status line: #{str.dump}" m.captures end 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) @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2015-01-14" -#define RUBY_PATCHLEVEL 611 +#define RUBY_PATCHLEVEL 612 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 |