set request.ContentLength

This informs the HTTP client the content length is known and disables
chunked Transfer-Encoding
This commit is contained in:
Michael Yang 2023-09-14 10:05:29 -07:00
parent 3ee85f1c6c
commit daa4f096f9

View file

@ -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 {