hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.57k stars 1.6k forks source link

CHANGELOG doesn't explain what happened to `hyper::Client` or `HttpConnector` #3450

Open simbleau opened 11 months ago

simbleau commented 11 months ago

Version 1.0

Description It's pretty much impossible to update hyper/http to 1.0 for some complex projects that relied heavily on the implementation of Client/HttpConnector since it's not documented how to replace the functionality in the CHANGELOG.

See https://github.com/awslabs/aws-lambda-rust-runtime/issues/737 + https://github.com/awslabs/aws-lambda-rust-runtime/pull/740

WhyNotHugo commented 11 months ago

The documentation still refers to the Client type even though it's gone: https://docs.rs/hyper/1.0.1/hyper/client/conn/index.html

I've been trying to upgrade libdav (a caldav/carddav client) to hyper 1.0. The client in hyper_util::client::legacy::Client is quite different. It needs a generic Body type, which won't work for code that sends requests with different Body implementations.

I'm unsure what to do. The new client is labeled "legacy", and I'd need a non-trivial amount of redesign to integrate with it. Are there plans to introduce a new Client type? I'm trying to decide if I should redesign my entire code around the new Client in hyper_util, or if it's best to wait for for a new Client implementation.

sfackler commented 11 months ago

The 0.14 client also has a generic body type.

WhyNotHugo commented 11 months ago

True, it did. The default for 0.14 worked for me with both Body::from(String) and Body::empty(), but now empty is Empty::new(), which is a different type. I'm not yet sure what I'd use in place of Body::from(String).

WhyNotHugo commented 11 months ago

I think that my main point of confusion is due to:

rename Body struct to Incoming

It's not immediately obvious what should be used in its place.

@simbleau For Client and HttpConnector you need:

hyper-util = { version = "0.1.1", features = ["client", "client-legacy", "http1"] }
WhyNotHugo commented 11 months ago

The CHANGELOG mentions that client::connect was dropped and links to 5e206883984fe6de2812861ec363964d9, which points to the new crate.

simbleau commented 11 months ago

The CHANGELOG mentions that client::connect was dropped and links to 5e20688, which points to the new crate.

This is very helpful... Let me see if I hit another brick wall.

+1!

seanmonstar commented 11 months ago

There's also https://hyper.rs/guides/1/upgrading/, which while a bit bare, tries to gather all the pain points that the CHANGELOG doesn't seem to address. Anything specific that is hard to find, we can add to that guide.

allan2 commented 11 months ago

It would be nice if it were mentioned that HttpConnector implements tower_service::Service<Uri> in 1.0 instead of hyper::service::Service<Uri> in 0.14.

It was easy for me to miss this when converting IO traits from Tower to hyper. I wasn't expecting it to go the other way.