Skip to content

Commit 13112e5

Browse files
committed
merge revision(s) r48948: [Backport ruby#10591]
* lib/net/http/response.rb (Net::HTTPResponse): require one or more spaces [Bug ruby#10591]. by leriksen <leif.eriksen.au@gmail.com> ruby#782 fix rubyGH-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
1 parent 1386c9f commit 13112e5

4 files changed

Lines changed: 69 additions & 2 deletions

File tree

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Thu Feb 19 19:14:34 2015 NARUSE, Yui <naruse@ruby-lang.org>
2+
3+
* lib/net/http/response.rb (Net::HTTPResponse): require one or more
4+
spaces [Bug #10591].
5+
by leriksen <leif.eriksen.au@gmail.com>
6+
https://github.com/ruby/ruby/pull/782 fix GH-782
7+
NOTE: graph.facebook.com returns without SP Reason-Phrase.
8+
19
Thu Feb 19 19:10:53 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
210

311
* ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function

lib/net/http/response.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def read_new(sock) #:nodoc: internal use only
3737

3838
def read_status_line(sock)
3939
str = sock.readline
40-
m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in.match(str) or
40+
m = /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)(?:\s+(.*))?\z/in.match(str) or
4141
raise Net::HTTPBadResponse, "wrong status line: #{str.dump}"
4242
m.captures
4343
end

test/net/http/test_httpresponse.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,65 @@ def test_uri_equals
244244
refute_same uri, response.uri
245245
end
246246

247+
def test_ensure_zero_space_does_not_regress
248+
io = dummy_io(<<EOS)
249+
HTTP/1.1 200OK
250+
Content-Length: 5
251+
Connection: close
252+
253+
hello
254+
EOS
255+
256+
assert_raises Net::HTTPBadResponse do
257+
Net::HTTPResponse.read_new(io)
258+
end
259+
end
260+
261+
def test_allow_trailing_space_after_status
262+
io = dummy_io(<<EOS)
263+
HTTP/1.1 200\s
264+
Content-Length: 5
265+
Connection: close
266+
267+
hello
268+
EOS
269+
270+
res = Net::HTTPResponse.read_new(io)
271+
assert_equal('1.1', res.http_version)
272+
assert_equal('200', res.code)
273+
assert_equal('', res.message)
274+
end
275+
276+
def test_normal_status_line
277+
io = dummy_io(<<EOS)
278+
HTTP/1.1 200 OK
279+
Content-Length: 5
280+
Connection: close
281+
282+
hello
283+
EOS
284+
285+
res = Net::HTTPResponse.read_new(io)
286+
assert_equal('1.1', res.http_version)
287+
assert_equal('200', res.code)
288+
assert_equal('OK', res.message)
289+
end
290+
291+
def test_allow_empty_reason_code
292+
io = dummy_io(<<EOS)
293+
HTTP/1.1 200
294+
Content-Length: 5
295+
Connection: close
296+
297+
hello
298+
EOS
299+
300+
res = Net::HTTPResponse.read_new(io)
301+
assert_equal('1.1', res.http_version)
302+
assert_equal('200', res.code)
303+
assert_equal(nil, res.message)
304+
end
305+
247306
private
248307

249308
def dummy_io(str)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.5"
22
#define RUBY_RELEASE_DATE "2015-02-19"
3-
#define RUBY_PATCHLEVEL 298
3+
#define RUBY_PATCHLEVEL 299
44

55
#define RUBY_RELEASE_YEAR 2015
66
#define RUBY_RELEASE_MONTH 2

0 commit comments

Comments
 (0)