Make websocket connection upgrade header check case-insensitive

I was having troubles configuring an nginx reverse-proxy when
using Websockets.

It turns out my configuration was sending a "Connection: upgrade"
header, but Lotus expected "Connection: Upgrade".

This commit converts the check to be case-insensitive.

Some of the examples on the MDN page show lower-case "upgrade",
so I think it's not unusual for the usage to vary.
This commit is contained in:
Jim Pick 2020-03-13 13:07:39 -07:00
parent 954085d33e
commit b6d5ea629b

View File

@ -65,7 +65,8 @@ func (s *RPCServer) handleWS(ctx context.Context, w http.ResponseWriter, r *http
func (s *RPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (s *RPCServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()
if strings.Contains(r.Header.Get("Connection"), "Upgrade") { h := strings.ToLower(r.Header.Get("Connection"))
if strings.Contains(h, "upgrade") {
s.handleWS(ctx, w, r) s.handleWS(ctx, w, r)
return return
} }