diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-09-29 12:46:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-29 12:46:30 -0700 |
commit | b84736e9b6401df0c6eeab9950bef09458a6aefd (patch) | |
tree | d9175208de3236db75a33879750a57b3000ba096 /vendor/github.com/NYTimes/gziphandler/gzip_test.go | |
parent | 8b9dbb86133ff0fd6002a391268383d1593918ca (diff) | |
download | chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.gz chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.tar.bz2 chat-b84736e9b6401df0c6eeab9950bef09458a6aefd.zip |
Updating server dependancies. (#7538)
Diffstat (limited to 'vendor/github.com/NYTimes/gziphandler/gzip_test.go')
-rw-r--r-- | vendor/github.com/NYTimes/gziphandler/gzip_test.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_test.go b/vendor/github.com/NYTimes/gziphandler/gzip_test.go index d5a7eb82b..655a19373 100644 --- a/vendor/github.com/NYTimes/gziphandler/gzip_test.go +++ b/vendor/github.com/NYTimes/gziphandler/gzip_test.go @@ -81,6 +81,17 @@ func TestGzipHandler(t *testing.T) { assert.Equal(t, http.DetectContentType([]byte(testBody)), res3.Header().Get("Content-Type")) } +func TestGzipHandlerAlreadyCompressed(t *testing.T) { + handler := newTestHandler(testBody) + + req, _ := http.NewRequest("GET", "/gzipped", nil) + req.Header.Set("Accept-Encoding", "gzip") + res := httptest.NewRecorder() + handler.ServeHTTP(res, req) + + assert.Equal(t, testBody, res.Body.String()) +} + func TestNewGzipLevelHandler(t *testing.T) { handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) @@ -435,6 +446,12 @@ func runBenchmark(b *testing.B, req *http.Request, handler http.Handler) { func newTestHandler(body string) http.Handler { return GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, body) + switch r.URL.Path { + case "/gzipped": + w.Header().Set("Content-Encoding", "gzip") + io.WriteString(w, body) + default: + io.WriteString(w, body) + } })) } |