diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb index bea4346e..f1bf7c31 100644 --- a/lib/net/http/response.rb +++ b/lib/net/http/response.rb @@ -157,7 +157,7 @@ def read_new(sock) #:nodoc: internal use only 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)[ \t\v\f\r]+(\d\d\d)[ \t\v\f\r]+(.*)\z/n.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 01281063..69d0c0d9 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -639,9 +639,24 @@ def test_uri_equals assert_not_same uri, response.uri end - def test_ensure_zero_space_does_not_regress + def test_normal_status_line + io = dummy_io(<