You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty query argument adds a trailing '&' to a URL that already has a query #491
If the URL already has query params and you pass an empty query argument, HTTPClient adds a & with nothing after it:
HTTPClient.new.get("https://example.com/Item?a=1",{})# requests: GET /Item?a=1&
query argument
Request line
nil
GET /Item?a=1
{}, [], ''
GET /Item?a=1&
{ "b" => "2" }
GET /Item?a=1&b=2
An empty query has nothing to add, so I'd expect the URL to stay /Item?a=1, the same as with nil.
Why it matters
Most servers ignore the trailing &, but some don't. We call an external API (MYOB AccountRight) through a wrapper that passes {} as the default query for GET requests. Since October 2026 that API rejects these requests with a 400 ("A value is required but was not present in the request"), because it reads the trailing & as a parameter with no name and no value.
HTTP::Message::Headers#create_query_part (lib/httpclient/http.rb) always appends "&" + query when the URL already has a query, even when the query argument turns into an empty string.
Activity