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

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.
This commit is contained in:
Matthew Holt 2017-09-06 19:05:30 -06:00
parent f069a575cc
commit 56453e9664
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5
2 changed files with 6 additions and 0 deletions

View file

@ -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.

View file

@ -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)