0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Abiola Ibrahim 2015-12-21 20:49:01 +01:00
commit 55d22f4ead
2 changed files with 12 additions and 3 deletions

View file

@ -400,6 +400,15 @@ func (c *FCGIClient) Do(p map[string]string, req io.Reader) (r io.Reader, err er
return 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 // Request returns a HTTP Response with Header and Body
// from fcgi responder // from fcgi responder
func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) { 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) resp.ContentLength, _ = strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64)
if chunked(resp.TransferEncoding) { if chunked(resp.TransferEncoding) {
resp.Body = ioutil.NopCloser(httputil.NewChunkedReader(rb)) resp.Body = clientCloser{c, httputil.NewChunkedReader(rb)}
} else { } else {
resp.Body = ioutil.NopCloser(rb) resp.Body = clientCloser{c, ioutil.NopCloser(rb)}
} }
return return
} }

View file

@ -114,7 +114,7 @@ type gzipResponseWriter struct {
func (w *gzipResponseWriter) WriteHeader(code int) { func (w *gzipResponseWriter) WriteHeader(code int) {
w.Header().Del("Content-Length") w.Header().Del("Content-Length")
w.Header().Set("Content-Encoding", "gzip") w.Header().Set("Content-Encoding", "gzip")
w.Header().Set("Vary", "Accept-Encoding") w.Header().Add("Vary", "Accept-Encoding")
w.ResponseWriter.WriteHeader(code) w.ResponseWriter.WriteHeader(code)
w.statusCodeWritten = true w.statusCodeWritten = true
} }