From 7eca372d92ce873b45a4be9d9e3911fa9eb98ca2 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 6 Mar 2024 13:38:07 +0100 Subject: [PATCH 1/2] util/network/http: Use `cargo/1.2.3` user-agent header ... instead of `cargo 1.2.3`. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent#syntax declares that the product and product version are usually separated by a slash. This commit changes the cargo `User-Agent` header to follow that syntax instead of using whitespace for the separator. --- src/cargo/util/network/http.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/util/network/http.rs b/src/cargo/util/network/http.rs index 137c67c7822..cf1841c3249 100644 --- a/src/cargo/util/network/http.rs +++ b/src/cargo/util/network/http.rs @@ -74,7 +74,7 @@ pub fn configure_http_handle(gctx: &GlobalContext, handle: &mut Easy) -> CargoRe if let Some(user_agent) = &http.user_agent { handle.useragent(user_agent)?; } else { - handle.useragent(&format!("cargo {}", version()))?; + handle.useragent(&format!("cargo/{}", version()))?; } fn to_ssl_version(s: &str) -> CargoResult { From c1f5fa6cbcb4a07e9ac620c29836ff22b918f6b6 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 6 Mar 2024 16:38:19 +0100 Subject: [PATCH 2/2] doc/registry-web-api: Adjust user-agent header --- src/doc/src/reference/registry-web-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/src/reference/registry-web-api.md b/src/doc/src/reference/registry-web-api.md index ce32401d24b..e8481b3a4b1 100644 --- a/src/doc/src/reference/registry-web-api.md +++ b/src/doc/src/reference/registry-web-api.md @@ -42,7 +42,7 @@ Cargo sets the following headers for all requests: - `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 +- `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. Added in 1.29.