Support HTTP/3 (#80)
This commit is contained in:
parent
6d9747a3f1
commit
7b288bc317
1 changed files with 4 additions and 2 deletions
|
|
@ -261,7 +261,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
|
||||||
return caddyhttp.Error(http.StatusProxyAuthRequired, authErr)
|
return caddyhttp.Error(http.StatusProxyAuthRequired, authErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.ProtoMajor != 1 && r.ProtoMajor != 2 {
|
if r.ProtoMajor != 1 && r.ProtoMajor != 2 && r.ProtoMajor != 3 {
|
||||||
return caddyhttp.Error(http.StatusHTTPVersionNotSupported,
|
return caddyhttp.Error(http.StatusHTTPVersionNotSupported,
|
||||||
fmt.Errorf("unsupported HTTP major version: %d", r.ProtoMajor))
|
fmt.Errorf("unsupported HTTP major version: %d", r.ProtoMajor))
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +279,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method == http.MethodConnect {
|
if r.Method == http.MethodConnect {
|
||||||
if r.ProtoMajor == 2 {
|
if r.ProtoMajor == 2 || r.ProtoMajor == 3 {
|
||||||
if len(r.URL.Scheme) > 0 || len(r.URL.Path) > 0 {
|
if len(r.URL.Scheme) > 0 || len(r.URL.Path) > 0 {
|
||||||
return caddyhttp.Error(http.StatusBadRequest,
|
return caddyhttp.Error(http.StatusBadRequest,
|
||||||
fmt.Errorf("CONNECT request has :scheme and/or :path pseudo-header fields"))
|
fmt.Errorf("CONNECT request has :scheme and/or :path pseudo-header fields"))
|
||||||
|
|
@ -306,6 +306,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
|
||||||
case 1: // http1: hijack the whole flow
|
case 1: // http1: hijack the whole flow
|
||||||
return serveHijack(w, targetConn)
|
return serveHijack(w, targetConn)
|
||||||
case 2: // http2: keep reading from "request" and writing into same response
|
case 2: // http2: keep reading from "request" and writing into same response
|
||||||
|
fallthrough
|
||||||
|
case 3:
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
wFlusher, ok := w.(http.Flusher)
|
wFlusher, ok := w.(http.Flusher)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue