Discussion about Expect: 100-continue
It seems that reqwest does not support 100-continue, but in some cases it appears to be necessary.
Issue description: In certain network environments, requests sent using reqwest fail with the error message “error sending request for url”, while the same requests work correctly when executed with the curl command. Packet capture analysis shows that the requests from reqwest are actively terminated by the gateway, likely due to the absence of the Expect: 100-continue header. I confirmed this suspicion by switching to the isahc library.
Is there any plan to support 100-continue?
This is the code that works correctly with isahc. If the line header("Expect", "100-continue") is removed, it will fail to send the request properly, just like reqwest.
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);
Additionally, I mentioned this issue in #2536 , but it seems to have been ignored.
You can always add .header("expect", "100-continue") when using reqwest, no problem. It won't automatically delay the body, but if that's all that is needed, it should work immediately.
If you need the delay, that would be a new feature that could be added, yes. Probably not one I've personally prioritize, but contributing it would be welcome. Starting with a design would be wise.
Thanks for the reply. However, based on my testing, simply adding .header("Expect", "100-continue") does not solve the problem. The gateway still rejects the request.