Skip to content

Commit

Permalink
Only wrap in encode if not already wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed Aug 2, 2023
1 parent 3dbb125 commit fb8c245
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/caddyhttp/encode/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ func (enc *Encode) openResponseWriter(encodingName string, w http.ResponseWriter
// initResponseWriter initializes the responseWriter instance
// allocated in openResponseWriter, enabling mid-stack inlining.
func (enc *Encode) initResponseWriter(rw *responseWriter, encodingName string, wrappedRW http.ResponseWriter) *responseWriter {
rw.ResponseWriter = &caddyhttp.ResponseWriterWrapper{ResponseWriter: wrappedRW}
if rww, ok := wrappedRW.(*caddyhttp.ResponseWriterWrapper); ok {
rw.ResponseWriter = rww
} else {
rw.ResponseWriter = &caddyhttp.ResponseWriterWrapper{ResponseWriter: wrappedRW}
}
rw.encodingName = encodingName
rw.config = enc

Expand Down

0 comments on commit fb8c245

Please sign in to comment.