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:
2026-08-20 03:36:34 +01:00
parent 543f358c7f
commit c0f31a3bc0
+1 -1
View File
@@ -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