summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/server.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-09-11 18:49:21 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-09-11 18:49:21 -0600
commitfe389fcbd7c3b8c64167d317b31adf7b98147fa8 (patch)
tree20583504dca4a5ddaec4e16c80f5ea589484d93a /modules/caddyhttp/server.go
parent005a11cf4b0af5bfbbb72f8572681b327675541c (diff)
http: Set Alt-Svc header if experimental HTTP3 server is enabled
Diffstat (limited to 'modules/caddyhttp/server.go')
-rw-r--r--modules/caddyhttp/server.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go
index e16a600..b4952e1 100644
--- a/modules/caddyhttp/server.go
+++ b/modules/caddyhttp/server.go
@@ -26,6 +26,7 @@ import (
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/modules/caddytls"
+ "github.com/lucas-clemente/quic-go/http3"
)
// Server is an HTTP server.
@@ -47,12 +48,21 @@ type Server struct {
ExperimentalHTTP3 bool `json:"experimental_http3,omitempty"`
tlsApp *caddytls.TLS
+
+ h3server *http3.Server
}
// ServeHTTP is the entry point for all HTTP requests.
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", "Caddy")
+ if s.h3server != nil {
+ err := s.h3server.SetQuicHeaders(w.Header())
+ if err != nil {
+ log.Printf("[ERROR] Setting HTTP/3 Alt-Svc header: %v", err)
+ }
+ }
+
if s.tlsApp.HandleHTTPChallenge(w, r) {
return
}