mirror of https://github.com/rust-lang/cargo
crates-io: Set `Content-Type: application/json` only for requests with a body payload
This commit is contained in:
parent
88599985e9
commit
2d1728088f
|
@ -389,7 +389,9 @@ impl Registry {
|
|||
self.handle.url(&format!("{}/api/v1{}", self.host, path))?;
|
||||
let mut headers = List::new();
|
||||
headers.append("Accept: application/json")?;
|
||||
headers.append("Content-Type: application/json")?;
|
||||
if body.is_some() {
|
||||
headers.append("Content-Type: application/json")?;
|
||||
}
|
||||
|
||||
if self.auth_required || authorized == Auth::Authorized {
|
||||
headers.append(&format!("Authorization: {}", self.token()?))?;
|
||||
|
|
|
@ -40,7 +40,7 @@ be required in the future.
|
|||
|
||||
Cargo sets the following headers for all requests:
|
||||
|
||||
- `Content-Type`: `application/json`
|
||||
- `Content-Type`: `application/json` (for requests with a body payload)
|
||||
- `Accept`: `application/json`
|
||||
- `User-Agent`: The Cargo version such as `cargo 1.32.0 (8610973aa
|
||||
2019-01-02)`. This may be modified by the user in a configuration value.
|
||||
|
|
Loading…
Reference in New Issue