reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

[question] reqwest requires curl to work??

Open aaron-tillekeratne opened this issue 11 months ago • 4 comments

Hey reqwest team,

I'm building a debian:bookworm-slim image for a rust grpc api. Part of the server side of this API makes a http call to another service. But it looks like it fails with a rather unhelpful error message error sending request for url .

Doing some testing I noticed that it works fine if I install curl on the image.

Am I missing something here or is this a requirement for reqwest to make http requests?

Cheers, A

Snippet of build

FROM debian:bookworm-slim AS release-base 

RUN apt-get update && apt-get upgrade -y  && apt-get install openssl -y
# binary copy and app stuff later

aaron-tillekeratne avatar Jan 31 '25 05:01 aaron-tillekeratne

For the error, you can use the {:?} format, or use an error reporter, to be able to print the source chain, which will explain more what happened.

As for why it suddenly works with curl, perhaps the curl package includes a system dependency on a TLS package that reqwest also wants? Or that enables more features in one? Hard to know without the full error message.

seanmonstar avatar Jan 31 '25 11:01 seanmonstar

I ran into this locally on docker with ubuntu 22.04.

This snippet

    Client::builder()
        .pool_max_idle_per_host(0)
        .build()
        .expect("Build reqwest client")

Would panic with:

thread 'main' panicked at common/src/clients.rs:17:10:
Build reqwest client: reqwest::Error { kind: Builder, source: Normal(ErrorStack([])) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Which wasn't a lot to go on sadly! Fortunately, I fixed it initially by installing curl in my docker container but found that installing openssl was sufficient.

Mainly posting this since other folks might run into this empty error stack.

itsibitzi avatar Feb 06 '25 21:02 itsibitzi

I ran into the same issue using the bitwarden crate that depends on Reqwest. Although for me installing only openssl did not work, curl alone did the trick though. I'm using the debian:bullseye-slim image.

This is the panic message I got, in case it's helpful:

[bot] | thread 'main' panicked at src/main.rs:38:62:
[bot] | called `Result::unwrap()` on an `Err` value: Reqwest(reqwest::Error { kind: Request, url: "https://identity.bitwarden.com/connect/token", source: hyper_util::client::legacy::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: AlertReceived(DecodeError) } }) })

online-octopus avatar Mar 22 '25 16:03 online-octopus

You're probably missing ca-certificates.

paolobarbolini avatar Mar 22 '25 22:03 paolobarbolini

I also ran into this problem. I found out that it was caused by the missing Expect: 100-continue mechanism. Under the same conditions, using curl or isahc = "1.7.2" works fine. Packet capture shows the difference clearly.

With isahc = "1.7.2":

let upload_url = "";
let body = "";

use isahc::Request;
use isahc::RequestExt;
use isahc::ReadResponseExt;
use isahc::config::ExpectContinue;

let mut response = Request::post(upload_url)
    .tcp_nodelay()
    .expect_continue(ExpectContinue::enabled())
    .header("Content-Type", "application/x-www-form-urlencoded")
    .header("Expect", "100-continue") // Without this line the request fails
    .body(body.to_string())?
    .send()?; 

println!("Status: {}", response.status());
let text = response.text()?;
println!("Response: {}", text);

Is there any plan to add proper Expect: 100-continue support in reqwest (like curl/libcurl does)?

vnt-dev avatar Sep 27 '25 09:09 vnt-dev

Did you mean to ask about reqwest, your example mentions isahc. Either way, this probably isn't the right issue. If you want to ask more about reqwest and expect-continue, open a new issue or maybe even a discussion.

This issue was about implicit build dependencies on some Linux installations. But I don't think I'll keep the issue open.

seanmonstar avatar Sep 27 '25 12:09 seanmonstar