isValidChallengeKey checks if the argument meets RFC6455 specification.
(s string)
| 284 | |
| 285 | // isValidChallengeKey checks if the argument meets RFC6455 specification. |
| 286 | func 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 | } |
no outgoing calls