http-rs/http-client

Types and traits for http clients

cargo add installed run:

http-client

.

API Docs | Releases | Contributing

Installation

With cargo add installed run:

$ cargo add http-client

Safety

For non-wasm clients, this crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

  • Issues labeled "good first issue"
  • Issues labeled "help wanted"

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Issues

Collection of the latest Issues

trrk

trrk

bug
Comment Icon1

I believe the timeout that can be set through http_client refers to the connection timeout. And I think the process shown below sets a timeout on isahc. According to the isahc documentation, it is not the connection timeout that can be set with timeout(). The connection timeout can be set with connect_timeout(). https://github.com/http-rs/http-client/blob/3c0ed9a2f350749f48f579867139dd9e3afdf182/src/isahc.rs#L90 https://github.com/http-rs/http-client/blob/3c0ed9a2f350749f48f579867139dd9e3afdf182/src/isahc.rs#L118

trrk

trrk

bug
Comment Icon0

IsahcClient::new() creates a client with a timeout set to 60 seconds. However, this client does not actually return a timeout error after 60 seconds. IsahcClient created with Config and try_into does not have this problem and returns a timeout error after 60 seconds.


Here are some additional explanations.

  • There is a concern related to this IsahcClient timeout issue. It is possible that settings other than timeout are also being ignored. Other clients may also have this issue.

  • I noticed this problem while using surf. The timeout behavior was different for the two below.

  • Here is the code I used to check the behavior. It takes more than 60 seconds to run. Depending on the environment, it may not work as expected.

Fishrock123

Fishrock123

Comment Icon12

For Surf 3.0 I am almost certainly going to merge http-client back into it. The feature flag mess currently is hellish and maintaining it is a bad experience. Most of this would be solved by not having surf set downstream feature flags.

If you use http-client for a client other than surf you either need to step up and help me maintain this or lose it. Thanks.

jbr

jbr

Comment Icon4

this is also an async-h1 client issue, but ideally would be exposed at both the surf and http-client levels as well — users may want to upgrade a request made with http-client to a websocket. this is especially relevant in a reverse-proxy scenario, but there may be other use cases as well

sunng87

sunng87

semver-major
Comment Icon2

I was trying to use surf on tokio 1.0 executor. It seems the tokio library family needs to be upgraded to 1.0, including hyper 0.14 for this library.

olanod

olanod

Comment Icon1

Hi! any chance you might want to expose the mod fetch publicly or make it a tiny crate? I started doing something similar and later I just plain copy-pasted the module since it does everything I need, I'm getting some requests that I want to convert to http_types::Request, same with responses and potentially converting the other way around from the http_types to JS equivalent. Even the WindowOrWorker is useful.

yoshuawuyts

yoshuawuyts

enhancement
Comment Icon0

For testing Surf it'd be great if we could create a mock backend to automatically handle http responses. We could in turn for example use tide with the mock frontend to create mock responses.

The benefit of this is that unit tests should become really fast, and we can provide extra methods to assert values, as seen in https://github.com/http-rs/tide/pull/273. Thanks!

Versions

Find the latest versions by id

v6.5.3 - Jun 20, 2022

Deps

  • h1-client now uses dashmap at version 5.x >, fixing an unsoundness issue.

v6.5.2 - May 10, 2022

Deps

  • Now only uses dashmap for h1-client.

v6.5.1 - Aug 19, 2021

Same as 6.5.0 with one change:

Config::max_connections_per_host() is now properly named Config::set_max_connections_per_host().

Added

  • Config has been stabilized and is now available by default!
  • wasm_client support for Config (only timeouts).
  • Config::max_connections_per_host (Supported on h1_client and curl_client.)

Deprecated

  • H1Client::with_max_connections() will be superseded by Config::max_connections_per_host.

v6.5.0 - Aug 19, 2021

(Yanked)

Added

  • Config has been stabilized and is now available by default!
  • wasm_client support for Config (only timeouts).
  • Config::max_connections_per_host (Supported on h1_client and curl_client.)

Deprecated

  • H1Client::with_max_connections() will be superseded by Config::max_connections_per_host.

v6.4.1 - May 19, 2021

Docs

  • Added "unstable-config" to the docs builds.

6.4.0 - May 19, 2021

Added

  • Added a new unstable-config feature, which exposes runtime configuration via a new Config struct.

v6.3.5 - Mar 12, 2021

Fixed

  • Multiple headers of the same name are now present with any client backend and not just h1_client.
  • Connection when multiple IPs are present for a hostname not function with the h1_client backend.

v6.3.4 - Mar 06, 2021

Fixed

  • h1_client connection pools now properly check if connections are still alive before recycling them.
    • Like, actually properly this time.
    • There is a test now to ensure closed connections don't cause errors.

v6.3.3 - Mar 01, 2021

Fixed

  • h1_client connection pools now properly check if connections are still alive before recycling them.

v6.3.1 - Feb 15, 2021

Fixed

  • Allow http-client to build & run properly when h1_client is enabled without either tls option.
  • Prefer rustls if both tls features are enabled.

Internal

  • More exhaustive CI for feature combinations.

v6.3.0 - Feb 12, 2021

Added

  • Connection pooling (HTTP/1.1 keep-alive) for h1_client (default).
  • native-tls (default) and rustls feature flags.
    • Only works with h1_client.
  • Isahc metrics as a response extension for curl_client.

Fixed

  • Box<dyn HttpClient> no longer infinitely recurses.
  • curl_client now always correctly reads the response body.
  • hyper_client should now build correctly.
  • WasmClient fetch from worker scope now works correctly.

Internal

  • Improved CI

v6.2.0 - Oct 26, 2020

This release implements HttpClient for Box<dyn HttpClient>.

Added

  • impl HttpClient for Box<dyn HttpClient>

v6.1.0 - Oct 09, 2020

This release brings improvements for HyperClient (hyper_client feature).

Added

  • HyperClient now impls Default.
  • HyperClient::from_client(hyper::Client<C>).

Changed

  • HyperClient now re-uses the internal client, allowing connection pooling.

v6.0.0 - Oct 09, 2020

This release moves the responsibility of any client sharing to the user.

Changed

  • HttpClient implementations no longer impl Clone.
    • The responsibility for sharing is the user's.
  • H1Client can no longer be instatiated via H1Client {}.
    • ::new() should be used.

v5.0.1 - Sep 18, 2020

Fixed

  • Fixed a body stream translation bug in the hyper_client.

v5.0.0 - Sep 18, 2020

This release includes an optional backend using hyper.rs, and uses async-trait for HttpClient.

Added

  • hyper_client feature, for using hyper.rs as the client backend.

Changed

  • HttpClient now uses async-trait.
    • This attribute is also re-exported as http_client::async_trait.

Fixed

  • Fixed WASM compilation.
  • Fixed Isahc (curl) client translation setting duplicate headers incorrectly.

4.0.0 - Jul 10, 2020

This release allows HttpClient to be used as a dynamic Trait object.

  • HttpClient: removed Clone bounds.
  • HttpClient: removed Error type.

v3.0.0 - May 29, 2020

This patch updates http-client to http-types 2.0.0 and a new version of async-h1.

Changes

  • http types and async-h1 for 2.0.0 #27

v2.0.0 - Apr 17, 2020

Added

Changed

Information - Updated Aug 04, 2022

Stars: 102
Forks: 43
Issues: 20

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

This library is released under the MIT License and the Apache v2 License (see License)

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀
CLI

132

The simple cli library

This project is duel-licensed under both MIT and Apache, so feel free to use either at your discretion

The simple cli library
CLI

132

The simple cli library

This project is duel-licensed under both MIT and Apache, so feel free to use either at your discretion

The simple cli library

A Rust wrapper library for smealum's ctrulib

A Rust wrapper library for smealum's LICENSE-APACHE, COPYRIGHT for details

A Rust wrapper library for smealum's ctrulib

OpenSearch Rust Client

a community-driven, open source fork of elasticsearch-rs licensed under the Apache v2

OpenSearch Rust Client

A 'Space Invader' clone made with rust and made for the terminal

Inspired by Apache License (Version 2

A 'Space Invader' clone made with rust and made for the terminal

The compact yet complete benchmarking suite for Rust

This project is licensed under the Apache-2

The compact yet complete benchmarking suite for Rust

Rust SDK for Structured Expression Project Toolkit (SEPT)

Copyright 2021 by Victor Dods, licensed under Apache 2

Rust SDK for Structured Expression Project Toolkit (SEPT)
Facebook Instagram Twitter GitHub Dribbble
Privacy