Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
http: Set Alt-Svc header if experimental HTTP3 server is enabled
Matthew Holt committed
Sep 11, 2019 at 18:49 UTC
fe389fcbd7c3b8c64167d317b31adf7b98147fa8
2 files changed
+11
modules/caddyhttp/caddyhttp.go
+1
@@ -209,6 +209,7 @@ func (app *App) Start() error {
209
go h3srv.Serve(h3ln)
210
app.h3servers = append(app.h3servers, h3srv)
211
app.h3listeners = append(app.h3listeners, h3ln)
212
+ srv.h3server = h3srv
213
}
214
/////////
215
}
modules/caddyhttp/server.go
+10
@@ -26,6 +26,7 @@ import (
26
27
"github.com/caddyserver/caddy/v2"
28
"github.com/caddyserver/caddy/v2/modules/caddytls"
29
+ "github.com/lucas-clemente/quic-go/http3"
30
)
31
32
// Server is an HTTP server.
@@ -47,12 +48,21 @@ type Server struct {
48
ExperimentalHTTP3 bool `json:"experimental_http3,omitempty"`
49
50
tlsApp *caddytls.TLS
51
+
52
+ h3server *http3.Server
53
}
54
55
// ServeHTTP is the entry point for all HTTP requests.
56
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
57
w.Header().Set("Server", "Caddy")
58
59
+ if s.h3server != nil {
60
+ err := s.h3server.SetQuicHeaders(w.Header())
61
+ if err != nil {
62
+ log.Printf("[ERROR] Setting HTTP/3 Alt-Svc header: %v", err)
63
+ }
64
+ }
65
+
66
if s.tlsApp.HandleHTTPChallenge(w, r) {
67
return
68
}