Skip to content

Commit

Permalink
Implement Caddy-Sponsors HTTP response header
Browse files Browse the repository at this point in the history
(See EULA.) Personally-licensed official Caddy builds cannot remove
this header by configuration. The commercially-licensed builds of Caddy
don't have this header.
  • Loading branch information
Matthew Holt committed Sep 11, 2017
1 parent f069a57 commit 56453e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions caddyhttp/header/header.go
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions caddyhttp/httpserver/server.go
Expand Up @@ -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)

Expand Down

0 comments on commit 56453e9

Please sign in to comment.