File tree Expand file tree Collapse file tree 4 files changed +64
-4
lines changed Expand file tree Collapse file tree 4 files changed +64
-4
lines changed Original file line number Diff line number Diff line change
1
+ Sat Oct 31 17:19:28 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
2
+
3
+ * lib/net/http.rb (Net::HTTPResponse#each_response_header):
4
+ cosmetic: '?\ ' -> '?\s'
5
+
6
+ Fri Oct 30 22:09:47 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
7
+
8
+ * lib/net/http.rb (Net::HTTPResponse#each_response_header):
9
+ accept multiline message header of HTTP response. see #1796.
10
+ cf. RFC 2616 '4.2 Message Header'.
11
+
12
+ * test/net/http/test_httpresponse.rb: added.
13
+
1
14
Thu Oct 29 04:41:44 2009 NARUSE, Yui <naruse@ruby-lang.org>
2
15
3
16
* ruby.c (process_options): call rb_filesystem_encoding().
Original file line number Diff line number Diff line change @@ -2146,13 +2146,20 @@ def response_class(code)
2146
2146
end
2147
2147
2148
2148
def each_response_header ( sock )
2149
+ key = value = nil
2149
2150
while true
2150
2151
line = sock . readuntil ( "\n " , true ) . sub ( /\s +\z / , '' )
2151
2152
break if line . empty?
2152
- m = /\A ([^:]+):\s */ . match ( line ) or
2153
- raise HTTPBadResponse , 'wrong header line format'
2154
- yield m [ 1 ] , m . post_match
2153
+ if line [ 0 ] == ?\s or line [ 0 ] == ?\t and value
2154
+ value << ' ' unless value . empty?
2155
+ value << line . strip
2156
+ else
2157
+ yield key , value if key
2158
+ key , value = line . strip . split ( /\s *:\s */ , 2 )
2159
+ raise HTTPBadResponse , 'wrong header line format' if value . nil?
2160
+ end
2155
2161
end
2162
+ yield key , value if key
2156
2163
end
2157
2164
end
2158
2165
Original file line number Diff line number Diff line change
1
+ require 'net/http'
2
+ require 'test/unit'
3
+ require 'stringio'
4
+
5
+ class HTTPResponseTest < Test ::Unit ::TestCase
6
+ def test_singleline_header
7
+ io = dummy_io ( <<EOS . gsub ( /\n / , "\r \n " ) )
8
+ HTTP/1.1 200 OK
9
+ Content-Length: 5
10
+ Connection: close
11
+
12
+ hello
13
+ EOS
14
+ res = Net ::HTTPResponse . read_new ( io )
15
+ assert_equal ( '5' , res . header [ 'content-length' ] )
16
+ assert_equal ( 'close' , res . header [ 'connection' ] )
17
+ end
18
+
19
+ def test_multiline_header
20
+ io = dummy_io ( <<EOS . gsub ( /\n / , "\r \n " ) )
21
+ HTTP/1.1 200 OK
22
+ X-Foo: XXX
23
+ YYY
24
+ X-Bar:
25
+ XXX
26
+ \t YYY
27
+
28
+ hello
29
+ EOS
30
+ res = Net ::HTTPResponse . read_new ( io )
31
+ assert_equal ( 'XXX YYY' , res . header [ 'x-foo' ] )
32
+ assert_equal ( 'XXX YYY' , res . header [ 'x-bar' ] )
33
+ end
34
+
35
+ private
36
+
37
+ def dummy_io ( str )
38
+ Net ::BufferedIO . new ( StringIO . new ( str ) )
39
+ end
40
+ end
Original file line number Diff line number Diff line change 1
1
#define RUBY_VERSION "1.9.1"
2
- #define RUBY_PATCHLEVEL 416
2
+ #define RUBY_PATCHLEVEL 417
3
3
#define RUBY_VERSION_MAJOR 1
4
4
#define RUBY_VERSION_MINOR 9
5
5
#define RUBY_VERSION_TEENY 1
You can’t perform that action at this time.
0 commit comments