[ANN] httpx 0.17.0 released

httpx 0.17.0 has been released.

HTTPX.get("HoneyryderChuck / httpx · GitLab
<HoneyryderChuck / httpx · GitLab>")

HTTPX is an HTTP client library for the Ruby programming language.

Among its features, it supports:

* HTTP/2 and HTTP/1.x protocol versions
* Concurrent requests by default
* Simple and chainable API
* Proxy Support (HTTP(S), Socks4/4a/5)
* Simple Timeout System
* Lightweight by default (require what you need)

And also:

* Compression (gzip, deflate, brotli)
* Streaming Requests
* Authentication (Basic Auth, Digest Auth, AWS Sigv4)
* Expect 100-continue
* Multipart Requests
* Cookies
* HTTP/2 Server Push
* H2C Upgrade
* Automatic follow redirects
* International Domain Names

Here are the updates since the last one.

# 0.17.0

## Features

### Response mime type decoders (#json, #form)

Two new methods, `#json` and `#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).

## Improvements

### Connection: reduce interest calculations

Due to it being an intensive task, internal interest calculation in
connections was reduce to the bare minimum.

### Immutable Options, internal recycling of instances, improves memory
usage in the happy path

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#merge` returns the same options the the options being merged are
a subset of the current set of options
* `Session#build_request` bypasses instantiation of options if it receives
an `Options` object (which happens internally in the happy path, if users
don't call `#build_request` directly)
* Improving internal `Session` APIs to not pass around options, and instead
rely on accessing request options.
* `Options#to_hash` does not build internal garbage arrays anymore

### Reduce regexp operations in the HTTP/1 parser

Some code paths in the HTTP/1 parser still using regular expressions were
replaced by string operations accomplishing the same.

### HTTP/1 improvements on the complexity of connection accounting

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

## Bugfixes

* 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 `Tempfile` implementation already takes care
of the file on GC (and `httpx` was duplicating), and the approach taken in
`httpx` was buggy in several ways (not tolerant to forks, never recycled
finalizers...) (aa3be21c890f92a41afcc7931f01dd24cc801f7c).

## Chore

RBS Typing improvements based on latest stdlib signatures additions, such
as `openssl`, `digest`, `socket` and others.

# 0.16.1

## Bugfixes

* fixed native resolver hanging when dealing with FQDN end names (#145).