-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
400 Bad Request after upgrading to 0.12.1 #2202
Comments
Cannot reproduce. You may check if you request were risk controlled for missing headers, invalid UA, etc. |
Thanks for taking a look. I don't think the headers are the issue in this case, but it's definitely possible that the problem lies elsewhere, probably a weird interaction between Figma's tech stack and Reqwest's dependencies. I'll try to do some additional testing, varying by egress location, platform, architecture, and TLS provider. With regards to bad headers, I'm intentionally not submitting any headers to keep the test case brief. With the code as written I get a 200 Success in 0.11.27, and a 400 Error on 0.12.x. The code, hardware, environment, and IP address are all identical. If you aren't experiencing the same change of behavior between versions, then something subtle and strange is happening somewhere. :) Just to add some data points, |
Is it the HTTP version? I wonder if the recent fix for ALPN is what was missing? |
I tried adding the Updated main.rs for easier testing: #[tokio::main]
async fn main() {
println!("It Works! (on my machine)");
}
#[tokio::test]
async fn figma_root_11() {
let res = reqwest_11::get("https://figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_root_12() {
let res = reqwest_12::get("https://figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_www_root_11() {
let res = reqwest_11::get("https://www.figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_www_root_12() {
let res = reqwest_12::get("https://www.figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_api_root_11() {
let res = reqwest_11::get("https://api.figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_api_root_12() {
let res = reqwest_12::get("https://api.figma.com/").await.unwrap();
assert_eq!(res.status(), 200, "Expected 200 Success: {res:#?}");
}
#[tokio::test]
async fn figma_api_me_11() {
let res = reqwest_11::get("https://api.figma.com/v1/me")
.await
.unwrap();
assert_eq!(res.status(), 403, "Expected 403 Forbidden: {res:#?}");
}
#[tokio::test]
async fn figma_api_api_me_12() {
let res = reqwest_12::get("https://api.figma.com/v1/me")
.await
.unwrap();
assert_eq!(res.status(), 403, "Expected 403 Forbidden: {res:#?}");
} cargo.toml: [package]
name = "reqwest-narrowing"
version = "0.1.0"
edition = "2021"
publish = false
[dependencies]
anyhow = "1.0.81"
reqwest_11 = { package = "reqwest", version = "=0.11.27", default-features = false, features = ["default-tls", "native-tls-alpn"] }
reqwest_12 = { package = "reqwest", version = "=0.12.1", default-features = false, features = ["default-tls", "native-tls-alpn"] }
tokio = { version = "1.36.0", features = ["full"] } Using
|
This comment was marked as outdated.
This comment was marked as outdated.
With regards to HTTP version, I've tried forcing HTTP 1: #[tokio::test]
async fn figma_api_root_http1_12() {
let client = reqwest_12::Client::builder().http1_only().build().unwrap();
let res = client.get("https://api.figma.com/")
.send()
.await
.unwrap();
assert_eq!(res.status(), 200, "Expected 403 Forbidden: {res:#?}");
}
#[tokio::test]
async fn figma_api_root_http1_11() {
let client = reqwest_11::Client::builder().http1_only().build().unwrap();
let res = client.get("https://api.figma.com/")
.send()
.await
.unwrap();
assert_eq!(res.status(), 200, "Expected 403 Forbidden: {res:#?}");
} Still no luck in 0.12:
|
Through investgation, I think 0.11.27
0.12.1
We can see what's different is just Tested manually with So funny test result... When enable alpn, h2 will be used and Not familiar with |
Hmmm. Or it could be that as part of the upgrade, since I changed around the body implementation, it might be indicating there is a body to send (but ends up being empty). |
I am willing to try to fix this issue. When making a request to an HTTPS website, a Content-Length: 0 request header is added. However, for HTTP websites, this request header is not added. request to
request to
|
Some requests have started failing after upgrading from 0.11.27 to 0.12.1.
In this case, api.figma.com works in 0.11.27 and fails in 0.12.1. A test of www.figma.com shows that both versions of reqwest are fine.
Results on 0.11.27:
Results on 0.12.1:
main.toml:
main.rs:
The text was updated successfully, but these errors were encountered: