Skip to content

Commit

Permalink
Auto merge of #13548 - Turbo87:user-agent, r=weihanglo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Mar 9, 2024
2 parents 29cf016 + c1f5fa6 commit d79fdf3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cargo/util/network/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SslVersion> {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/registry-web-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit d79fdf3

Please sign in to comment.