httpx/doc/release_notes/0_15_0.md
2021-06-24 12:39:41 +03:00

53 lines
1.6 KiB
Markdown

# 0.15.0
## Features
### HTTP response pattern-matching (ruby 3 only)
You can now apply pattern matching in responses:
```ruby
case response = HTTPX.get("https://google.com")
in { status: 200..399, headers: [*, ["x-special-token", token], *], body: }
puts "success: #{body.to_s}"
in { status: 400..499, body: }
puts "client error: #{body.to_s}"
in { status: 500.., body: }
puts "server error: #{body.to_s}"
in { error: error }
puts "error: #{error.message}"
else
raise "unexpected: #{response}"
end
```
### NTLM Authentication
A new plugin, `:ntml_authentication`, is now available. Like the name suggests, it allows authenticating requests via [NTLM](https://docs.microsoft.com/en-us/windows-server/security/kerberos/ntlm-overview).
```ruby
ntlm_http = HTTPX.plugin(:ntlm_authentication)
ntlm.ntlm_authentication("user", "password").get("http://protected-area-requiring-ntlm.net")
# or for a specific domain
ntlm.ntlm_authentication("user", "password", "Domain\\User").get("http://protected-area-requiring-ntlm.net")
```
## Improvemennts
A new timeout option, `settings_timeout`, is supported for the HTTP/2 handshake; after the TCP and TLS handshakes are complete, and initiating the HTTP/2 handshake, the client terminates the connection with SETTINGS_TIMEOUT error code, if it doesn't receive the server settings for the amount of seconds set in `settings_timeout` (by default, 10 seconds).
```ruby
# if you want to change
HTTPX.with(timeout: {settings_timeout: 5})....
```
IDNA 2008 support is now possibly, by integrating [idnx](https://github.com/HoneyryderChuck/idnx) into your dependencies:
```ruby
# in Gemfile
gem "httpx"
gem "idnx"
```