From dba4dcb4a586d0d18366098c79f9ac465c28cc27 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 26 Apr 2015 22:53:47 -0600 Subject: [PATCH 1/3] gzip strips Accept-Encoding header after using it --- middleware/fastcgi/fastcgi.go | 6 +----- middleware/gzip/gzip.go | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/middleware/fastcgi/fastcgi.go b/middleware/fastcgi/fastcgi.go index 9a9994d7..7f780379 100644 --- a/middleware/fastcgi/fastcgi.go +++ b/middleware/fastcgi/fastcgi.go @@ -196,11 +196,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule) (map[string]string, error) for field, val := range r.Header { header := strings.ToUpper(field) header = headerNameReplacer.Replace(header) - // We don't want to pass the encoding header to prevent the fastcgi server from gzipping - // TODO: is there a better way. - if header != "ACCEPT_ENCODING" { - env["HTTP_"+header] = strings.Join(val, ", ") - } + env["HTTP_"+header] = strings.Join(val, ", ") } return env, nil diff --git a/middleware/gzip/gzip.go b/middleware/gzip/gzip.go index c9f62bc4..69411832 100644 --- a/middleware/gzip/gzip.go +++ b/middleware/gzip/gzip.go @@ -33,6 +33,9 @@ func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { return g.Next.ServeHTTP(w, r) } + // Delete this header so gzipping isn't repeated later in the chain + r.Header.Del("Accept-Encoding") + w.Header().Set("Content-Encoding", "gzip") gzipWriter := gzip.NewWriter(w) defer gzipWriter.Close() From c1916c0fb5c33c97fcfad119bdfd808f0dd5b8a2 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 26 Apr 2015 23:09:26 -0600 Subject: [PATCH 2/3] Server header in response Version number purposefully excluded (for now?) --- server/server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/server.go b/server/server.go index 1f9d40e3..028278b0 100644 --- a/server/server.go +++ b/server/server.go @@ -162,6 +162,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if vh, ok := s.vhosts[host]; ok { + w.Header().Set("Server", "Caddy") + status, _ := vh.stack.ServeHTTP(w, r) // Fallback error response in case error handling wasn't chained in From fa2403c1d346bc3284da6dbe4ecd66817ede0bc4 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 27 Apr 2015 07:35:39 -0600 Subject: [PATCH 3/3] websockets: quick version fix --- middleware/websockets/websockets.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/websockets/websockets.go b/middleware/websockets/websockets.go index c1f235de..561d84d6 100644 --- a/middleware/websockets/websockets.go +++ b/middleware/websockets/websockets.go @@ -130,5 +130,5 @@ var ( const ( envGatewayInterface = "caddy-CGI/1.1" - envServerSoftware = "caddy/?.?.?" // TODO + envServerSoftware = "caddy/" // TODO: Version )