mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
fix for wrong query string encoding when passed an empty :params input
Fixes https://github.com/HoneyryderChuck/httpx/issues/85
This commit is contained in:
parent
17c1090b7a
commit
0484dd76c8
@ -226,7 +226,7 @@ module HTTPX
|
||||
return @query if defined?(@query)
|
||||
|
||||
query = []
|
||||
if (q = @query_params)
|
||||
if (q = @query_params) && !q.empty?
|
||||
query << Transcoder::Form.encode(q)
|
||||
end
|
||||
query << @uri.query if @uri.query
|
||||
|
@ -12,6 +12,15 @@ module Requests
|
||||
verify_uploaded(body, "url", build_uri("/#{meth}?q=this+is+a+test"))
|
||||
end
|
||||
|
||||
define_method :"test_#{meth}_query_params_empty" do
|
||||
uri = build_uri("/#{meth}")
|
||||
response = HTTPX.send(meth, "#{uri}?foo=bar", params: {})
|
||||
verify_status(response, 200)
|
||||
body = json_body(response)
|
||||
verify_uploaded(body, "args", "foo" => "bar")
|
||||
verify_uploaded(body, "url", build_uri("/#{meth}?foo=bar"))
|
||||
end
|
||||
|
||||
define_method :"test_#{meth}_query_nested_params" do
|
||||
uri = build_uri("/#{meth}")
|
||||
response = HTTPX.send(meth, uri, params: { "q" => { "a" => "z" }, "a" => %w[1 2], "b" => [] })
|
||||
|
Loading…
x
Reference in New Issue
Block a user