# 0.17.0

## Features

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

https://gitlab.com/os85/httpx/-/wikis/Response-Handling#response-decoding

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.

```ruby
# 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 (b126938a6547e09b726dd64298fb488891d938e9).
* `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) (3d549817cb41d4b904102fdc61afe3ecd9170893).
* 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 (cc02679b804f63798f5d2136a039be1624e96ab6).

### 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 calculations

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).

## 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.