diff --git a/proxy/gzip/gzip_handler.go b/proxy/gzip/gzip_handler.go index 9cdf70d10..f59f805b6 100644 --- a/proxy/gzip/gzip_handler.go +++ b/proxy/gzip/gzip_handler.go @@ -21,6 +21,7 @@ import ( const ( headerVary = "Vary" + headerAccept = "Accept" headerAcceptEncoding = "Accept-Encoding" headerContentEncoding = "Content-Encoding" headerContentType = "Content-Type" @@ -28,6 +29,8 @@ const ( encodingGzip = "gzip" ) +var blacklistedAcceptContentTypes = []string{"text/event-stream"} + var gzipWriterPool = sync.Pool{ New: func() interface{} { return gzip.NewWriter(nil) }, } @@ -110,5 +113,11 @@ func isCompressable(header http.Header, contentTypes *regexp.Regexp) bool { } func acceptsGzip(r *http.Request) bool { + accept := r.Header.Get(headerAccept) + for _, contentType := range blacklistedAcceptContentTypes { + if strings.Contains(accept, contentType) { + return false + } + } return strings.Contains(r.Header.Get(headerAcceptEncoding), encodingGzip) }