Surf 2.3.0 has been released!

surf is a modular Rust HTTP client built for rapid development. It comes with a powerful middleware system and feature-swappable backend implementations. It is part of the http-rs project and a counterpart to the tide server framework. Check out the docs or join us on Zulip

(v2.3.0 was yanked, faulty git base - v2.3.1 instead)

Additions

  • surf::Config, a way to configure surf::Client-s!
    • Config::add_header() - client-wide headers
    • Config::set_base_url() - client-wide base url
    • Config::set_http_keep_alive()
    • Config::set_tcp_no_delay()
    • Config::set_timeout() - per-request timeout.
    • Config::set_max_connections_per_host()
    • Config::set_tls_config() - only available on h1-client or h1-client-rustls.
    • More config may be available from the underlying http_client::Config.
    • Easily turns into a Client via std::convert::TryInto.
  • Extra RequestBuilder helpers for setting the body from different sources.
    • body_json(), body_string(), body_bytes(), body_file().
  • Client::request() for making arbitrary HTTP-method requests from a client.

Improvements

  • The h1-client backend now uses a shared client for 'one-off' style (surf::get(), etc) requests.
    • The curl-client and hyper-client backends already did this.
  • The wasm-client feature now pulls in getrandom's "js" feature.
    • This isn't a problem since the wasm client only works in a web/emscripten environment anyways.

Deprecations

  • Client::set_base_url has been deprecated in favor of Config.

Docs

  • Several docs fixes
  • Minor 'branding' changes

Release notes on GitHub: Release 2.3.0 · http-rs/surf · GitHub
Docs: surf - Rust

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.