[前][次][番号順一覧][スレッド一覧]

ruby-changes:37571

From: nagachika <ko1@a...>
Date: Thu, 19 Feb 2015 19:45:02 +0900 (JST)
Subject: [ruby-changes:37571] nagachika:r49652 (ruby_2_1): merge revision(s) r48948: [Backport #10591]

nagachika	2015-02-19 19:44:51 +0900 (Thu, 19 Feb 2015)

  New Revision: 49652

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49652

  Log:
    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@g...>
      https://github.com/ruby/ruby/pull/782 fix GH-782
      NOTE: graph.facebook.com returns without SP Reason-Phrase.

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/lib/net/http/response.rb
    branches/ruby_2_1/test/net/http/test_httpresponse.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 49651)
+++ ruby_2_1/ChangeLog	(revision 49652)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Thu Feb 19 19:14:34 2015  NARUSE, Yui  <naruse@r...>
+
+	* lib/net/http/response.rb (Net::HTTPResponse): require one or more
+	  spaces [Bug #10591].
+	  by leriksen <leif.eriksen.au@g...>
+	  https://github.com/ruby/ruby/pull/782 fix GH-782
+	  NOTE: graph.facebook.com returns without SP Reason-Phrase.
+
 Thu Feb 19 19:10:53 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* ext/tk/lib/tkextlib/tcllib/plotchart.rb: fix to invoke correct function
Index: ruby_2_1/lib/net/http/response.rb
===================================================================
--- ruby_2_1/lib/net/http/response.rb	(revision 49651)
+++ ruby_2_1/lib/net/http/response.rb	(revision 49652)
@@ -37,7 +37,7 @@ class Net::HTTPResponse https://github.com/ruby/ruby/blob/trunk/ruby_2_1/lib/net/http/response.rb#L37
 
     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
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 49651)
+++ ruby_2_1/version.h	(revision 49652)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.5"
 #define RUBY_RELEASE_DATE "2015-02-19"
-#define RUBY_PATCHLEVEL 298
+#define RUBY_PATCHLEVEL 299
 
 #define RUBY_RELEASE_YEAR 2015
 #define RUBY_RELEASE_MONTH 2
Index: ruby_2_1/test/net/http/test_httpresponse.rb
===================================================================
--- ruby_2_1/test/net/http/test_httpresponse.rb	(revision 49651)
+++ ruby_2_1/test/net/http/test_httpresponse.rb	(revision 49652)
@@ -244,6 +244,65 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/net/http/test_httpresponse.rb#L244
     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)

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r48948


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]