Skip to content

Commit

Permalink
Support HTTP/3
Browse files Browse the repository at this point in the history
  • Loading branch information
klzgrad committed Sep 27, 2020
1 parent c89027b commit f01c163
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions forwardproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
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,
fmt.Errorf("unsupported HTTP major version: %d", r.ProtoMajor))
}
Expand All @@ -255,7 +255,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht

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 {
return caddyhttp.Error(http.StatusBadRequest,
fmt.Errorf("CONNECT request has :scheme and/or :path pseudo-header fields"))
Expand All @@ -282,6 +282,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
case 1: // http1: hijack the whole flow
return serveHijack(w, targetConn)
case 2: // http2: keep reading from "request" and writing into same response
fallthrough
case 3:
defer r.Body.Close()
wFlusher, ok := w.(http.Flusher)
if !ok {
Expand Down

0 comments on commit f01c163

Please sign in to comment.