Permalink
Browse files

The proto argument to constructor now optional.

  • Loading branch information...
1 parent 58f8429 commit 23135fbd8103b77d0c7e9eee55203417bbbe9e67 @pgriess pgriess committed Jun 19, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/websocket.js
View
@@ -321,8 +321,8 @@ var WebSocket = function(url, proto) {
// Connect and perform handshaking with the server
(function() {
// Parse constructor arguments
- if (!url || !proto) {
- throw new Error('Both url and protocol must be specified.');
+ if (!url) {
+ throw new Error('Url and must be specified.');
}
// Secrets used for handshaking
@@ -339,12 +339,15 @@ var WebSocket = function(url, proto) {
var httpHeaders = {
'Connection' : 'Upgrade',
'Upgrade' : 'WebSocket',
- 'Sec-WebSocket-Protocol' : proto,
'Sec-WebSocket-Key1' : key1,
'Sec-WebSocket-Key2' : key2
};
var httpPath = '/';
+ if (proto) {
+ httpHeaders['Sec-WebSocket-Protocol'] = proto;
+ }
+
// Create the HTTP client that we'll use for handshaking. We'll cannabalize
// its socket via the 'upgrade' event and leave it to rot.
//

0 comments on commit 23135fb

Please sign in to comment.