Skip to content

Commit

Permalink
Fix another issue with Content-Type detection.
Browse files Browse the repository at this point in the history
If the response from upstream had Content-Encoding: gzip, but no
Content-Type, the Content-Type was being sniffed as application/x-gzip.
Decompress the content to fix the issue.
  • Loading branch information
andybalholm committed Jun 20, 2019
1 parent 2478ed9 commit 8299e5d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ func (h proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

removeHopByHopHeaders(resp.Header)

// Yet another workaround for https://github.com/golang/go/issues/31753
if resp.Header.Get("Content-Type") == "" && resp.Header.Get("Content-Encoding") == "gzip" && r.Method != "HEAD" {
gzr, err := gzip.NewReader(resp.Body)
if err != nil {
log.Printf("Error creating gzip reader for %v: %v", r.URL, err)
} else {
resp.Body = gzr
resp.Header.Del("Content-Encoding")
}
}

respACLs := conf.ACLs.responseACLs(resp)
acls := unionACLSets(reqACLs, respACLs)

Expand Down

0 comments on commit 8299e5d

Please sign in to comment.