From 2d1728088fa5214ec3b8a472cf7361840aab91f9 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 8 Jan 2024 17:29:27 +0100 Subject: [PATCH 1/2] crates-io: Set `Content-Type: application/json` only for requests with a body payload --- crates/crates-io/lib.rs | 4 +++- src/doc/src/reference/registry-web-api.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/crates-io/lib.rs b/crates/crates-io/lib.rs index 468900e55c1..5d8a8c50cc3 100644 --- a/crates/crates-io/lib.rs +++ b/crates/crates-io/lib.rs @@ -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()?))?; diff --git a/src/doc/src/reference/registry-web-api.md b/src/doc/src/reference/registry-web-api.md index d36b4f16d2c..ce32401d24b 100644 --- a/src/doc/src/reference/registry-web-api.md +++ b/src/doc/src/reference/registry-web-api.md @@ -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. From 6218d08504326ce1de28b92b7f1c36223136508b Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 9 Jan 2024 18:00:51 +0100 Subject: [PATCH 2/2] crates-io: Bump version to v0.40.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/crates-io/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e65871e4dcf..4f011a892c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -613,7 +613,7 @@ dependencies = [ [[package]] name = "crates-io" -version = "0.39.2" +version = "0.40.0" dependencies = [ "curl", "percent-encoding", diff --git a/Cargo.toml b/Cargo.toml index 2b61f279d89..fbe4cffdeec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ cargo_metadata = "0.18.1" clap = "4.4.12" color-print = "0.3.5" core-foundation = { version = "0.9.4", features = ["mac_os_10_7_support"] } -crates-io = { version = "0.39.0", path = "crates/crates-io" } +crates-io = { version = "0.40.0", path = "crates/crates-io" } criterion = { version = "0.5.1", features = ["html_reports"] } curl = "0.4.44" curl-sys = "0.4.70" diff --git a/crates/crates-io/Cargo.toml b/crates/crates-io/Cargo.toml index 458f62749d8..af487b3598e 100644 --- a/crates/crates-io/Cargo.toml +++ b/crates/crates-io/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crates-io" -version = "0.39.2" +version = "0.40.0" rust-version.workspace = true edition.workspace = true license.workspace = true