diff options
author | Corey Hulen <corey@hulen.com> | 2017-03-24 23:31:34 -0700 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-03-25 03:31:34 -0300 |
commit | 54d3d47daf9190275bbdaf8703b84969a4593451 (patch) | |
tree | 05899b296d0186c1a0da8a540bc486e34ad8eec9 /vendor/github.com/NYTimes | |
parent | 7460302dec7796e01c98264e84bece8169cb6ed9 (diff) | |
download | chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.gz chat-54d3d47daf9190275bbdaf8703b84969a4593451.tar.bz2 chat-54d3d47daf9190275bbdaf8703b84969a4593451.zip |
PLT-6076 Adding viper libs for config file changes (#5871)
* Adding viper libs for config file changes
* Removing the old fsnotify lib
* updating some missing libs
Diffstat (limited to 'vendor/github.com/NYTimes')
-rw-r--r-- | vendor/github.com/NYTimes/gziphandler/gzip.go | 1 | ||||
-rw-r--r-- | vendor/github.com/NYTimes/gziphandler/gzip_test.go | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/vendor/github.com/NYTimes/gziphandler/gzip.go b/vendor/github.com/NYTimes/gziphandler/gzip.go index fbc99396d..23efacc45 100644 --- a/vendor/github.com/NYTimes/gziphandler/gzip.go +++ b/vendor/github.com/NYTimes/gziphandler/gzip.go @@ -117,6 +117,7 @@ func (w *GzipResponseWriter) Close() error { err := w.gw.Close() gzipWriterPools[w.index].Put(w.gw) + w.gw = nil return err } diff --git a/vendor/github.com/NYTimes/gziphandler/gzip_test.go b/vendor/github.com/NYTimes/gziphandler/gzip_test.go index f2d44e04f..80f54c77d 100644 --- a/vendor/github.com/NYTimes/gziphandler/gzip_test.go +++ b/vendor/github.com/NYTimes/gziphandler/gzip_test.go @@ -215,6 +215,31 @@ func TestGzipHandlerContentLength(t *testing.T) { assert.NotEqual(t, b, body) } +func TestGzipDoubleClose(t *testing.T) { + // reset the pool for the default compression so we can make sure duplicates + // aren't added back by double close + addLevelPool(gzip.DefaultCompression) + + handler := GzipHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // call close here and it'll get called again interally by + // NewGzipLevelHandler's handler defer + w.Write([]byte("test")) + w.(io.Closer).Close() + })) + + r := httptest.NewRequest("GET", "/", nil) + r.Header.Set("Accept-Encoding", "gzip") + w := httptest.NewRecorder() + handler.ServeHTTP(w, r) + + // the second close shouldn't have added the same writer + // so we pull out 2 writers from the pool and make sure they're different + w1 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get() + w2 := gzipWriterPools[poolIndex(gzip.DefaultCompression)].Get() + // assert.NotEqual looks at the value and not the address, so we use regular == + assert.False(t, w1 == w2) +} + // -------------------------------------------------------------------- func BenchmarkGzipHandler_S2k(b *testing.B) { benchmark(b, false, 2048) } |