diff --git a/src/application.rs b/src/application.rs index 3dd1b1fe8..b714067e2 100644 --- a/src/application.rs +++ b/src/application.rs @@ -310,7 +310,6 @@ mod tests { use http::{Method, Version, Uri, HeaderMap, StatusCode}; use super::*; use httprequest::HttpRequest; - use payload::Payload; use httpcodes; #[test] @@ -321,13 +320,13 @@ mod tests { let req = HttpRequest::new( Method::GET, Uri::from_str("/test").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let resp = app.run(req); assert_eq!(resp.as_response().unwrap().status(), StatusCode::OK); let req = HttpRequest::new( Method::GET, Uri::from_str("/blah").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let resp = app.run(req); assert_eq!(resp.as_response().unwrap().status(), StatusCode::NOT_FOUND); @@ -336,7 +335,7 @@ mod tests { .finish(); let req = HttpRequest::new( Method::GET, Uri::from_str("/blah").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let resp = app.run(req); assert_eq!(resp.as_response().unwrap().status(), StatusCode::METHOD_NOT_ALLOWED); } diff --git a/src/h1.rs b/src/h1.rs index 10b5cff2d..8b929177e 100644 --- a/src/h1.rs +++ b/src/h1.rs @@ -998,7 +998,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_11); assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1021,7 +1021,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_11); assert_eq!(*req.method(), Method::PUT); assert_eq!(req.path(), "/test"); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1038,7 +1038,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_10); assert_eq!(*req.method(), Method::POST); assert_eq!(req.path(), "/test2"); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1055,7 +1055,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_11); assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body"); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"body"); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1073,7 +1073,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_11); assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body"); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"body"); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1093,7 +1093,7 @@ mod tests { assert_eq!(req.version(), Version::HTTP_11); assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1120,7 +1120,7 @@ mod tests { assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); assert_eq!(req.headers().get("test").unwrap().as_bytes(), b"value"); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); } Ok(_) | Err(_) => panic!("Error during parsing http request"), } @@ -1229,7 +1229,7 @@ mod tests { connection: upgrade\r\n\r\n"); let req = parse_ready!(&mut buf); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); assert!(req.upgrade()); } @@ -1241,7 +1241,7 @@ mod tests { let req = parse_ready!(&mut buf); assert!(req.upgrade()); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); } #[test] @@ -1251,7 +1251,7 @@ mod tests { transfer-encoding: chunked\r\n\r\n"); let req = parse_ready!(&mut buf); - assert!(!req.payload().eof()); + assert!(req.payload().is_some()); if let Ok(val) = req.chunked() { assert!(val); } else { @@ -1263,7 +1263,7 @@ mod tests { transfer-encoding: chnked\r\n\r\n"); let req = parse_ready!(&mut buf); - assert!(req.payload().eof()); + assert!(req.payload().is_none()); if let Ok(val) = req.chunked() { assert!(!val); } else { @@ -1323,7 +1323,7 @@ mod tests { let mut req = parse_ready!(&mut buf); assert!(!req.keep_alive()); assert!(req.upgrade()); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"some raw data"); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"some raw data"); } #[test] @@ -1371,13 +1371,13 @@ mod tests { let mut reader = Reader::new(); let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf)); assert!(req.chunked().unwrap()); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); buf.feed_data("4\r\ndata\r\n4\r\nline\r\n0\r\n\r\n"); not_ready!(reader.parse(&mut buf, &mut readbuf)); - assert!(!req.payload().eof()); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"dataline"); - assert!(req.payload().eof()); + assert!(!req.payload().unwrap().eof()); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"dataline"); + assert!(req.payload().unwrap().eof()); } #[test] @@ -1391,7 +1391,7 @@ mod tests { let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf)); assert!(req.chunked().unwrap()); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); buf.feed_data( "4\r\ndata\r\n4\r\nline\r\n0\r\n\r\n\ @@ -1401,10 +1401,10 @@ mod tests { let req2 = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf)); assert_eq!(*req2.method(), Method::POST); assert!(req2.chunked().unwrap()); - assert!(!req2.payload().eof()); + assert!(!req2.payload().unwrap().eof()); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"dataline"); - assert!(req.payload().eof()); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"dataline"); + assert!(req.payload().unwrap().eof()); } #[test] @@ -1417,7 +1417,7 @@ mod tests { let mut reader = Reader::new(); let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf)); assert!(req.chunked().unwrap()); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); buf.feed_data("4\r\ndata\r"); not_ready!(reader.parse(&mut buf, &mut readbuf)); @@ -1439,12 +1439,12 @@ mod tests { //buf.feed_data("test: test\r\n"); //not_ready!(reader.parse(&mut buf, &mut readbuf)); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"dataline"); - assert!(!req.payload().eof()); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"dataline"); + assert!(!req.payload().unwrap().eof()); buf.feed_data("\r\n"); not_ready!(reader.parse(&mut buf, &mut readbuf)); - assert!(req.payload().eof()); + assert!(req.payload().unwrap().eof()); } #[test] @@ -1457,13 +1457,13 @@ mod tests { let mut reader = Reader::new(); let mut req = reader_parse_ready!(reader.parse(&mut buf, &mut readbuf)); assert!(req.chunked().unwrap()); - assert!(!req.payload().eof()); + assert!(!req.payload().unwrap().eof()); buf.feed_data("4;test\r\ndata\r\n4\r\nline\r\n0\r\n\r\n"); // test: test\r\n\r\n") not_ready!(reader.parse(&mut buf, &mut readbuf)); - assert!(!req.payload().eof()); - assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"dataline"); - assert!(req.payload().eof()); + assert!(!req.payload().unwrap().eof()); + assert_eq!(req.payload_mut().unwrap().readall().unwrap().as_ref(), b"dataline"); + assert!(req.payload().unwrap().eof()); } /*#[test] diff --git a/src/httprequest.rs b/src/httprequest.rs index 266a4e945..7d5fbb740 100644 --- a/src/httprequest.rs +++ b/src/httprequest.rs @@ -114,7 +114,7 @@ impl HttpRequest<()> { params: Params::default(), cookies: None, addr: None, - payload: Payload::empty(), + payload: None, extensions: Extensions::new(), info: None, }), @@ -530,7 +530,6 @@ mod tests { use http::Uri; use std::str::FromStr; use router::Pattern; - use payload::Payload; use resource::Resource; #[test] @@ -539,8 +538,7 @@ mod tests { headers.insert(header::TRANSFER_ENCODING, header::HeaderValue::from_static("chunked")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); assert_eq!(req.urlencoded().err().unwrap(), UrlencodedError::Chunked); @@ -550,8 +548,7 @@ mod tests { headers.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("xxxx")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, - headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); assert_eq!(req.urlencoded().err().unwrap(), UrlencodedError::UnknownLength); @@ -561,8 +558,7 @@ mod tests { headers.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("1000000")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); assert_eq!(req.urlencoded().err().unwrap(), UrlencodedError::Overflow); @@ -572,8 +568,7 @@ mod tests { headers.insert(header::CONTENT_LENGTH, header::HeaderValue::from_static("10")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); assert_eq!(req.urlencoded().err().unwrap(), UrlencodedError::ContentType); } @@ -584,8 +579,7 @@ mod tests { headers.insert(header::HOST, header::HeaderValue::from_static("www.rust-lang.org")); let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); let mut resource = Resource::default(); resource.name("index"); @@ -612,7 +606,7 @@ mod tests { fn test_url_for_external() { let req = HttpRequest::new( Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let mut resource = Resource::<()>::default(); resource.name("index"); diff --git a/src/middlewares/logger.rs b/src/middlewares/logger.rs index 57b12cf81..507908148 100644 --- a/src/middlewares/logger.rs +++ b/src/middlewares/logger.rs @@ -291,7 +291,6 @@ mod tests { use time; use http::{Method, Version, StatusCode, Uri}; use http::header::{self, HeaderMap}; - use payload::Payload; #[test] fn test_logger() { @@ -300,8 +299,7 @@ mod tests { let mut headers = HeaderMap::new(); headers.insert(header::USER_AGENT, header::HeaderValue::from_static("ACTIX-WEB")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); let resp = HttpResponse::build(StatusCode::OK) .header("X-Test", "ttt") .force_close().body(Body::Empty).unwrap(); @@ -332,8 +330,7 @@ mod tests { let mut headers = HeaderMap::new(); headers.insert(header::USER_AGENT, header::HeaderValue::from_static("ACTIX-WEB")); let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); let resp = HttpResponse::build(StatusCode::OK) .force_close().body(Body::Empty).unwrap(); let entry_time = time::now(); @@ -351,7 +348,7 @@ mod tests { let req = HttpRequest::new( Method::GET, Uri::from_str("/?test").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let resp = HttpResponse::build(StatusCode::OK) .force_close().body(Body::Empty).unwrap(); let entry_time = time::now(); diff --git a/src/pred.rs b/src/pred.rs index c907d2793..82283899f 100644 --- a/src/pred.rs +++ b/src/pred.rs @@ -153,7 +153,6 @@ mod tests { use std::str::FromStr; use http::{Uri, Version, Method}; use http::header::{self, HeaderMap}; - use payload::Payload; #[test] fn test_header() { @@ -161,8 +160,7 @@ mod tests { headers.insert(header::TRANSFER_ENCODING, header::HeaderValue::from_static("chunked")); let mut req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); let pred = Header("transfer-encoding", "chunked"); assert!(pred.check(&mut req)); @@ -178,10 +176,10 @@ mod tests { fn test_methods() { let mut req = HttpRequest::new( Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let mut req2 = HttpRequest::new( Method::POST, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Get().check(&mut req)); assert!(!Get().check(&mut req2)); @@ -190,43 +188,43 @@ mod tests { let mut r = HttpRequest::new( Method::PUT, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Put().check(&mut r)); assert!(!Put().check(&mut req)); let mut r = HttpRequest::new( Method::DELETE, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Delete().check(&mut r)); assert!(!Delete().check(&mut req)); let mut r = HttpRequest::new( Method::HEAD, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Head().check(&mut r)); assert!(!Head().check(&mut req)); let mut r = HttpRequest::new( Method::OPTIONS, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Options().check(&mut r)); assert!(!Options().check(&mut req)); let mut r = HttpRequest::new( Method::CONNECT, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Connect().check(&mut r)); assert!(!Connect().check(&mut req)); let mut r = HttpRequest::new( Method::PATCH, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Patch().check(&mut r)); assert!(!Patch().check(&mut req)); let mut r = HttpRequest::new( Method::TRACE, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Trace().check(&mut r)); assert!(!Trace().check(&mut req)); } @@ -235,7 +233,7 @@ mod tests { fn test_preds() { let mut r = HttpRequest::new( Method::TRACE, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(Not(Get()).check(&mut r)); assert!(!Not(Trace()).check(&mut r)); diff --git a/src/router.rs b/src/router.rs index b6e1313dc..b5cdd8330 100644 --- a/src/router.rs +++ b/src/router.rs @@ -305,7 +305,6 @@ mod tests { use http::{Uri, Version, Method}; use http::header::HeaderMap; use std::str::FromStr; - use payload::Payload; #[test] fn test_recognizer() { @@ -320,39 +319,39 @@ mod tests { let mut req = HttpRequest::new( Method::GET, Uri::from_str("/name").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert!(req.match_info().is_empty()); let mut req = HttpRequest::new( Method::GET, Uri::from_str("/name/value").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert_eq!(req.match_info().get("val").unwrap(), "value"); assert_eq!(&req.match_info()["val"], "value"); let mut req = HttpRequest::new( Method::GET, Uri::from_str("/name/value2/index.html").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert_eq!(req.match_info().get("val").unwrap(), "value2"); let mut req = HttpRequest::new( Method::GET, Uri::from_str("/vtest/ttt/index.html").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert_eq!(req.match_info().get("val").unwrap(), "test"); assert_eq!(req.match_info().get("val2").unwrap(), "ttt"); let mut req = HttpRequest::new( Method::GET, Uri::from_str("/v/blah-blah/index.html").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert_eq!(req.match_info().get("tail").unwrap(), "blah-blah/index.html"); let mut req = HttpRequest::new( Method::GET, Uri::from_str("/bbb/index.html").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert!(rec.recognize(&mut req).is_some()); assert_eq!(req.match_info().get("test").unwrap(), "bbb"); } diff --git a/src/ws.rs b/src/ws.rs index cd23526fc..65ddb5afe 100644 --- a/src/ws.rs +++ b/src/ws.rs @@ -339,31 +339,30 @@ impl WsWriter { mod tests { use super::*; use std::str::FromStr; - use payload::Payload; use http::{Method, HeaderMap, Version, Uri, header}; #[test] fn test_handshake() { let req = HttpRequest::new(Method::POST, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert_eq!(WsHandshakeError::GetMethodRequired, handshake(&req).err().unwrap()); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert_eq!(WsHandshakeError::NoWebsocketUpgrade, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); headers.insert(header::UPGRADE, header::HeaderValue::from_static("test")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(WsHandshakeError::NoWebsocketUpgrade, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); headers.insert(header::UPGRADE, header::HeaderValue::from_static("websocket")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(WsHandshakeError::NoConnectionUpgrade, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); @@ -372,7 +371,7 @@ mod tests { headers.insert(header::CONNECTION, header::HeaderValue::from_static("upgrade")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(WsHandshakeError::NoVersionHeader, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); @@ -383,7 +382,7 @@ mod tests { headers.insert(SEC_WEBSOCKET_VERSION, header::HeaderValue::from_static("5")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(WsHandshakeError::UnsupportedVersion, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); @@ -394,7 +393,7 @@ mod tests { headers.insert(SEC_WEBSOCKET_VERSION, header::HeaderValue::from_static("13")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(WsHandshakeError::BadWebsocketKey, handshake(&req).err().unwrap()); let mut headers = HeaderMap::new(); @@ -407,7 +406,7 @@ mod tests { headers.insert(SEC_WEBSOCKET_KEY, header::HeaderValue::from_static("13")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert_eq!(StatusCode::SWITCHING_PROTOCOLS, handshake(&req).unwrap().status()); } } diff --git a/tests/test_httprequest.rs b/tests/test_httprequest.rs index b6fecce57..aaaaf2764 100644 --- a/tests/test_httprequest.rs +++ b/tests/test_httprequest.rs @@ -13,16 +13,14 @@ use http::{header, Method, Version, HeaderMap, Uri}; #[test] fn test_debug() { let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, - HeaderMap::new(), Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, HeaderMap::new(), None); let _ = format!("{:?}", req); } #[test] fn test_no_request_cookies() { let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, HeaderMap::new(), None); assert!(req.cookies().unwrap().is_empty()); } @@ -33,8 +31,7 @@ fn test_request_cookies() { header::HeaderValue::from_static("cookie1=value1; cookie2=value2")); let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); { let cookies = req.cookies().unwrap(); assert_eq!(cookies.len(), 2); @@ -57,7 +54,7 @@ fn test_request_cookies() { #[test] fn test_no_request_range_header() { let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let ranges = req.range(100).unwrap(); assert!(ranges.is_empty()); } @@ -69,7 +66,7 @@ fn test_request_range_header() { header::HeaderValue::from_static("bytes=0-4")); let req = HttpRequest::new(Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); let ranges = req.range(100).unwrap(); assert_eq!(ranges.len(), 1); assert_eq!(ranges[0].start, 0); @@ -79,7 +76,7 @@ fn test_request_range_header() { #[test] fn test_request_query() { let req = HttpRequest::new(Method::GET, Uri::from_str("/?id=test").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); assert_eq!(req.query_string(), "id=test"); let query = req.query(); assert_eq!(&query["id"], "test"); @@ -88,7 +85,7 @@ fn test_request_query() { #[test] fn test_request_match_info() { let mut req = HttpRequest::new(Method::GET, Uri::from_str("/value/?id=test").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Version::HTTP_11, HeaderMap::new(), None); let mut resource = Resource::default(); resource.name("index"); @@ -103,16 +100,14 @@ fn test_request_match_info() { #[test] fn test_chunked() { let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, HeaderMap::new(), Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, HeaderMap::new(), None); assert!(!req.chunked().unwrap()); let mut headers = HeaderMap::new(); headers.insert(header::TRANSFER_ENCODING, header::HeaderValue::from_static("chunked")); let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, - headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); assert!(req.chunked().unwrap()); let mut headers = HeaderMap::new(); @@ -122,6 +117,6 @@ fn test_chunked() { header::HeaderValue::from_str(s).unwrap()); let req = HttpRequest::new( Method::GET, Uri::from_str("/").unwrap(), - Version::HTTP_11, headers, Payload::empty()); + Version::HTTP_11, headers, None); assert!(req.chunked().is_err()); } diff --git a/tests/test_httpresponse.rs b/tests/test_httpresponse.rs index 53b1149b9..922e07a95 100644 --- a/tests/test_httpresponse.rs +++ b/tests/test_httpresponse.rs @@ -15,7 +15,7 @@ fn test_response_cookies() { header::HeaderValue::from_static("cookie1=value1; cookie2=value2")); let req = HttpRequest::new( - Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, Payload::empty()); + Method::GET, Uri::from_str("/").unwrap(), Version::HTTP_11, headers, None); let cookies = req.cookies().unwrap(); let resp = httpcodes::HTTPOk