From 81c4ea6be7c7b26a3ab860375dae62751ad71f47 Mon Sep 17 00:00:00 2001 From: Mateusz Gajewski Date: Mon, 20 Jun 2016 21:50:25 +0200 Subject: [PATCH] Add support for Alt-Svc headers (#892) --- caddyhttp/httpserver/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/caddyhttp/httpserver/server.go b/caddyhttp/httpserver/server.go index 37ed0165..2247f53d 100644 --- a/caddyhttp/httpserver/server.go +++ b/caddyhttp/httpserver/server.go @@ -71,6 +71,7 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) { // Enable QUIC if desired if QUIC { s.quicServer = &h2quic.Server{Server: s.Server} + s.Server.Handler = s.wrapWithSvcHeaders(s.Server.Handler) } // We have to bound our wg with one increment @@ -105,6 +106,13 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) { return s, nil } +func (s *Server) wrapWithSvcHeaders(previousHandler http.Handler) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + s.quicServer.SetQuicHeaders(w.Header()) + previousHandler.ServeHTTP(w, r) + } +} + // Listen creates an active listener for s that can be // used to serve requests. func (s *Server) Listen() (net.Listener, error) {