Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/httpclient/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ def create_query_part()
end
if @request_query
if query_str
query_str += "&#{Message.create_query_part_str(@request_query)}"
extra_query_str = Message.create_query_part_str(@request_query).to_s
query_str += "&#{extra_query_str}" unless extra_query_str.empty?
else
query_str = Message.create_query_part_str(@request_query)
end
Expand Down
16 changes: 16 additions & 0 deletions test/test_httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,22 @@ def test_chunked_empty
assert_equal('', @client.get_content(serverurl + 'chunked', { 'msg' => '' }))
end

def test_get_query_with_query_in_uri
request_line = lambda do |query|
str = "".dup
@client.debug_dev = str
@client.get(serverurl + 'hello?a=1', query)
@client.reset_all
str.split(/(?:\r?\n)+/)[3]
end

assert_equal("GET /hello?a=1 HTTP/1.1", request_line.call(nil))
assert_equal("GET /hello?a=1 HTTP/1.1", request_line.call({}))
assert_equal("GET /hello?a=1 HTTP/1.1", request_line.call([]))
assert_equal("GET /hello?a=1 HTTP/1.1", request_line.call(''))
assert_equal("GET /hello?a=1&b=2 HTTP/1.1", request_line.call({'b' => '2'}))
end

def test_get_query
assert_equal({'1'=>'2'}, check_query_get({1=>2}))
assert_equal({'a'=>'A', 'B'=>'b'}, check_query_get({"a"=>"A", "B"=>"b"}))
Expand Down