Browse Source
http: Set Alt-Svc header if experimental HTTP3 server is enabled
master
Matthew Holt
5 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with
11 additions and
0 deletions
-
modules/caddyhttp/caddyhttp.go
-
modules/caddyhttp/server.go
|
|
@ -209,6 +209,7 @@ func (app *App) Start() error { |
|
|
|
go h3srv.Serve(h3ln) |
|
|
|
app.h3servers = append(app.h3servers, h3srv) |
|
|
|
app.h3listeners = append(app.h3listeners, h3ln) |
|
|
|
srv.h3server = h3srv |
|
|
|
} |
|
|
|
/////////
|
|
|
|
} |
|
|
|
|
|
@ -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 |
|
|
|
} |
|
|
|