Full Changelog: v0.24.4...v0.25.0
0.25 makes request paths and redirect targets resolve the way RFC 3986, browsers, curl and other HTTP clients resolve them. Both changes alter which URL some requests go to, so check the tables below before upgrading. 0.24.4 printed a [DEPRECATION] warning for every request the first change affects.
Breaking Changes
Empty paths no longer add a trailing slash
An empty path (""), a query-only path ("?a=1") or a fragment-only path ("#top") now requests the base_uri as-is. Before, HTTParty added a trailing slash, which some servers, such as SOAP endpoints, reject. (#742, #898, #900, thanks @Arniedude5342)
Call (base_uri "https://example.com/api/articles")
| 0.24 | 0.25 |
|---|---|---|
get("")
| /api/articles/
| /api/articles
|
get("?a=1")
| /api/articles/?a=1
| /api/articles?a=1
|
get("", query: { a: 1 })
| /api/articles/?a=1
| /api/articles?a=1
|
get("#top")
| /api/articles/#top
| /api/articles#top
|
base_uri has always dropped a trailing slash when it is set, so base_uri "https://example.com/api/" with get("") now requests /api as well.
Relative redirect Locations resolve against the current URL
A relative Location header now resolves against the URL that redirected. Before, HTTParty sent "" and ?page=2 to the site root and sent ../ to the server as-is. (#909)
Location (redirecting from /foo/start?a=1)
| 0.24 | 0.25 |
|---|---|---|
""
| /
| /foo/start?a=1
|
?page=2
| /?page=2
| /foo/start?page=2
|
../baz
| /foo/../baz
| /baz
|
./baz
| /foo/./baz
| /foo/baz
|
A server that always answers with Location: "" now gets the same URL requested again, until the redirect limit raises HTTParty::RedirectionTooDeep.
Upgrading
- To keep the trailing slash on an empty path, pass
"/"as the path. It requests the same URL in 0.24 and 0.25. - If you upgraded to 0.24.4, its
[DEPRECATION]warnings point to each call whose URL changes. - Redirects need no change unless you relied on a relative
Locationreaching the site root. Use an absolute path such as/in theLocationfor that.
Unchanged
get("/")and any non-empty path such asget("/comments").- A
base_uriwithout a path:get("")againsthttps://example.comstill requests/. - Absolute URLs,
URIobjects and the Addressable adapter for request paths. - Redirects to
baz,/xand anyLocationwith a host.
Other Behavior Changes
- A
HEADrequest staysHEADacross a 303 redirect, as the docs already said and RFC 9110 allows. Before, a 303 turned it into aGET, which downloaded the whole body. (#905) headers:values that aren't hash-like raise the documentedArgumentError, ':headers must be a hash'. Before, they raisedNoMethodErrororTypeError. (#902)
New
HTTParty.mkcol,HTTParty.lockandHTTParty.unlock, matching the class methods. (#903)
Bug Fixes
inspect,pandppshow a response whose body fails to parse, with its status, headers and body, instead of raising the parse error. (#901)- A
query_string_normalizerthat returns an array works for request bodies, not only query strings. Before, it raisedNoMethodErrorwhen sending. (#907)