Skip to content

Commit cc450e9

Browse files
authored
fix issue where proxy is still proxying with chunked transfer-encoding (#114)
1 parent 27465fe commit cc450e9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

proxy/process.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/http"
99
"net/url"
1010
"os/exec"
11+
"strconv"
1112
"strings"
1213
"sync"
1314
"syscall"
@@ -439,6 +440,12 @@ func (p *Process) ProxyRequest(w http.ResponseWriter, r *http.Request) {
439440
return
440441
}
441442
req.Header = r.Header.Clone()
443+
444+
contentLength, err := strconv.ParseInt(req.Header.Get("content-length"), 10, 64)
445+
if err == nil {
446+
req.ContentLength = contentLength
447+
}
448+
442449
resp, err := client.Do(req)
443450
if err != nil {
444451
http.Error(w, err.Error(), http.StatusBadGateway)

proxy/proxymanager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ func (pm *ProxyManager) proxyOAIHandler(c *gin.Context) {
371371

372372
// dechunk it as we already have all the body bytes see issue #11
373373
c.Request.Header.Del("transfer-encoding")
374+
c.Request.Header.Del("content-length")
374375
c.Request.Header.Add("content-length", strconv.Itoa(len(bodyBytes)))
375376

376377
if err := processGroup.ProxyRequest(realModelName, c.Writer, c.Request); err != nil {

0 commit comments

Comments
 (0)