Some code improvements (#1909)

* strings.ToLower comparison changed to strings.EqualFold.
* Rewrite switch statement with only one case as if.
This commit is contained in:
Kirill Motkov
2019-05-21 18:08:52 +03:00
committed by 田欧
parent 8ee9d959a0
commit b1d607a899
3 changed files with 4 additions and 6 deletions

View File

@ -671,7 +671,7 @@ func (c *Context) ContentType() string {
// handshake is being initiated by the client.
func (c *Context) IsWebsocket() bool {
if strings.Contains(strings.ToLower(c.requestHeader("Connection")), "upgrade") &&
strings.ToLower(c.requestHeader("Upgrade")) == "websocket" {
strings.EqualFold(c.requestHeader("Upgrade"), "websocket") {
return true
}
return false