Two new methods,
#form, were added to
HTTPX::Response. As the name implies, they’ll decode the raw payload into ruby objects you can work with.
# after HTTPX.get("https://api.smth/endpoint-returning-json") response.json # same as JSON.dump(response.to_s)
Although not yet documented, integrating custom decoders is also possible (i.e. parsing HTML with
nokogiri or something similar).
Due to it being an intensive task, internal interest calculation in connections was reduce to the bare minimum.
A lot of effort went into avoiding generating options objects internally whenever necessary. This means, when sending several requests with the same set of options (the most common case in
httpx usage), internally only one object is passed around. For that, the following improvements were done:
Options#mergereturns the same options the the options being merged are a subset of the current set of options (b126938a6547e09b726dd64298fb488891d938e9).
Session#build_requestbypasses instantiation of options if it receives an
Optionsobject (which happens internally in the happy path, if users don’t call
SessionAPIs to not pass around options, and instead rely on accessing request options.
Options#to_hashdoes not build internal garbage arrays anymore (cc02679b804f63798f5d2136a039be1624e96ab6).
Some code paths in the HTTP/1 parser still using regular expressions were replaced by string operations accomplishing the same.
Managing open HTTP/1 connections relies on operations calculating whether there are requests waiting for completion. This relied on traversing all requests for that connectionn (O(n)); it now only checks the completion state of the first and last request of that connection, given that all requests in HTTP/1 are sequential (O(1)); this optimization brings a big improvement to persistent and pipelined requests (65261217b1270913e4bb93717e8b8dcfa775565a).
fixing HTTP/1 protocol uncompliant exposing multiple values for the "Host" header (e435dd0534314508262184fb03d83124d89d2079).
Custom response finalizer introduced in 0.16.0 has been reverted. It was brought to my attention that
Tempfileimplementation already takes care of the file on GC (and
httpxwas duplicating), and the approach taken in
httpxwas buggy in several ways (not tolerant to forks, never recycled finalizers...) (aa3be21c890f92a41afcc7931f01dd24cc801f7c).
RBS Typing improvements based on latest stdlib signatures additions, such as
socket and others.