gems httparty 0.25.0
v0.25.0

one hour ago

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 Location reaching the site root. Use an absolute path such as / in the Location for that.

Unchanged

  • get("/") and any non-empty path such as get("/comments").
  • A base_uri without a path: get("") against https://example.com still requests /.
  • Absolute URLs, URI objects and the Addressable adapter for request paths.
  • Redirects to baz, /x and any Location with a host.

Other Behavior Changes

  • A HEAD request stays HEAD across a 303 redirect, as the docs already said and RFC 9110 allows. Before, a 303 turned it into a GET, which downloaded the whole body. (#905)
  • headers: values that aren't hash-like raise the documented ArgumentError, ':headers must be a hash'. Before, they raised NoMethodError or TypeError. (#902)

New

  • HTTParty.mkcol, HTTParty.lock and HTTParty.unlock, matching the class methods. (#903)

Bug Fixes

  • inspect, p and pp show a response whose body fails to parse, with its status, headers and body, instead of raising the parse error. (#901)
  • A query_string_normalizer that returns an array works for request bodies, not only query strings. Before, it raised NoMethodError when sending. (#907)

Other

  • Fixed the custom connection adapter examples in the docs so they run. (#906)
  • Removed unused cucumber steps. (#908)

Don't miss a new httparty release

NewReleases is sending notifications on new releases.