From ca3fb11f8b0fddaeb817ab0e7fa0b52f0f0af50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Mon, 4 Jun 2018 08:15:04 +0200 Subject: [PATCH] add actix-web version in header --- src/client/request.rs | 5 ++++- tests/test_client.rs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/client/request.rs b/src/client/request.rs index d3f6ebdb..bb338482 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -615,7 +615,10 @@ impl ClientRequestBuilder { true }; if !contains { - self.header(header::USER_AGENT, "Actix-web"); + self.header( + header::USER_AGENT, + concat!("Actix-web/", env!("CARGO_PKG_VERSION")), + ); } } diff --git a/tests/test_client.rs b/tests/test_client.rs index cd47583c..3128bb94 100644 --- a/tests/test_client.rs +++ b/tests/test_client.rs @@ -440,7 +440,11 @@ fn test_default_headers() { let request = srv.get().finish().unwrap(); let repr = format!("{:?}", request); 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() .header("User-Agent", "test") @@ -448,5 +452,9 @@ fn test_default_headers() { .unwrap(); let repr_override = format!("{:?}", request_override); 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"), + "\"" + ))); }