Skip to content

Commit c9b1bc6

Browse files
committed
fix: remove content-related headers when no body is provided in OpenAIProxyService
1 parent 98f7c23 commit c9b1bc6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

crates/services/src/response/service.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ impl OpenAIProxyService for OpenAIProxy {
5454
headers.remove("authorization");
5555
headers.remove("host"); // Don't forward host header
5656

57+
// If no body is provided, remove content-related headers to avoid
58+
// the server waiting for body data that will never arrive
59+
if body.is_none() {
60+
headers.remove("content-length");
61+
headers.remove("content-type");
62+
headers.remove("transfer-encoding");
63+
}
64+
5765
tracing::debug!("Forwarding {} header(s) to OpenAI", headers.len());
5866
for (key, value) in headers.iter() {
5967
request_builder = request_builder.header(key, value);

0 commit comments

Comments
 (0)