0_15_0.md

doc/release_notes/0_15_0.md
Last Update: 2024-04-03 14:03:54 +0000

0.15.0

Features

HTTP response pattern-matching (ruby 3 only)

You can now apply pattern matching in responses:

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.

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

# if you want to change
HTTPX.with(timeout: {settings_timeout: 5})....

IDNA 2008 support is now possibly, by integrating idnx into your dependencies:

# in Gemfile
gem "httpx"
gem "idnx"