Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Andres Virviescas Santana committed Jan 4, 2021
1 parent 4a68976 commit 3850145
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/fasthttp/websocket
go 1.12

require (
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb
github.com/valyala/fasthttp v1.18.0
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f
github.com/valyala/fasthttp v1.19.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDa
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb h1:XPJCVf85HPE2jMVEQ7QWrazaZo1lc94GbUWaQ8Yv5sM=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f h1:MlVk9SWHScKX//xsHudKurgtyVOmD06TLYKnuTPNK4g=
github.com/savsgio/gotils v0.0.0-20210104112019-96a5e1e9898f/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.18.0 h1:IV0DdMlatq9QO1Cr6wGJPVW1sV1Q8HvZXAIcjorylyM=
github.com/valyala/fasthttp v1.18.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/fasthttp v1.19.0 h1:PfTS4PeH3xDr3WomrDS2ID8lU2GskK1xS3YG6gIpibU=
github.com/valyala/fasthttp v1.19.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand Down
20 changes: 10 additions & 10 deletions server_fasthttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"sync"
"time"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/strconv"
"github.com/valyala/fasthttp"
)

Expand Down Expand Up @@ -98,7 +98,7 @@ func (u *FastHTTPUpgrader) selectSubprotocol(ctx *fasthttp.RequestCtx) []byte {

for _, serverProtocol := range u.Subprotocols {
for _, clientProtocol := range clientProtocols {
if gotils.B2S(clientProtocol) == serverProtocol {
if strconv.B2S(clientProtocol) == serverProtocol {
return clientProtocol
}
}
Expand Down Expand Up @@ -138,15 +138,15 @@ func (u *FastHTTPUpgrader) Upgrade(ctx *fasthttp.RequestCtx, handler FastHTTPHan
return u.responseError(ctx, fasthttp.StatusMethodNotAllowed, fmt.Sprintf("%s request method is not GET", badHandshake))
}

if !tokenContainsValue(gotils.B2S(ctx.Request.Header.Peek("Connection")), "Upgrade") {
if !tokenContainsValue(strconv.B2S(ctx.Request.Header.Peek("Connection")), "Upgrade") {
return u.responseError(ctx, fasthttp.StatusBadRequest, fmt.Sprintf("%s 'upgrade' token not found in 'Connection' header", badHandshake))
}

if !tokenContainsValue(gotils.B2S(ctx.Request.Header.Peek("Upgrade")), "Websocket") {
if !tokenContainsValue(strconv.B2S(ctx.Request.Header.Peek("Upgrade")), "Websocket") {
return u.responseError(ctx, fasthttp.StatusBadRequest, fmt.Sprintf("%s 'websocket' token not found in 'Upgrade' header", badHandshake))
}

if !tokenContainsValue(gotils.B2S(ctx.Request.Header.Peek("Sec-Websocket-Version")), "13") {
if !tokenContainsValue(strconv.B2S(ctx.Request.Header.Peek("Sec-Websocket-Version")), "13") {
return u.responseError(ctx, fasthttp.StatusBadRequest, "websocket: unsupported version: 13 not found in 'Sec-Websocket-Version' header")
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func (u *FastHTTPUpgrader) Upgrade(ctx *fasthttp.RequestCtx, handler FastHTTPHan

c := newConn(netConn, true, u.ReadBufferSize, u.WriteBufferSize, u.WriteBufferPool, nil, writeBuf)
if subprotocol != nil {
c.subprotocol = gotils.B2S(subprotocol)
c.subprotocol = strconv.B2S(subprotocol)
}

if compress {
Expand All @@ -213,16 +213,16 @@ func fastHTTPcheckSameOrigin(ctx *fasthttp.RequestCtx) bool {
if len(origin) == 0 {
return true
}
u, err := url.Parse(gotils.B2S(origin))
u, err := url.Parse(strconv.B2S(origin))
if err != nil {
return false
}
return equalASCIIFold(u.Host, gotils.B2S(ctx.Host()))
return equalASCIIFold(u.Host, strconv.B2S(ctx.Host()))
}

// FastHTTPIsWebSocketUpgrade returns true if the client requested upgrade to the
// WebSocket protocol.
func FastHTTPIsWebSocketUpgrade(ctx *fasthttp.RequestCtx) bool {
return tokenContainsValue(gotils.B2S(ctx.Request.Header.Peek("Connection")), "Upgrade") &&
tokenContainsValue(gotils.B2S(ctx.Request.Header.Peek("Upgrade")), "Websocket")
return tokenContainsValue(strconv.B2S(ctx.Request.Header.Peek("Connection")), "Upgrade") &&
tokenContainsValue(strconv.B2S(ctx.Request.Header.Peek("Upgrade")), "Websocket")
}

0 comments on commit 3850145

Please sign in to comment.