Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions relay/adaptor/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ func DoRequestHelper(a Adaptor, c *gin.Context, meta *meta.Meta, requestBody io.
if err != nil {
return nil, fmt.Errorf("new request failed: %w", err)
}
// When the request body is passed through from the original request (e.g., OpenAI pass-through),
// Go cannot determine the content length and sets it to -1, which causes chunked transfer encoding.
// Some upstream APIs (e.g., Azure grok models) require an explicit Content-Length header.
// Inherit the content length from the original request as a fallback.
if req.ContentLength == -1 {
req.ContentLength = c.Request.ContentLength
}
err = a.SetupRequestHeader(c, req, meta)
if err != nil {
return nil, fmt.Errorf("setup request header failed: %w", err)
Expand Down