소스 검색

Don't gzip server-sent events

Fixes https://github.com/gin-contrib/gzip/issues/16
Jorrit Salverda 7 년 전
부모
커밋
e6e6bbc9cd
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      gzip.go

+ 2 - 1
gzip.go

@@ -69,7 +69,8 @@ func (g *gzipWriter) WriteHeader(code int) {
 
 
 func shouldCompress(req *http.Request) bool {
 func shouldCompress(req *http.Request) bool {
 	if !strings.Contains(req.Header.Get("Accept-Encoding"), "gzip") ||
 	if !strings.Contains(req.Header.Get("Accept-Encoding"), "gzip") ||
-		strings.Contains(req.Header.Get("Connection"), "Upgrade") {
+		strings.Contains(req.Header.Get("Connection"), "Upgrade") ||
+	        strings.Contains(req.Header.Get("Content-Type"), "text/event-stream") {
 
 
 		return false
 		return false
 	}
 	}