diff --git a/crates/lune-std-net/src/server/service.rs b/crates/lune-std-net/src/server/service.rs index 37e3820..4b1e9d2 100644 --- a/crates/lune-std-net/src/server/service.rs +++ b/crates/lune-std-net/src/server/service.rs @@ -99,7 +99,7 @@ async fn handle_request( let config = ResponseConfig::from_lua_multi(thread_res, &lua)?; let response = Response::try_from(config)?; - Ok(response.as_full()) + Ok(response.into_full()) } async fn handle_websocket( diff --git a/crates/lune-std-net/src/shared/request.rs b/crates/lune-std-net/src/shared/request.rs index 35a2048..5bdbd75 100644 --- a/crates/lune-std-net/src/shared/request.rs +++ b/crates/lune-std-net/src/shared/request.rs @@ -105,9 +105,10 @@ impl Request { } /** - Returns the inner `hyper` request with its body + Clones the inner `hyper` request with its body type modified to `Full` for sending. */ + #[allow(dead_code)] pub fn as_full(&self) -> HyperRequest> { let mut builder = HyperRequest::builder() .version(self.inner.version()) @@ -122,6 +123,16 @@ impl Request { let body = Full::new(self.inner.body().clone()); builder.body(body).expect("request was valid") } + + /** + Takes the inner `hyper` request with its body + type modified to `Full` for sending. + */ + #[allow(dead_code)] + pub fn into_full(self) -> HyperRequest> { + let (parts, body) = self.inner.into_parts(); + HyperRequest::from_parts(parts, Full::new(body)) + } } impl TryFrom for Request { diff --git a/crates/lune-std-net/src/shared/response.rs b/crates/lune-std-net/src/shared/response.rs index 9db245e..9c576e2 100644 --- a/crates/lune-std-net/src/shared/response.rs +++ b/crates/lune-std-net/src/shared/response.rs @@ -75,9 +75,10 @@ impl Response { } /** - Returns the inner `hyper` response with its body + Clones the inner `hyper` response with its body type modified to `Full` for sending. */ + #[allow(dead_code)] pub fn as_full(&self) -> HyperResponse> { let mut builder = HyperResponse::builder() .version(self.inner.version()) @@ -91,6 +92,16 @@ impl Response { let body = Full::new(self.inner.body().clone()); builder.body(body).expect("request was valid") } + + /** + Takes the inner `hyper` response with its body + type modified to `Full` for sending. + */ + #[allow(dead_code)] + pub fn into_full(self) -> HyperResponse> { + let (parts, body) = self.inner.into_parts(); + HyperResponse::from_parts(parts, Full::new(body)) + } } impl TryFrom for Response {