diff --git a/actix-http/src/request.rs b/actix-http/src/request.rs index 5ba07929a..e9252a829 100644 --- a/actix-http/src/request.rs +++ b/actix-http/src/request.rs @@ -178,3 +178,28 @@ impl
fmt::Debug for Request
{
Ok(())
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use http::HttpTryFrom;
+
+ #[test]
+ fn test_basics() {
+ let msg = Message::new();
+ let mut req = Request::from(msg);
+ req.headers_mut().insert(
+ header::CONTENT_TYPE,
+ header::HeaderValue::from_static("text/plain"),
+ );
+ assert!(req.headers().contains_key(header::CONTENT_TYPE));
+
+ *req.uri_mut() = Uri::try_from("/index.html?q=1").unwrap();
+ assert_eq!(req.uri().path(), "/index.html");
+ assert_eq!(req.uri().query(), Some("q=1"));
+
+ let s = format!("{:?}", req);
+ println!("T: {:?}", s);
+ assert!(s.contains("Request HTTP/1.1 GET:/index.html"));
+ }
+}
diff --git a/tests/test_server.rs b/tests/test_server.rs
index 718aa7d4f..33c18b001 100644
--- a/tests/test_server.rs
+++ b/tests/test_server.rs
@@ -17,7 +17,7 @@ use futures::stream::once;
use rand::{distributions::Alphanumeric, Rng};
use actix_web::middleware::{BodyEncoding, Compress};
-use actix_web::{http, test, web, App, HttpResponse, HttpServer};
+use actix_web::{dev, http, test, web, App, HttpResponse, HttpServer};
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
Hello World Hello World Hello World Hello World Hello World \
@@ -89,6 +89,39 @@ fn test_body_gzip() {
assert_eq!(Bytes::from(dec), Bytes::from_static(STR.as_ref()));
}
+#[cfg(any(feature = "flate2-zlib", feature = "flate2-rust"))]
+#[test]
+fn test_body_gzip2() {
+ let mut srv = TestServer::new(|| {
+ h1::H1Service::new(
+ App::new()
+ .wrap(Compress::new(ContentEncoding::Gzip))
+ .service(web::resource("/").route(web::to(|| {
+ Response::Ok().body(STR).into_body::