mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-10-12 04:54:45 +00:00
fix(openai): case-insensitive content-type gate
Content-Type header values are case-insensitive per RFC 7231, but chatCompletion's streaming-vs-JSON-fallback gate used a plain strings.Contains against "text/event-stream", so an upstream that sent "Text/Event-Stream" or similar would silently fall through to the non-streaming passthrough path. Carried item (a) from Task 9's brief.
This commit is contained in:
+1
-1
@@ -121,7 +121,7 @@ func (a *openaiAdapter) chatCompletion(ctx context.Context, w http.ResponseWrite
|
||||
return usage{}, newProviderHTTPError(resp)
|
||||
}
|
||||
|
||||
if streaming && strings.Contains(resp.Header.Get("Content-Type"), "text/event-stream") {
|
||||
if streaming && strings.Contains(strings.ToLower(resp.Header.Get("Content-Type")), "text/event-stream") {
|
||||
return a.forwardStream(w, resp.Body, clientAskedUsage)
|
||||
}
|
||||
// Either a non-streaming request, or a streaming one whose upstream
|
||||
|
||||
Reference in New Issue
Block a user