Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better error message when client disconnected without sending anything.

  • Loading branch information...
commit 94437cebe69da455eb18a1e448cb1253b8d74f63 1 parent 3097789
@gimite authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/web_socket.rb
View
10 lib/web_socket.rb
@@ -39,9 +39,13 @@ def initialize(arg, params = {})
@server = params[:server]
@socket = arg
- line = gets().chomp()
+ line = gets()
+ if !line
+ raise(WebSocket::Error, "Client disconnected without sending anything.")
+ end
+ line = line.chomp()
if !(line =~ /\AGET (\S+) HTTP\/1.1\z/n)
- raise(WebSocket::Error, "invalid request: #{line}")
+ raise(WebSocket::Error, "Invalid request: #{line}")
end
@path = $1
read_header()
@@ -501,7 +505,7 @@ def create_web_socket(socket)
send_flash_socket_policy_file(socket)
return nil
else
- socket.ungetc(ch)
+ socket.ungetc(ch) if ch
return WebSocket.new(socket, :server => self)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.