add Upgrade Response status code check to begin/abort websocket client

This commit is contained in:
xdrm-brackets 2018-04-28 16:23:42 +02:00
parent 5fcdc9ca70
commit 3c5d45ee21
1 changed files with 6 additions and 0 deletions

View File

@ -76,6 +76,12 @@ func (s *Server) Launch() error {
upgrader, err := upgrader.Upgrade(sock)
if err != nil {
fmt.Printf(" - upgrade error: %s\n", err)
sock.Close()
continue
}
if upgrader.Response.GetStatusCode() != 101 {
fmt.Printf(" - upgrade bad request\n")
sock.Close()
continue
}