Skip to content

Commit

Permalink
Issue #300: GzipResponseWriter should implement http.Hijacker
Browse files Browse the repository at this point in the history
This patch fixes an error 500 when websocket clients are setting
an Accept-Encoding: gzip header.
  • Loading branch information
magiconair committed May 26, 2017
1 parent a58ddef commit bc88128
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions proxy/gzip/gzip_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
package gzip

import (
"bufio"
"compress/gzip"
"errors"
"io"
"net"
"net/http"
"regexp"
"strings"
Expand Down Expand Up @@ -91,6 +94,13 @@ func (grw *GzipResponseWriter) Close() {
}
}

func (grw *GzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if hj, ok := grw.ResponseWriter.(http.Hijacker); ok {
return hj.Hijack()
}
return nil, nil, errors.New("not a Hijacker")
}

func isCompressable(header http.Header, contentTypes *regexp.Regexp) bool {
// don't compress if it is already encoded
if header.Get(headerContentEncoding) != "" {
Expand Down

0 comments on commit bc88128

Please sign in to comment.