1_8_0.md

doc/release_notes/1_8_0.md

1.8.0

Features

New plugins

:server_sent_events plugin

The :server_sent_events plugin provides a convenience API to deal with text/event-stream requests, on top of the :stream plugin.

session = HTTPX.plugin(:server_sent_events)

sse_response = session.get("https://example.com/event-stream", event_stream: true)

sse_response.each_message do |message|
  puts message.id
  puts message.event
  puts message.data
end

You can read more about it in gitlab.com/os85/httpx/wikis/Server-Sent-Events .

:cache plugin

The :cache plugin allows caching responses. It exposes some options to determine some of its functionality, i.e. whether a request can use a cached response, whether a response can be cached, whether a cached response is still valid, etc.

This functionality was extracted from the :response_cache plugin, which now uses it under the hood.

You can read more about it in gitlab.com/os85/httpx/wikis/Cache .

:ntlm_v2_auth plugin

The :ntlm_v2_auth plugin is now available. It implements the most recent version of the NTLM authentication scheme supported by Microsoft products.

You can read more about it in gitlab.com/os85/httpx/wikis/Auth#ntlm-v2-auth .

New timeouts

:total_request_timeout

You can use the :total_request_timeout to time the time it takes a request to get its final response. This includes when your requests follows redirects (via the :follow_redirects plugin) or is retried multiple times (via the ‘:retries´ plugin).

:ping_timeout

Defines the number of seconds a connection waits to receive a ping response when probing for a connection for liveness.

Defaults to 2 seconds.

:ssrf_filter plugin new options

:extra_unsafe_ranges

A list of extra unsafe IPs or IP ranges to the default deny list.

:safe_private_ranges

A list of IPs or IP ranges which are allowed and would otherwise be denied.

:auth plugin new option

:reset_auth_header_expires_in/at

The :reset_auth_header_expires_in and :reset_auth_header_expires_at options enable discarding an authorization token an X number of seconds after it has been generated, or at a particuar point in time, respectively. This is useful when the token is dynamically generated, so that you can preemptively renegotiate a new one.

The :oauth plugin makes use of these fields, alongside the expires_in claim from token responses, to refresh the token as soon as the it expires.

:max_response_body_size

Can be set to the maximum number of bytes a response may have, after which it’ll return an HTTPX::ErrorResponse. The limit is enforced based on the content-length header and as bytes are received.

:max_response_headers

Can be set to the maximum number of headers a response may have.

:max_response_header_value_size

Can be set to the maximum number of bytes a header value may have. In cases where a header field may be spread across multiple entries (ex. "cookie"), the limit is enforced on the aggregate byte size.

resolver file cache

By specifying :file as the resolver :cache option, the DNS entries will be cached in a known location in your file system. This will allow sharing entries across processes within the same machine to reduce overall DNS traffic. You can use it via:

session = HTTPX.with(resolver_options: { cache: :file })
session.get("https://example.com")

Improvements

  • http-2 minimum version is now 1.2.0, which brings performance benefits around frame parsing and other common operations.

Bugfixes

  • several fixes to make httpx usable inside a fiber scheduler in ruby 4.

  • :proxy plugin: unescape user/password from proxy options before reusing it (to avoid using percent-encoded values when p.ex. generating base64-encoding for basic auth).

  • :retries plugin: fixed the polynomial and exponential backoff :retry_after strategies calculation.

  • :tracing plugin: fixing span start time set up when request is sent to a closed connection, or when a long-lived connection will be probed for liveness.

  • datadog adapter: fixed integration with the datadog gem v2.34 or higher.