blob: ab6fdd0ea95cf5d4ac6c12523a17f5618f53b716 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
require 'net/http'
require 'test/unit'
require 'stringio'
class HTTPResponseTest < Test::Unit::TestCase
def test_singleline_header
io = dummy_io(<<EOS.gsub(/\n/, "\r\n"))
HTTP/1.1 200 OK
Content-Length: 5
Connection: close
hello
EOS
res = Net::HTTPResponse.read_new(io)
assert_equal('5', res.header['content-length'])
assert_equal('close', res.header['connection'])
end
def test_multiline_header
io = dummy_io(<<EOS.gsub(/\n/, "\r\n"))
HTTP/1.1 200 OK
X-Foo: XXX
YYY
X-Bar:
XXX
\tYYY
hello
EOS
res = Net::HTTPResponse.read_new(io)
assert_equal('XXX YYY', res.header['x-foo'])
assert_equal('XXX YYY', res.header['x-bar'])
end
private
def dummy_io(str)
Net::BufferedIO.new(StringIO.new(str))
end
end
|