1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 08:22:59 +01:00

add actix-web version in header

This commit is contained in:
François Mockers 2018-06-04 08:15:04 +02:00
parent 86be54df71
commit ca3fb11f8b
2 changed files with 14 additions and 3 deletions

View File

@ -615,7 +615,10 @@ impl ClientRequestBuilder {
true true
}; };
if !contains { if !contains {
self.header(header::USER_AGENT, "Actix-web"); self.header(
header::USER_AGENT,
concat!("Actix-web/", env!("CARGO_PKG_VERSION")),
);
} }
} }

View File

@ -440,7 +440,11 @@ fn test_default_headers() {
let request = srv.get().finish().unwrap(); let request = srv.get().finish().unwrap();
let repr = format!("{:?}", request); let repr = format!("{:?}", request);
assert!(repr.contains("\"accept-encoding\": \"gzip, deflate\"")); assert!(repr.contains("\"accept-encoding\": \"gzip, deflate\""));
assert!(repr.contains("\"user-agent\": \"Actix-web\"")); assert!(repr.contains(concat!(
"\"user-agent\": \"Actix-web/",
env!("CARGO_PKG_VERSION"),
"\""
)));
let request_override = srv.get() let request_override = srv.get()
.header("User-Agent", "test") .header("User-Agent", "test")
@ -448,5 +452,9 @@ fn test_default_headers() {
.unwrap(); .unwrap();
let repr_override = format!("{:?}", request_override); let repr_override = format!("{:?}", request_override);
assert!(repr_override.contains("\"user-agent\": \"test\"")); assert!(repr_override.contains("\"user-agent\": \"test\""));
assert!(!repr_override.contains("\"user-agent\": \"Actix-web\"")); assert!(!repr_override.contains(concat!(
"\"user-agent\": \"Actix-web/",
env!("CARGO_PKG_VERSION"),
"\""
)));
} }