Permalink
Browse files

Fixing too strict header validation to make it work with WebSocket in…

… Firefox.
  • Loading branch information...
gimite committed Dec 17, 2011
1 parent be76776 commit 30977897642e017532dd0fe11d1e9ebe96c870f1
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/web_socket.rb
View
@@ -300,10 +300,16 @@ def read_header()
@header[$1] = $2
@header[$1.downcase()] = $2
end
+ if !@header["upgrade"]
+ raise(WebSocket::Error, "Upgrade header is missing")
+ end
if !(@header["upgrade"] =~ /\AWebSocket\z/i)
raise(WebSocket::Error, "invalid Upgrade: " + @header["upgrade"])
end
- if !(@header["connection"] =~ /\AUpgrade\z/i)
+ if !@header["connection"]
+ raise(WebSocket::Error, "Connection header is missing")
+ end
+ if @header["connection"].split(/,/).grep(/\A\s*Upgrade\s*\z/i).empty?
raise(WebSocket::Error, "invalid Connection: " + @header["connection"])
end
end

0 comments on commit 3097789

Please sign in to comment.