From 56453e9664aa2c24115eb52a4e933febb3cac1f7 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 6 Sep 2017 19:05:30 -0600 Subject: [PATCH] Implement Caddy-Sponsors HTTP response header (See EULA.) Personally-licensed official Caddy builds cannot remove this header by configuration. The commercially-licensed builds of Caddy don't have this header. --- caddyhttp/header/header.go | 4 ++++ caddyhttp/httpserver/server.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/caddyhttp/header/header.go b/caddyhttp/header/header.go index 3967dd38..6a60eacf 100644 --- a/caddyhttp/header/header.go +++ b/caddyhttp/header/header.go @@ -27,6 +27,10 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) for _, rule := range h.Rules { if httpserver.Path(r.URL.Path).Matches(rule.Path) { for name := range rule.Headers { + if name == "Caddy-Sponsors" || name == "-Caddy-Sponsors" { + // see EULA + continue + } // One can either delete a header, add multiple values to a header, or simply // set a header. diff --git a/caddyhttp/httpserver/server.go b/caddyhttp/httpserver/server.go index 6a51aa9c..6096a133 100644 --- a/caddyhttp/httpserver/server.go +++ b/caddyhttp/httpserver/server.go @@ -343,6 +343,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { r = r.WithContext(c) w.Header().Set("Server", caddy.AppName) + sponsors := "Minio, Uptime Robot, and Sourcegraph" + w.Header().Set("Caddy-Sponsors", "This free web server is made possible by its sponsors: "+sponsors) status, _ := s.serveHTTP(w, r)