Skip to content

Commit b38cea6

Browse files
Bas van Kervelobscuren
authored andcommitted
[release/1.4.4] rpc: HTTP origin case insensitive
(cherry picked from commit 5479097)
1 parent f213a9d commit b38cea6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rpc/websocket.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ func wsHandshakeValidator(allowedOrigins []string) func(*websocket.Config, *http
6161
allowAllOrigins = true
6262
}
6363
if origin != "" {
64-
origins.Add(origin)
64+
origins.Add(strings.ToLower(origin))
6565
}
6666
}
6767

68-
// allow localhost if no allowedOrigins are specified
68+
// allow localhost if no allowedOrigins are specified.
6969
if len(origins.List()) == 0 {
7070
origins.Add("http://localhost")
7171
if hostname, err := os.Hostname(); err == nil {
72-
origins.Add("http://" + hostname)
72+
origins.Add("http://" + strings.ToLower(hostname))
7373
}
7474
}
7575

7676
glog.V(logger.Debug).Infof("Allowed origin(s) for WS RPC interface %v\n", origins.List())
7777

7878
f := func(cfg *websocket.Config, req *http.Request) error {
79-
origin := req.Header.Get("Origin")
79+
origin := strings.ToLower(req.Header.Get("Origin"))
8080
if allowAllOrigins || origins.Has(origin) {
8181
return nil
8282
}

0 commit comments

Comments
 (0)