Commit 56453e96 authored by Matthew Holt's avatar Matthew Holt

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.
parent f069a575
...@@ -27,6 +27,10 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) ...@@ -27,6 +27,10 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
for _, rule := range h.Rules { for _, rule := range h.Rules {
if httpserver.Path(r.URL.Path).Matches(rule.Path) { if httpserver.Path(r.URL.Path).Matches(rule.Path) {
for name := range rule.Headers { 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 // One can either delete a header, add multiple values to a header, or simply
// set a header. // set a header.
......
...@@ -343,6 +343,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { ...@@ -343,6 +343,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
r = r.WithContext(c) r = r.WithContext(c)
w.Header().Set("Server", caddy.AppName) 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) status, _ := s.serveHTTP(w, r)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment