Skip to content

Commit 2aba1db

Browse files
author
Steven Liu
committed
add a newline to debug_dev after fetch response body
1 parent 5bc7b0d commit 2aba1db

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/httpclient/session.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ def get_body(&block)
599599
close
600600
end
601601
end
602+
603+
@debug_dev << "\n" if @debug_dev
604+
602605
nil
603606
end
604607

test/test_http-access2.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ def test_debug_dev
6060
assert(!str.empty?)
6161
end
6262

63+
def test_debug_dev_shared_dev
64+
str = "".dup
65+
@client.debug_dev = str
66+
@client.get(serverurl)
67+
str << "another stuff\n"
68+
lines = str.split(/(?:\r?\n)+/)
69+
assert_equal('another stuff', lines[-1])
70+
end
71+
6372
def _test_protocol_version_http09
6473
@client.protocol_version = 'HTTP/0.9'
6574
str = "".dup

test/test_httpclient.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ def test_debug_dev
5757
assert(!str.empty?)
5858
end
5959

60+
def test_debug_dev_shared_dev
61+
str = "".dup
62+
@client.debug_dev = str
63+
@client.get(serverurl + 'hello')
64+
65+
str << "another stuff\n"
66+
lines = str.split(/(?:\r?\n)+/)
67+
68+
assert_equal('hello', lines[-2])
69+
assert_equal('another stuff', lines[-1])
70+
end
71+
6072
def test_debug_dev_stream
6173
str = "".dup
6274
@client.debug_dev = str
@@ -65,6 +77,18 @@ def test_debug_dev_stream
6577
assert(!str.empty?)
6678
end
6779

80+
def test_debug_dev_stream_shared_dev
81+
str = "".dup
82+
@client.debug_dev = str
83+
conn = @client.get_async(serverurl)
84+
Thread.pass while !conn.finished?
85+
86+
str << "another stuff\n"
87+
lines = str.split(/(?:\r?\n)+/)
88+
89+
assert_equal('another stuff', lines[-1])
90+
end
91+
6892
def test_protocol_version_http09
6993
@client.protocol_version = 'HTTP/0.9'
7094
@client.debug_dev = str = ''.dup

0 commit comments

Comments
 (0)