From 34d3cd7c927e113c7ec65735c4694fb21d2d51ae Mon Sep 17 00:00:00 2001 From: Craig Peterson Date: Tue, 15 Dec 2015 08:56:44 -0700 Subject: [PATCH 1/2] Gzip: Append to Vary header instead of replacing. --- middleware/gzip/gzip.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/gzip/gzip.go b/middleware/gzip/gzip.go index 147d739f..39a92266 100644 --- a/middleware/gzip/gzip.go +++ b/middleware/gzip/gzip.go @@ -113,7 +113,7 @@ type gzipResponseWriter struct { func (w gzipResponseWriter) WriteHeader(code int) { w.Header().Del("Content-Length") w.Header().Set("Content-Encoding", "gzip") - w.Header().Set("Vary", "Accept-Encoding") + w.Header().Add("Vary", "Accept-Encoding") w.ResponseWriter.WriteHeader(code) } From f639d3cd68bc8bf06fe7953b3278d206a2f17424 Mon Sep 17 00:00:00 2001 From: Abiola Ibrahim Date: Mon, 21 Dec 2015 11:57:20 +0100 Subject: [PATCH 2/2] FastCGI: Close client connections when done. --- middleware/fastcgi/fcgiclient.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/middleware/fastcgi/fcgiclient.go b/middleware/fastcgi/fcgiclient.go index 97dc6153..511a5219 100644 --- a/middleware/fastcgi/fcgiclient.go +++ b/middleware/fastcgi/fcgiclient.go @@ -400,6 +400,15 @@ func (c *FCGIClient) Do(p map[string]string, req io.Reader) (r io.Reader, err er return } +// clientCloser is a io.ReadCloser. It wraps a io.Reader with a Closer +// that closes FCGIClient connection. +type clientCloser struct { + *FCGIClient + io.Reader +} + +func (f clientCloser) Close() error { return f.rwc.Close() } + // Request returns a HTTP Response with Header and Body // from fcgi responder func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) { @@ -439,9 +448,9 @@ func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Res resp.ContentLength, _ = strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64) if chunked(resp.TransferEncoding) { - resp.Body = ioutil.NopCloser(httputil.NewChunkedReader(rb)) + resp.Body = clientCloser{c, httputil.NewChunkedReader(rb)} } else { - resp.Body = ioutil.NopCloser(rb) + resp.Body = clientCloser{c, ioutil.NopCloser(rb)} } return }