Full Changelog: v0.24.3...v0.24.4
Deprecations
HTTParty 0.25 will stop adding a trailing slash to an empty (""), query-only ("?a=1") or fragment-only ("#top") request path. Today, get("") against base_uri "https://example.com/api/articles" requests /api/articles/. In 0.25 it will request /api/articles, which matches RFC 3986 and what curl, Faraday, axios and other HTTP clients do. (#742, #898, #900)
This release changes no URLs. It prints a [DEPRECATION] warning to stderr, once per request, for each request whose URL will change in 0.25:
[DEPRECATION] HTTParty added a trailing slash to the request path (/api/articles/) because the path passed to the request was empty. ...
The warning shows only the path, never the full URL, so credentials or query values in your base_uri are not printed.
To keep the trailing slash in 0.25, pass "/" as the path. It requests the same URL in both versions and silences the warning:
get("/") # https://example.com/api/articles/ in 0.24 and 0.25If you want the 0.25 behavior, no change is needed and the warning goes away when you upgrade. To get it now and silence the warning, pass a URI object, which HTTParty already uses as given:
get(URI("")) # https://example.com/api/articles in 0.24 and 0.25There is no warning when nothing will change: non-empty paths, get("/"), a base_uri without a path, absolute URLs, the Addressable adapter, and redirects.
Bug Fixes
Requests
- The
headers:option and thecookiesclass method accept any object that responds toto_hash, as documented. Before, such objects raisedNoMethodErrororRuntimeError. (#899) - Callable header values work with any object that responds to
call, not only procs and lambdas. (#897) - Multipart bodies accept hash-like objects that respond to
to_hash. (#894) - Arrays inside inherited options, such as
default_params tags: ["one"], are copied for each subclass, so changing them in one class no longer changes them in its parent or sibling classes. (#896) headno longer modifies the options hash you pass to it. (#884)webcal://requests keep their query string, including thequery:option. (#859)
Responses
- A
parsed_responseoffalseornilis cached, so the parser runs once instead of on every call. (#893) - Responses with a capitalized content type, such as
Application/JSON, are parsed. (#877) - Responses can be marshaled when their request has a proc option or a
debug_outputstream. (#885)
Streaming uploads
- Streamed multipart reads return no more than the requested number of bytes. (#895)
- Files are rewound after a streamed upload, so they can be read or sent again. (#882)
Cookies and digest auth
- Following a redirect no longer sends
Max-Ageback as a cookie. (#878) - Digest auth sends each cookie as
name=valueonly, without attributes likePathorHttpOnly. (#888) - A digest auth cookie and your own
Cookieheader are joined with;in one header. Before they were joined with a comma, so servers read them as a single cookie and the digest session was lost. (#889) - Digest auth answers a challenge that offers several
qopvalues with just one. (#886) - When digest auth retries a request, your streaming block now receives the authenticated response. Before, the retry ran without your block. (#883)
Logging and CLI
- The curl log format no longer raises
Encoding::CompatibilityErroron a binary response body, and it logs bodies in other charsets, such as Latin-1, as readable UTF-8. (#848, #873, thanks @harissmansoor) - The curl log format handles a string
query:option instead of raising. (#887) Logger.add_formattertreats string and symbol names the same, so a string name can no longer silently replace a built-in formatter like:curl. (#869)bin/httpartykeeps every colon after the first in--headervalues and--userpasswords. (#872)bin/httpartyprints a usage message instead of a stack trace for usage mistakes, including a missing URL. (#874, #879)
Other
- The packaged gem no longer includes development files such as
.github/, theGemfileandscript/. (#865) - CI runs on Ruby 4.0. (#868)
- Removed code paths for Ruby versions older than 2.7. (#860, #881)
- Documentation: timeouts and Net::HTTP's retry of idempotent requests (#891), fixed doc and example code (#862, #864, #890), and CONTRIBUTING links (#863).
- Test and repository cleanup. (#849, #858, #861, #870, #871, #875, #876, #880)