Skip to content

v2.0.0

Latest

Choose a tag to compare

@phip1611 phip1611 released this 07 Oct 09:56
· 9 commits to main since this release
v2.0.0
df44908

This is the biggest release since v1.0.0. ttfb now supports HTTP/2 and
HTTP/3 (over QUIC) in addition to HTTP/1.1, and by default selects the newest
protocol the server supports.

  • Library users: the ttfb() function is replaced by TtfbClient and
    TtfbOptions, and several types changed. See the BREAKING entries below.
  • Binary users: the default protocol is no longer HTTP/1.1. Use --http1.1
    for the previous behavior. New options include --repeat for statistics,
    --json for scripts, --headers, --timeout, and -4/-6.

ttfb lib

  • BREAKING The ttfb() function is replaced by TtfbClient, which is
    configured with TtfbOptions:
    TtfbClient::new(TtfbOptions::default()).measure(url).
    TtfbOptions::protocol takes a ProtocolSelection, and
    TtfbOutcome::protocol_selection() reports it. TtfbOptions is
    #[non_exhaustive], so that new options are no breaking change: set its
    fields on TtfbOptions::default().
  • BREAKING TtfbError, ResolveDnsError, and InvalidUrlError are
    #[non_exhaustive].
  • BREAKING TtfbError::CantConnectTls and TtfbError::CantVerifyTls
    are replaced by TtfbError::Tls, which describes the error as a string.
    The lib no longer depends on rustls-connector.
  • BREAKING AllowInvalidCertsVerifier is no longer public. It was
    exported by accident.
  • BREAKING InvalidUrlError::Other is removed. It was never used.
  • BREAKING DurationPair no longer implements Default. A pair of zero
    durations isn't a meaningful measurement.
  • BREAKING TtfbOutcome::tcp_connect_duration() and
    TtfbOutcome::tls_handshake_duration() are replaced by
    TtfbOutcome::connection_handshake(). It reports how the connection was
    established as the new ConnectionHandshake: a TCP connect with an optional
    TLS handshake, or a QUIC handshake for HTTP/3.
  • BREAKING TtfbError has the new variants UnsupportedHttpProtocol,
    Http2, and Http3.
  • BREAKING ResolveDnsError::Other and TtfbError::CantConfigureDNSError
    describe the error as a string instead of exposing the ResolveError of
    hickory-resolver, so that the DNS resolver can change without a breaking
    change.
  • TLS trusts the system's root certificates and the bundled Mozilla root
    certificates together. Previously, the bundled ones were only used if the
    system's could not be loaded.
  • HTTPS works with IPv6 addresses, such as https://[2606:4700:4700::1111].
  • TtfbError compares CantConnectHttp and OtherStreamError correctly.
    Before, two errors of the same variant were never equal, while the two
    variants were equal with the same io::ErrorKind.
  • The duration of the DNS lookup no longer includes starting the internal Tokio
    runtime and its thread, which took about 0.1-0.3 ms.
  • Added TtfbOutcome::protocol(), which reports the HTTP protocol used as
    HttpProtocol.
  • Added HTTP/2 measurements over TLS with HttpProtocol::Http2. They need
    the Cargo feature http2, which is enabled by default. Without it, they
    fail with the new TtfbError::UnsupportedHttpProtocol.
  • Added HTTP/3 measurements over QUIC with HttpProtocol::Http3. They need
    the Cargo feature http3, which is enabled by default.
  • ProtocolSelection::Auto, the default, selects HTTP/3, HTTP/2, or
    HTTP/1.1, whichever the server supports first in this order. Protocols built
    without their Cargo feature are skipped.
  • TtfbOptions::ip_version selects the IP version of the connection:
    IpVersion::Any, the default, prefers IPv4 as before, while IpVersion::V4
    and IpVersion::V6 use only that version. A host without an address of that
    version fails with the new TtfbError::NoAddressForIpVersion.
  • TtfbOptions::timeout limits the duration of a measurement, from the DNS
    lookup to the end of the download. It defaults to 10 s and must be between
    1 s and 60 min. A measurement that exceeds it fails with the new
    TtfbError::Timeout.
  • TtfbOutcome::status() and TtfbOutcome::headers() return the status code
    and the headers of the final response. The types StatusCode and
    HeaderMap of the http crate are re-exported.

ttfb binary

  • BREAKING The protocol is now chosen automatically by default: HTTP/3,
    then HTTP/2, then HTTP/1.1. Use --http1.1 for the previous behavior.
    For HTTPS servers without HTTP/3, the HTTP/3 attempt usually waits for its
    timeout of 1 s, which prolongs the run but not the measured timings.
  • Added --http1.1, --http2, --http3, and --auto-protocol to select
    the HTTP protocol.
  • Added --repeat N and --repeat Ns, which measure N times or repeatedly
    for N seconds and print the minimum, median, mean, and maximum of the
    relative and the absolute duration of each step.
  • Added --timeout <SECS>, the maximum duration of a measurement, which
    defaults to 10 s and must be between 1 s and 3600 s.
  • Added -4/--ipv4 and -6/--ipv6 to require an IP version. Without them,
    IPv4 is preferred as before.
  • Added --headers, which prints the status line and the headers of the
    response.
  • Added --json, which prints the results only as JSON in a single line, e.g.,
    for scripts. Its dependencies grow the release binary by 41 KiB (33 KiB
    stripped).
  • The tables show the timings in ms with one decimal. More decimals only
    showed measurement noise. Durations below 0.05 ms are shown as <0.1.
  • The output shows the IP address and port, the HTTP protocol, the status, and
    the download of the response.
  • The output labels "TCP connect" and "HTTP GET Req" are now "TCP Connect"
    and "HTTP Send GET".
  • The output shows the QUIC handshake of HTTP/3 measurements instead of the
    TCP connect and the TLS handshake.
  • The release binary grows with the HTTP/2 and HTTP/3 support. On Linux,
    built with Rust 1.99 (sizes when stripped in parentheses):
    • v1.15.0: 3.2 MiB (2.5 MiB)
    • without http2 and http3: 3.2 MiB (2.5 MiB)
    • with http2: 3.5 MiB (2.8 MiB)
    • with http3: 4.0 MiB (3.2 MiB)
    • with http2 and http3, the default: 4.3 MiB (3.4 MiB)

PR List

Full Changelog: v1.15.0...v2.0.0