Quellcode durchsuchen

Merge branch 'master' into version/4

DarthSim vor 2 Monaten
Ursprung
Commit
52ecfeaf8b
2 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 2 0
      CHANGELOG.md
  2. 6 0
      stream.go

+ 2 - 0
CHANGELOG.md

@@ -3,6 +3,8 @@
 ## [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.
 

+ 6 - 0
stream.go

@@ -24,6 +24,7 @@ import (
 var (
 	streamReqHeaders = []string{
 		"If-None-Match",
+		"If-Modified-Since",
 		"Accept-Encoding",
 		"Range",
 	}
@@ -123,6 +124,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,