Forráskód Böngészése

Ignore http.ErrBodyNotAllowed error during streaming

DarthSim 2 hónapja
szülő
commit
4d19d89ac0
2 módosított fájl, 6 hozzáadás és 0 törlés
  1. 1 0
      CHANGELOG.md
  2. 5 0
      stream.go

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@
 ## [Unreleased]
 ### Fixed
 - Fix the `Vary` header value when `IMGPROXY_AUTO_JXL` or `IMGPROXY_ENFORCE_JXL` configs are set to `true`.
+- Fix connection break when the `raw` processing option is used and the response status code does not allow a response body (such as `304 Not Modified`).
 - Fix the `If-Modified-Since` request header handling when the `raw` processing option is used.
 - (pro) Fix generating thumbnails for VP9 videos with high bit depth.
 - (pro) Fix `IMGPROXY_CUSTOM_RESPONSE_HEADERS` and `IMGPROXY_RESPONSE_HEADERS_PASSTHROUGH` configs behavior when the `raw` processing option is used.

+ 5 - 0
stream.go

@@ -127,6 +127,11 @@ func streamOriginImage(ctx context.Context, reqID string, r *http.Request, rw ht
 	defer streamBufPool.Put(buf)
 
 	_, copyerr := io.CopyBuffer(rw, res.Body, *buf)
+	if copyerr == http.ErrBodyNotAllowed {
+		// We can hit this for some statuses like 304 Not Modified.
+		// We can ignore this error.
+		copyerr = nil
+	}
 
 	router.LogResponse(
 		reqID, r, res.StatusCode, nil,