Skip to content

[Bug]: Sending two requests with the rust library reqwest makes the second fail #425

Description

@tyilo

Repro steps

  • Create a Rust project that sends two requests using reqwest:
$ cargo new reqwest-test
$ cd reqwest-test
$ cargo add reqwest
$ cargo add tokio -F full

Edit src/main.rs:

use reqwest::Client;

#[tokio::main]
async fn main() {
    let client = Client::new();

    for _ in 0..2 {
        let response = client.get("http://example.org/").send().await.unwrap();
        println!("Response: {:?}", response.status());
    }
}
  • Run the binary and see that it makes two successful requests:
$ cargo run --release
...
Response: 200
Response: 200
  • Open the desktop app
  • Run the binary with HTTP_PROXY set and see that the second request fails:
$ HTTP_PROXY=http://127.0.0.1:8000 cargo run --release
Response: 200
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Request, url: Url { scheme: "http", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("example.org")), port: None, path: "/", query: None, fragment: None }, source: hyper::Error(IncompleteMessage) }', src/main.rs:8:71
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

How often does this bug happen?

Often

The desktop OS you're using

Arch Linux

Details of other apps/devices

No response

Error screenshot

image

Any other info?

I also tested the binary with mitmproxy to rule out that the possibility that the error is in reqwest's handling of HTTP proxies.
It works fine:

$ mitmproxy

In another terminal:

$ HTTP_PROXY=http://127.0.0.1:8080 cargo run --release
...
Response: 200
Response: 200

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions