diff options
author | metamuffin <metamuffin@disroot.org> | 2025-03-18 11:22:58 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-03-18 11:22:58 +0100 |
commit | d3c1805fadc6cd7c0926d1b22dffe0b58d25c207 (patch) | |
tree | b5df5086aa7c9716fb9bbf14b5b2aca193ea1601 | |
parent | c19e992b557c169ee0fa765c29c8ee3b4e897946 (diff) | |
download | gnix-d3c1805fadc6cd7c0926d1b22dffe0b58d25c207.tar gnix-d3c1805fadc6cd7c0926d1b22dffe0b58d25c207.tar.bz2 gnix-d3c1805fadc6cd7c0926d1b22dffe0b58d25c207.tar.zst |
fix h3 for curl client
-rw-r--r-- | src/main.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index ee33d3f..31f8db7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ use error::ServiceError; use futures::future::try_join_all; use h3::error::ErrorLevel; use h3_support::H3RequestBody; +use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING}; use http_body_util::{combinators::BoxBody, BodyExt}; use hyper::{ body::Incoming, @@ -251,21 +252,15 @@ async fn serve_h3(state: Arc<State>) -> Result<()> { let (mut send, recv) = stream.split(); let req = req.map(|()| H3RequestBody(recv).boxed()); - let resp = match service( - state.clone(), - req, - addr, - true, - listen_addr, - ) - .await - { - Ok(resp) => resp, - Err(error) => error_response(addr, error), - }; + let resp = service(state.clone(), req, addr, true, listen_addr) + .await + .unwrap_or_else(|error| error_response(addr, error)); let (parts, mut body) = resp.into_parts(); - let resp = Response::from_parts(parts, ()); + let mut resp = Response::from_parts(parts, ()); + + resp.headers_mut().remove(TRANSFER_ENCODING); // TODO allow "trailers" options + resp.headers_mut().remove(CONTENT_LENGTH); if let Err(e) = send.send_response(resp).await { debug!("h3 response send error: {e}"); |