MCPcopy
hub / github.com/gorilla/websocket / isValidChallengeKey

Function isValidChallengeKey

util.go:286–298  ·  view source on GitHub ↗

isValidChallengeKey checks if the argument meets RFC6455 specification.

(s string)

Source from the content-addressed store, hash-verified

284
285// isValidChallengeKey checks if the argument meets RFC6455 specification.
286func isValidChallengeKey(s string) bool {
287 // From RFC6455:
288 //
289 // A |Sec-WebSocket-Key| header field with a base64-encoded (see
290 // Section 4 of [RFC4648]) value that, when decoded, is 16 bytes in
291 // length.
292
293 if s == "" {
294 return false
295 }
296 decoded, err := base64.StdEncoding.DecodeString(s)
297 return err == nil && len(decoded) == 16
298}

Callers 2

UpgradeMethod · 0.85
TestIsValidChallengeKeyFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsValidChallengeKeyFunction · 0.68