From daa4f096f9e1e23aa2f6d09e5a13483c5cbaf232 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 14 Sep 2023 10:05:29 -0700 Subject: [PATCH] set request.ContentLength This informs the HTTP client the content length is known and disables chunked Transfer-Encoding --- server/images.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/images.go b/server/images.go index d5e53dd1..6fdde576 100644 --- a/server/images.go +++ b/server/images.go @@ -1442,6 +1442,15 @@ func makeRequest(ctx context.Context, method string, requestURL *url.URL, header req.Header.Set("User-Agent", fmt.Sprintf("ollama/%s (%s %s) Go/%s", version.Version, runtime.GOARCH, runtime.GOOS, runtime.Version())) + if s := req.Header.Get("Content-Length"); s != "" { + contentLength, err := strconv.ParseInt(s, 10, 64) + if err != nil { + return nil, err + } + + req.ContentLength = contentLength + } + client := &http.Client{ CheckRedirect: func(req *http.Request, via []*http.Request) error { if len(via) >= 10 {