mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
support client request's async body
This commit is contained in:
@ -545,6 +545,30 @@ fn test_h2() {
|
||||
// assert_eq!(_res.unwrap(), Bytes::from_static(STR.as_ref()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_client_streaming_explicit() {
|
||||
let mut srv = test::TestServer::new(
|
||||
|app| app.handler(
|
||||
|req: HttpRequest| req.body()
|
||||
.map_err(Error::from)
|
||||
.and_then(|body| {
|
||||
Ok(httpcodes::HTTPOk.build()
|
||||
.chunked()
|
||||
.content_encoding(headers::ContentEncoding::Identity)
|
||||
.body(body)?)})
|
||||
.responder()));
|
||||
|
||||
let body = once(Ok(Bytes::from_static(STR.as_ref())));
|
||||
|
||||
let request = srv.get().body(Body::Streaming(Box::new(body))).unwrap();
|
||||
let response = srv.execute(request.send()).unwrap();
|
||||
assert!(response.status().is_success());
|
||||
|
||||
// read response
|
||||
let bytes = srv.execute(response.body()).unwrap();
|
||||
assert_eq!(bytes, Bytes::from_static(STR.as_ref()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_application() {
|
||||
let mut srv = test::TestServer::with_factory(
|
||||
|
@ -49,5 +49,5 @@ fn test_simple() {
|
||||
|
||||
writer.close(ws::CloseCode::Normal, "");
|
||||
let (item, _) = srv.execute(reader.into_future()).unwrap();
|
||||
assert!(item.is_none())
|
||||
assert!(item.is_none());
|
||||
}
|
||||
|
Reference in New Issue
Block a user