diff --git a/model_gateway/src/routers/http/pd_router.rs b/model_gateway/src/routers/http/pd_router.rs index 22bce3081..7d32d74f6 100644 --- a/model_gateway/src/routers/http/pd_router.rs +++ b/model_gateway/src/routers/http/pd_router.rs @@ -1302,7 +1302,7 @@ impl PDRouter { client .post(endpoint_url) .header(CONTENT_TYPE, HeaderValue::from_static("application/json")), - bytes::Bytes::from(body), + body, ); if connection_close { request = request.header("Connection", "close"); @@ -1910,7 +1910,7 @@ mod tests { assert!(result.is_err()); // No workers at all is the pre-existing unavailable string, not a shed: // an empty pool has nothing to be overloaded. - match result.unwrap_err() { + match *result.unwrap_err() { PdSelectionFailure::Unavailable(error) => { assert!(error.contains("No prefill workers available")); } diff --git a/model_gateway/src/routers/http/router.rs b/model_gateway/src/routers/http/router.rs index 2de124058..21c3d50e7 100644 --- a/model_gateway/src/routers/http/router.rs +++ b/model_gateway/src/routers/http/router.rs @@ -1188,7 +1188,7 @@ impl Router { self.client .post(&endpoint_url) .header(CONTENT_TYPE, HeaderValue::from_static("application/json")), - bytes::Bytes::from(body), + body, ); request_builder = header_utils::apply_forwarded_request_headers( diff --git a/model_gateway/src/worker/http_client.rs b/model_gateway/src/worker/http_client.rs index ded9a2e02..d2c619f1b 100644 --- a/model_gateway/src/worker/http_client.rs +++ b/model_gateway/src/worker/http_client.rs @@ -166,7 +166,15 @@ mod tests { /// Loopback echo server; axum::serve accepts HTTP/1.1 and prior-knowledge /// h2c on the same listener, mirroring a dual-protocol engine. async fn spawn_echo_server() -> String { - let app = axum::Router::new().route("/probe", axum::routing::get(|| async { "ok" })); + let app = axum::Router::new() + .route("/probe", axum::routing::get(|| async { "ok" })) + .route( + "/hang", + axum::routing::get(|| async { + tokio::time::sleep(Duration::from_secs(3600)).await; + "late" + }), + ); let listener = tokio::net::TcpListener::bind("127.0.0.1:0") .await .expect("bind echo server"); @@ -281,14 +289,20 @@ mod tests { async fn per_request_timeout_overrides_client_default() { let url = spawn_echo_server().await; // A zero client-level total timeout fails every request that relies - // on the client default... + // on the client default. Aim it at the hanging route: a fast local + // response can otherwise win the race against a zero-duration timer. + let hang_url = url.replace("/probe", "/hang"); let client = cache(RouterConfig { request_timeout_secs: 0, ..RouterConfig::default() }) .get(&HttpPoolConfig::default()) .expect("client"); - let err = client.get(&url).send().await.expect_err("default applies"); + let err = client + .get(&hang_url) + .send() + .await + .expect_err("default applies"); assert!(err.is_timeout()); // ...while a per-request timeout replaces it entirely. let resp = client