/* automatically generated by JSCoverage - do not edit */
if (typeof _$jscoverage === 'undefined') _$jscoverage = {};
if (! _$jscoverage['socket.io/transports/xhr-polling.js']) {
  _$jscoverage['socket.io/transports/xhr-polling.js'] = [];
  _$jscoverage['socket.io/transports/xhr-polling.js'][1] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][4] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][5] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][8] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][10] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][11] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][18] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][19] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][20] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][22] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][23] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][24] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][26] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][27] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][30] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][31] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][33] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][34] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][35] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][36] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][37] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][38] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][40] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][41] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][42] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][43] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][46] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][48] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][49] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][51] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][52] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][53] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][55] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][59] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][60] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][61] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][64] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][65] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][66] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][68] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][69] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][70] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][72] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][73] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][74] = 0;
  _$jscoverage['socket.io/transports/xhr-polling.js'][75] = 0;
}
_$jscoverage['socket.io/transports/xhr-polling.js'][1]++;
var Client = require("../client"), qs = require("querystring");
_$jscoverage['socket.io/transports/xhr-polling.js'][4]++;
var Polling = module.exports = (function () {
  _$jscoverage['socket.io/transports/xhr-polling.js'][5]++;
  Client.apply(this, arguments);
});
_$jscoverage['socket.io/transports/xhr-polling.js'][8]++;
require("sys").inherits(Polling, Client);
_$jscoverage['socket.io/transports/xhr-polling.js'][10]++;
Polling.prototype.getOptions = (function () {
  _$jscoverage['socket.io/transports/xhr-polling.js'][11]++;
  return ({timeout: null, closeTimeout: 8000, duration: 20000});
});
_$jscoverage['socket.io/transports/xhr-polling.js'][18]++;
Polling.prototype._onConnect = (function (req, res) {
  _$jscoverage['socket.io/transports/xhr-polling.js'][19]++;
  var self = this, body = "";
  _$jscoverage['socket.io/transports/xhr-polling.js'][20]++;
  switch (req.method) {
  case "GET":
    _$jscoverage['socket.io/transports/xhr-polling.js'][22]++;
    Client.prototype._onConnect.apply(this, [req, res]);
    _$jscoverage['socket.io/transports/xhr-polling.js'][23]++;
    this._closeTimeout = setTimeout((function () {
  _$jscoverage['socket.io/transports/xhr-polling.js'][24]++;
  self._write("");
}), this.options.duration);
    _$jscoverage['socket.io/transports/xhr-polling.js'][26]++;
    this._payload();
    _$jscoverage['socket.io/transports/xhr-polling.js'][27]++;
    break;
  case "POST":
    _$jscoverage['socket.io/transports/xhr-polling.js'][30]++;
    req.addListener("data", (function (message) {
  _$jscoverage['socket.io/transports/xhr-polling.js'][31]++;
  body += message;
}));
    _$jscoverage['socket.io/transports/xhr-polling.js'][33]++;
    req.addListener("end", (function () {
  _$jscoverage['socket.io/transports/xhr-polling.js'][34]++;
  var headers = {"Content-Type": "text/plain"};
  _$jscoverage['socket.io/transports/xhr-polling.js'][35]++;
  if (req.headers.origin) {
    _$jscoverage['socket.io/transports/xhr-polling.js'][36]++;
    if (self._verifyOrigin(req.headers.origin)) {
      _$jscoverage['socket.io/transports/xhr-polling.js'][37]++;
      headers["Access-Control-Allow-Origin"] = "*";
      _$jscoverage['socket.io/transports/xhr-polling.js'][38]++;
      if (req.headers.cookie) {
        _$jscoverage['socket.io/transports/xhr-polling.js'][38]++;
        headers["Access-Control-Allow-Credentials"] = "true";
      }
    }
    else {
      _$jscoverage['socket.io/transports/xhr-polling.js'][40]++;
      res.writeHead(401);
      _$jscoverage['socket.io/transports/xhr-polling.js'][41]++;
      res.write("unauthorized");
      _$jscoverage['socket.io/transports/xhr-polling.js'][42]++;
      res.end();
      _$jscoverage['socket.io/transports/xhr-polling.js'][43]++;
      return;
    }
  }
  _$jscoverage['socket.io/transports/xhr-polling.js'][46]++;
  try {
    _$jscoverage['socket.io/transports/xhr-polling.js'][48]++;
    var msg = qs.parse(body);
    _$jscoverage['socket.io/transports/xhr-polling.js'][49]++;
    self._onMessage(msg.data);
  }
  catch (e) {
  }
  _$jscoverage['socket.io/transports/xhr-polling.js'][51]++;
  res.writeHead(200, headers);
  _$jscoverage['socket.io/transports/xhr-polling.js'][52]++;
  res.write("ok");
  _$jscoverage['socket.io/transports/xhr-polling.js'][53]++;
  res.end();
}));
    _$jscoverage['socket.io/transports/xhr-polling.js'][55]++;
    break;
  }
});
_$jscoverage['socket.io/transports/xhr-polling.js'][59]++;
Polling.prototype._onClose = (function () {
  _$jscoverage['socket.io/transports/xhr-polling.js'][60]++;
  if (this._closeTimeout) {
    _$jscoverage['socket.io/transports/xhr-polling.js'][60]++;
    clearTimeout(this._closeTimeout);
  }
  _$jscoverage['socket.io/transports/xhr-polling.js'][61]++;
  return Client.prototype._onClose.call(this);
});
_$jscoverage['socket.io/transports/xhr-polling.js'][64]++;
Polling.prototype._write = (function (message) {
  _$jscoverage['socket.io/transports/xhr-polling.js'][65]++;
  if (this._open) {
    _$jscoverage['socket.io/transports/xhr-polling.js'][66]++;
    var headers = {"Content-Type": "text/plain; charset=UTF-8", "Content-Length": Buffer.byteLength(message)};
    _$jscoverage['socket.io/transports/xhr-polling.js'][68]++;
    if (this.request.headers.origin && this._verifyOrigin(this.request.headers.origin)) {
      _$jscoverage['socket.io/transports/xhr-polling.js'][69]++;
      headers["Access-Control-Allow-Origin"] = this.request.headers.origin;
      _$jscoverage['socket.io/transports/xhr-polling.js'][70]++;
      if (this.request.headers.cookie) {
        _$jscoverage['socket.io/transports/xhr-polling.js'][70]++;
        headers["Access-Control-Allow-Credentials"] = "true";
      }
    }
    _$jscoverage['socket.io/transports/xhr-polling.js'][72]++;
    this.response.writeHead(200, headers);
    _$jscoverage['socket.io/transports/xhr-polling.js'][73]++;
    this.response.write(message);
    _$jscoverage['socket.io/transports/xhr-polling.js'][74]++;
    this.response.end();
    _$jscoverage['socket.io/transports/xhr-polling.js'][75]++;
    this._onClose();
  }
});
_$jscoverage['socket.io/transports/xhr-polling.js'].source = ["var Client = require('../client')","  , qs = require('querystring');","","var Polling = module.exports = function(){","  Client.apply(this, arguments);","};","","require('sys').inherits(Polling, Client);","","Polling.prototype.getOptions = function(){","  return {","    timeout: null, // no heartbeats","    closeTimeout: 8000,","    duration: 20000","  };","};","","Polling.prototype._onConnect = function(req, res){","  var self = this, body = '';","  switch (req.method){","    case 'GET':","      Client.prototype._onConnect.apply(this, [req, res]);","      this._closeTimeout = setTimeout(function(){","        self._write('');","      }, this.options.duration);","      this._payload();","      break;","      ","    case 'POST':","      req.addListener('data', function(message){","        body += message;","      });","      req.addListener('end', function(){","        var headers = {'Content-Type': 'text/plain'};","        if (req.headers.origin){","          if (self._verifyOrigin(req.headers.origin)){","            headers['Access-Control-Allow-Origin'] = '*';","            if (req.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';","          } else {","            res.writeHead(401);","            res.write('unauthorized');","            res.end();","            return;","          }","        }","        try {","          // optimization: just strip first 5 characters here?","          var msg = qs.parse(body);","          self._onMessage(msg.data);","        } catch(e){}","        res.writeHead(200, headers);","        res.write('ok');","        res.end();","      });","      break;","  }","};","","Polling.prototype._onClose = function(){","  if (this._closeTimeout) clearTimeout(this._closeTimeout);","  return Client.prototype._onClose.call(this);","};","  ","Polling.prototype._write = function(message){","  if (this._open){","    var headers = {'Content-Type': 'text/plain; charset=UTF-8', 'Content-Length': Buffer.byteLength(message)};","    // https://developer.mozilla.org/En/HTTP_Access_Control","    if (this.request.headers.origin &amp;&amp; this._verifyOrigin(this.request.headers.origin)){","      headers['Access-Control-Allow-Origin'] = this.request.headers.origin;","      if (this.request.headers.cookie) headers['Access-Control-Allow-Credentials'] = 'true';","    }","    this.response.writeHead(200, headers);","    this.response.write(message);","    this.response.end();","    this._onClose();","  }","};"];
