/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['socket.io/transports/websocket.js']) {
  _$jscoverage['socket.io/transports/websocket.js'] = [];
  _$jscoverage['socket.io/transports/websocket.js'][1] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][6] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][7] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][10] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][12] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][13] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][16] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][18] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][20] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][21] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][22] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][23] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][26] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][30] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][31] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][39] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][40] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][43] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][51] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][52] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][54] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][58] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][59] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][60] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][62] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][63] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][66] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][69] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][70] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][71] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][72] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][73] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][74] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][75] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][76] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][77] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][78] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][79] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][81] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][83] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][87] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][88] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][92] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][93] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][95] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][96] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][99] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][100] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][101] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][102] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][105] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][107] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][114] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][116] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][117] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][119] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][123] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][126] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][127] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][128] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][129] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][130] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][132] = 0;
  _$jscoverage['socket.io/transports/websocket.js'][136] = 0;
}
_$jscoverage['socket.io/transports/websocket.js'][1]++;
var Client = require("../client"), Stream = require("net").Stream, url = require("url"), crypto = require("crypto");
_$jscoverage['socket.io/transports/websocket.js'][6]++;
WebSocket = module.exports = (function () {
  _$jscoverage['socket.io/transports/websocket.js'][7]++;
  Client.apply(this, arguments);
});
_$jscoverage['socket.io/transports/websocket.js'][10]++;
require("sys").inherits(WebSocket, Client);
_$jscoverage['socket.io/transports/websocket.js'][12]++;
WebSocket.prototype._onConnect = (function (req, socket) {
  _$jscoverage['socket.io/transports/websocket.js'][13]++;
  var self = this, headers = [];
  _$jscoverage['socket.io/transports/websocket.js'][16]++;
  Client.prototype._onConnect.call(this, req);
  _$jscoverage['socket.io/transports/websocket.js'][18]++;
  this.data = "";
  _$jscoverage['socket.io/transports/websocket.js'][20]++;
  if (this.request.headers.upgrade !== "WebSocket" || ! this._verifyOrigin(this.request.headers.origin)) {
    _$jscoverage['socket.io/transports/websocket.js'][21]++;
    this.listener.options.log("WebSocket connection invalid or Origin not verified");
    _$jscoverage['socket.io/transports/websocket.js'][22]++;
    this._onClose();
    _$jscoverage['socket.io/transports/websocket.js'][23]++;
    return false;
  }
  _$jscoverage['socket.io/transports/websocket.js'][26]++;
  var origin = this.request.headers.origin, location = (origin && origin.substr(0, 5) == "https"? "wss": "ws") + "://" + this.request.headers.host + this.request.url;
  _$jscoverage['socket.io/transports/websocket.js'][30]++;
  if ("sec-websocket-key1" in this.request.headers) {
    _$jscoverage['socket.io/transports/websocket.js'][31]++;
    headers = ["HTTP/1.1 101 WebSocket Protocol Handshake", "Upgrade: WebSocket", "Connection: Upgrade", "Sec-WebSocket-Origin: " + origin, "Sec-WebSocket-Location: " + location];
    _$jscoverage['socket.io/transports/websocket.js'][39]++;
    if ("sec-websocket-protocol" in this.request.headers) {
      _$jscoverage['socket.io/transports/websocket.js'][40]++;
      headers.push("Sec-WebSocket-Protocol: " + this.request.headers["sec-websocket-protocol"]);
    }
  }
  else {
    _$jscoverage['socket.io/transports/websocket.js'][43]++;
    headers = ["HTTP/1.1 101 Web Socket Protocol Handshake", "Upgrade: WebSocket", "Connection: Upgrade", "WebSocket-Origin: " + origin, "WebSocket-Location: " + location];
    _$jscoverage['socket.io/transports/websocket.js'][51]++;
    try {
      _$jscoverage['socket.io/transports/websocket.js'][52]++;
      this.connection.write(headers.concat("", "").join("\r\n"));
    }
    catch (e) {
      _$jscoverage['socket.io/transports/websocket.js'][54]++;
      this._onClose();
    }
  }
  _$jscoverage['socket.io/transports/websocket.js'][58]++;
  this.connection.setTimeout(0);
  _$jscoverage['socket.io/transports/websocket.js'][59]++;
  this.connection.setNoDelay(true);
  _$jscoverage['socket.io/transports/websocket.js'][60]++;
  this.connection.setEncoding("utf-8");
  _$jscoverage['socket.io/transports/websocket.js'][62]++;
  this.connection.addListener("data", (function (data) {
  _$jscoverage['socket.io/transports/websocket.js'][63]++;
  self._handle(data);
}));
  _$jscoverage['socket.io/transports/websocket.js'][66]++;
  if (this._proveReception(headers)) {
    _$jscoverage['socket.io/transports/websocket.js'][66]++;
    this._payload();
  }
});
_$jscoverage['socket.io/transports/websocket.js'][69]++;
WebSocket.prototype._handle = (function (data) {
  _$jscoverage['socket.io/transports/websocket.js'][70]++;
  var chunk, chunks, chunk_count;
  _$jscoverage['socket.io/transports/websocket.js'][71]++;
  this.data += data;
  _$jscoverage['socket.io/transports/websocket.js'][72]++;
  chunks = this.data.split("\ufffd");
  _$jscoverage['socket.io/transports/websocket.js'][73]++;
  chunk_count = chunks.length - 1;
  _$jscoverage['socket.io/transports/websocket.js'][74]++;
  for (var i = 0; i < chunk_count; i++) {
    _$jscoverage['socket.io/transports/websocket.js'][75]++;
    chunk = chunks[i];
    _$jscoverage['socket.io/transports/websocket.js'][76]++;
    if (chunk[0] !== "\u0000") {
      _$jscoverage['socket.io/transports/websocket.js'][77]++;
      this.listener.options.log("Data incorrectly framed by UA. Dropping connection");
      _$jscoverage['socket.io/transports/websocket.js'][78]++;
      this._onClose();
      _$jscoverage['socket.io/transports/websocket.js'][79]++;
      return false;
    }
    _$jscoverage['socket.io/transports/websocket.js'][81]++;
    this._onMessage(chunk.slice(1));
}
  _$jscoverage['socket.io/transports/websocket.js'][83]++;
  this.data = chunks[chunks.length - 1];
});
_$jscoverage['socket.io/transports/websocket.js'][87]++;
WebSocket.prototype._proveReception = (function (headers) {
  _$jscoverage['socket.io/transports/websocket.js'][88]++;
  var self = this, k1 = this.request.headers["sec-websocket-key1"], k2 = this.request.headers["sec-websocket-key2"];
  _$jscoverage['socket.io/transports/websocket.js'][92]++;
  if (k1 && k2) {
    _$jscoverage['socket.io/transports/websocket.js'][93]++;
    var md5 = crypto.createHash("md5");
    _$jscoverage['socket.io/transports/websocket.js'][95]++;
    [k1, k2].forEach((function (k) {
  _$jscoverage['socket.io/transports/websocket.js'][96]++;
  var n = parseInt(k.replace(/[^\d]/g, "")), spaces = k.replace(/[^ ]/g, "").length;
  _$jscoverage['socket.io/transports/websocket.js'][99]++;
  if (spaces === 0 || n % spaces !== 0) {
    _$jscoverage['socket.io/transports/websocket.js'][100]++;
    self.listener.options.log("Invalid WebSocket key: \"" + k + "\". Dropping connection");
    _$jscoverage['socket.io/transports/websocket.js'][101]++;
    self._onClose();
    _$jscoverage['socket.io/transports/websocket.js'][102]++;
    return false;
  }
  _$jscoverage['socket.io/transports/websocket.js'][105]++;
  n /= spaces;
  _$jscoverage['socket.io/transports/websocket.js'][107]++;
  md5.update(String.fromCharCode(n >> 24 & 255, n >> 16 & 255, n >> 8 & 255, n & 255));
}));
    _$jscoverage['socket.io/transports/websocket.js'][114]++;
    md5.update(this.upgradeHead.toString("binary"));
    _$jscoverage['socket.io/transports/websocket.js'][116]++;
    try {
      _$jscoverage['socket.io/transports/websocket.js'][117]++;
      this.connection.write(headers.concat("", "").join("\r\n") + md5.digest("binary"), "binary");
    }
    catch (e) {
      _$jscoverage['socket.io/transports/websocket.js'][119]++;
      this._onClose();
    }
  }
  _$jscoverage['socket.io/transports/websocket.js'][123]++;
  return true;
});
_$jscoverage['socket.io/transports/websocket.js'][126]++;
WebSocket.prototype._write = (function (message) {
  _$jscoverage['socket.io/transports/websocket.js'][127]++;
  try {
    _$jscoverage['socket.io/transports/websocket.js'][128]++;
    this.connection.write("\u0000", "binary");
    _$jscoverage['socket.io/transports/websocket.js'][129]++;
    this.connection.write(message, "utf8");
    _$jscoverage['socket.io/transports/websocket.js'][130]++;
    this.connection.write("\uffff", "binary");
  }
  catch (e) {
    _$jscoverage['socket.io/transports/websocket.js'][132]++;
    this._onClose();
  }
});
_$jscoverage['socket.io/transports/websocket.js'][136]++;
WebSocket.httpUpgrade = true;
_$jscoverage['socket.io/transports/websocket.js'].source = ["var Client = require('../client')","  , Stream = require('net').Stream","  , url = require('url')","  , crypto = require('crypto');","","WebSocket = module.exports = function(){","  Client.apply(this, arguments);","};","","require('sys').inherits(WebSocket, Client);","","WebSocket.prototype._onConnect = function(req, socket){","  var self = this","    , headers = [];","  ","  Client.prototype._onConnect.call(this, req);","    ","  this.data = '';","  ","  if (this.request.headers.upgrade !== 'WebSocket' || !this._verifyOrigin(this.request.headers.origin)){","    this.listener.options.log('WebSocket connection invalid or Origin not verified');","    this._onClose();","    return false;","  }","  ","  var origin = this.request.headers.origin,","      location = (origin &amp;&amp; origin.substr(0, 5) == 'https' ? 'wss' : 'ws')","               + '://' + this.request.headers.host + this.request.url;","    ","  if ('sec-websocket-key1' in this.request.headers){","    headers = [","      'HTTP/1.1 101 WebSocket Protocol Handshake',","      'Upgrade: WebSocket',","      'Connection: Upgrade',","      'Sec-WebSocket-Origin: ' + origin,","      'Sec-WebSocket-Location: ' + location","    ];","    ","    if ('sec-websocket-protocol' in this.request.headers){","      headers.push('Sec-WebSocket-Protocol: ' + this.request.headers['sec-websocket-protocol']);","    }","  } else {","    headers = [","      'HTTP/1.1 101 Web Socket Protocol Handshake',","      'Upgrade: WebSocket',","      'Connection: Upgrade',","      'WebSocket-Origin: ' + origin,","      'WebSocket-Location: ' + location","    ];","    ","    try {","      this.connection.write(headers.concat('', '').join('\\r\\n'));","    } catch(e){","      this._onClose();","    }","  }","  ","  this.connection.setTimeout(0);","  this.connection.setNoDelay(true);","  this.connection.setEncoding('utf-8');","  ","  this.connection.addListener('data', function(data){","    self._handle(data);","  });","","  if (this._proveReception(headers)) this._payload();","};","","WebSocket.prototype._handle = function(data){","  var chunk, chunks, chunk_count;","  this.data += data;","  chunks = this.data.split('\\ufffd');","  chunk_count = chunks.length - 1;","  for (var i = 0; i &lt; chunk_count; i++){","    chunk = chunks[i];","    if (chunk[0] !== '\\u0000'){","      this.listener.options.log('Data incorrectly framed by UA. Dropping connection');","      this._onClose();","      return false;","    }","    this._onMessage(chunk.slice(1));","  }","  this.data = chunks[chunks.length - 1];","};","","// http://www.whatwg.org/specs/web-apps/current-work/complete/network.html#opening-handshake","WebSocket.prototype._proveReception = function(headers){","  var self = this","    , k1 = this.request.headers['sec-websocket-key1']","    , k2 = this.request.headers['sec-websocket-key2'];","  ","  if (k1 &amp;&amp; k2){","    var md5 = crypto.createHash('md5');","","    [k1, k2].forEach(function(k){","      var n = parseInt(k.replace(/[^\\d]/g, '')),","          spaces = k.replace(/[^ ]/g, '').length;","          ","      if (spaces === 0 || n % spaces !== 0){","        self.listener.options.log('Invalid WebSocket key: \"' + k + '\". Dropping connection');","        self._onClose();","        return false;","      }","","      n /= spaces;","      ","      md5.update(String.fromCharCode(","        n &gt;&gt; 24 &amp; 0xFF,","        n &gt;&gt; 16 &amp; 0xFF,","        n &gt;&gt; 8  &amp; 0xFF,","        n       &amp; 0xFF));","    });","","    md5.update(this.upgradeHead.toString('binary'));","    ","    try {","      this.connection.write(headers.concat('', '').join('\\r\\n') + md5.digest('binary'), 'binary');","    } catch(e){","      this._onClose();","    }","  }","  ","  return true;","};","","WebSocket.prototype._write = function(message){","  try {","    this.connection.write('\\u0000', 'binary');","    this.connection.write(message, 'utf8');","    this.connection.write('\\uffff', 'binary');","  } catch(e){","    this._onClose();","  }","};","","WebSocket.httpUpgrade = true;"];
