mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
reverseproxy: Only handle websocket protocol (#6740)
This commit is contained in:
parent
bcaa8aaf11
commit
328fb614f0
1 changed files with 2 additions and 2 deletions
|
@ -398,13 +398,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
|
|||
}
|
||||
// websocket over http2, assuming backend doesn't support this, the request will be modified to http1.1 upgrade
|
||||
// TODO: once we can reliably detect backend support this, it can be removed for those backends
|
||||
if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") != "" {
|
||||
if r.ProtoMajor == 2 && r.Method == http.MethodConnect && r.Header.Get(":protocol") == "websocket" {
|
||||
clonedReq.Header.Del(":protocol")
|
||||
// keep the body for later use. http1.1 upgrade uses http.NoBody
|
||||
caddyhttp.SetVar(clonedReq.Context(), "h2_websocket_body", clonedReq.Body)
|
||||
clonedReq.Body = http.NoBody
|
||||
clonedReq.Method = http.MethodGet
|
||||
clonedReq.Header.Set("Upgrade", r.Header.Get(":protocol"))
|
||||
clonedReq.Header.Set("Upgrade", "websocket")
|
||||
clonedReq.Header.Set("Connection", "Upgrade")
|
||||
key := make([]byte, 16)
|
||||
_, randErr := rand.Read(key)
|
||||
|
|
Loading…
Reference in a new issue