You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Raises an error: TypeError: Request with GET/HEAD method cannot have body.
Most of clients in other languages do this as well.
It makes sense if following Rust code was also producing an error:
use url::Url;#[tokio::main]asyncfnmain(){let url = Url::parse("https://jsonplaceholder.typicode.com/posts/1").unwrap();let client = reqwest::Client::new();let res = client.get(url).json(&serde_json::json!({"a":1})).send().await.unwrap().text().await.unwrap();println!("{}", res);}
The specification is pretty much against allowing such code to be executed:
9.3.1. GET A client SHOULD NOT generate content in a GET request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported. An origin server SHOULD NOT rely on private agreements to receive content, since participants in HTTP communication are often unaware of intermediaries along the request chain.
While it might be valuable to keep a backdoor for extremely rare cases where server violates HTTP semantic and requires such requests, I think it is worth making this an error by-default.
I can work on an implementation if overall idea is supported by crate maintainers.
The text was updated successfully, but these errors were encountered:
Most of existing HTTP client implementation have safeguards against incorrect usage of HTTP verbs. For example, following JS code:
Raises an error:
TypeError: Request with GET/HEAD method cannot have body.
Most of clients in other languages do this as well.
It makes sense if following Rust code was also producing an error:
The specification is pretty much against allowing such code to be executed:
While it might be valuable to keep a backdoor for extremely rare cases where server violates HTTP semantic and requires such requests, I think it is worth making this an error by-default.
I can work on an implementation if overall idea is supported by crate maintainers.
The text was updated successfully, but these errors were encountered: