File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
19Thu 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
Original file line number Diff line number Diff 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 = /\A HTTP(?:\/ (\d +\. \d +))?\s +(\d \d \d )\s * (.*)\z /in . match ( str ) or
40+ m = /\A HTTP(?:\/ (\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
Original file line number Diff line number Diff 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+
247306private
248307
249308 def dummy_io ( str )
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments