Skip to content

From v0.14 to v1 difficulties using Client #3455

@frederikhors

Description

@frederikhors

Coming from:

hyper = { version = "0.14.27", default-features = false }

I switched to hyper 1.0.1 but now I'm stuck upgrading the below code:

use hyper::{client::Client, Body, Request};

pub async fn ping(uri: &str) -> Result<()> {
    let hyper_client = Client::new();

    if let Err(e) = retry(5, 2, || {
        let req = Request::builder()
            .uri(uri.to_string())
            .body(Body::empty())
            .unwrap();

        hyper_client.request(req)
    })
    .await
    {
        return "cannot ping!"
    }

    Ok(())
}

Can you help me understand what to use instead of client::Client now?

Should I use hyper_util::client::legacy::Client?

Why the word legacy in the name?

Or should I use all the code in https://github.com/hyperium/hyper/blob/master/examples/client.rs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions