changes done based on review

1. set only `h3` header
2. set default max-age
3. support https redirect as well
This commit is contained in:
Rahul Somasundaram 2022-10-06 20:44:55 +05:30
parent b7e815483e
commit 0c0340d63e
No known key found for this signature in database
GPG key ID: AA8F0B27E83147BD

View file

@ -320,6 +320,16 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
return false return false
} }
// Let the browser know that server support HTTP/3
// max-age is set to default (24 hourd)
//
// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Alt-Svc
// TODO: take max-age from config and set
if config.DNS.ServeHTTP3 {
altSvc := fmt.Sprintf(`h3=":%[1]v";`, config.TLS.PortHTTPS)
w.Header().Set("Alt-Svc", altSvc)
}
if r.TLS == nil && web.forceHTTPS { if r.TLS == nil && web.forceHTTPS {
hostPort := host hostPort := host
if port := web.conf.PortHTTPS; port != defaultPortHTTPS { if port := web.conf.PortHTTPS; port != defaultPortHTTPS {
@ -347,11 +357,6 @@ func handleHTTPSRedirect(w http.ResponseWriter, r *http.Request) (ok bool) {
Host: r.Host, Host: r.Host,
} }
if config.DNS.ServeHTTP3 {
altSvc := fmt.Sprintf(`h3=":%[1]v"; ma=2592000,h3-29=":%[1]v"; ma=2592000,h3-Q050=":%[1]v";ma=2592000,h3-Q046=":%[1]v"; ma=2592000,h3-Q043=":%[1]v"; ma=2592000,quic=":%[1]v"; ma=2592000; v="46,43"`, config.TLS.PortHTTPS)
w.Header().Set("Alt-Svc", altSvc)
}
w.Header().Set("Access-Control-Allow-Origin", originURL.String()) w.Header().Set("Access-Control-Allow-Origin", originURL.String())
w.Header().Set("Vary", "Origin") w.Header().Set("Vary", "Origin")