From 3421a538c81a9ea1ff03c06d2486acc35db107d9 Mon Sep 17 00:00:00 2001 From: Michael Gattozzi Date: Tue, 15 Nov 2022 13:11:54 -0500 Subject: [PATCH] Fix write body test --- cli/tests/integration/async_io.rs | 26 +++++++++++++------------- lib/src/session.rs | 8 +++++--- test-fixtures/src/bin/async_io.rs | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cli/tests/integration/async_io.rs b/cli/tests/integration/async_io.rs index 745ae855..a10f6c70 100644 --- a/cli/tests/integration/async_io.rs +++ b/cli/tests/integration/async_io.rs @@ -115,7 +115,7 @@ async fn async_io_methods() -> TestResult { .unwrap() } 3 => { - let _body = req.into_body(); + let _body = hyper::body::to_bytes(req.into_body()).await; Response::builder() .status(StatusCode::OK) .body(Body::empty()) @@ -196,28 +196,28 @@ async fn async_io_methods() -> TestResult { let _task = tokio::task::spawn(async move { temp_barrier.wait().await }); barrier.wait().await; - // let resp = test - // .against( - // Request::builder() - // .header("Host", "example.org") - // .header("Empty-Select-Timeout", "0") - // .body(vec![]) - // .unwrap(), - // ) - // .await; - // assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR); + let resp = test + .against( + Request::builder() + .header("Host", "example.org") + .header("Empty-Select-Timeout", "0") + .body(Body::empty()) + .unwrap(), + ) + .await; + assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR); // let resp = test // .against( // Request::builder() // .header("Host", "example.org") // .header("Empty-Select-Timeout", "0") - // .body(vec![]) + // .body(Body::empty()) // .unwrap(), // ) // .await; // assert_eq!(resp.status(), StatusCode::OK); // assert_eq!(resp.headers()["Ready-Index"], "timeout"); - + // Ok(()) } diff --git a/lib/src/session.rs b/lib/src/session.rs index c1126646..85ea6ced 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -687,11 +687,13 @@ impl Session { pub fn reinsert_pending_request( &mut self, handle: PendingRequestHandle, - pending_req: PendingRequest + pending_req: PendingRequest, ) -> Result<(), HandleError> { - *self.async_items + *self + .async_items .get_mut(handle.into()) - .ok_or(HandleError::InvalidPendingRequestHandle(handle))? = Some(AsyncItem::PendingReq(pending_req)); + .ok_or(HandleError::InvalidPendingRequestHandle(handle))? = + Some(AsyncItem::PendingReq(pending_req)); Ok(()) } diff --git a/test-fixtures/src/bin/async_io.rs b/test-fixtures/src/bin/async_io.rs index f8a25602..4e773e13 100644 --- a/test-fixtures/src/bin/async_io.rs +++ b/test-fixtures/src/bin/async_io.rs @@ -93,7 +93,7 @@ fn test_select() -> Result<(), Error> { append_header(&mut ds_resp, "Write-Ready", is_ready(write_body_handle)); let handles = vec![ - s128imple_pending_req_handle, + simple_pending_req_handle, read_body_handle, write_body_handle, ];