From 5cb212f7b7dc0584e4412ad56f04a7de382a7161 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sun, 13 Sep 2020 05:13:54 -0700 Subject: [PATCH] Put the crate version in the User-Agent header. (#138) * Put the crate version in the User-Agent header. https://tools.ietf.org/html/rfc7231#section-5.5.3 Each product identifier consists of a name and optional version. product = token ["/" product-version] product-version = token * User-Agent of rust-ureq * Update src/unit.rs Co-authored-by: Martin Algesten --- src/unit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unit.rs b/src/unit.rs index 37530e8..a22ddd9 100644 --- a/src/unit.rs +++ b/src/unit.rs @@ -369,7 +369,7 @@ fn send_prelude(unit: &Unit, stream: &mut Stream, redir: bool) -> IoResult<()> { } } if !header::has_header(&unit.headers, "user-agent") { - write!(prelude, "User-Agent: ureq\r\n")?; + write!(prelude, "User-Agent: ureq/{}\r\n", env!("CARGO_PKG_VERSION"))?; } if !header::has_header(&unit.headers, "accept") { write!(prelude, "Accept: */*\r\n")?;