Browse Source

Merge pull request #17 from JorritSalverda/patch-1

Don't gzip server-sent events
田欧 7 years ago
parent
commit
f462374215
1 changed files with 2 additions and 1 deletions
  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
 	}
 	}