From 1273fc4f104235cdd2e9476c19bf4f31bf970219 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Tue, 3 Jan 2012 12:59:40 -0800 Subject: [PATCH] Simplified XHR#doWrite --- lib/transports/polling-xhr.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/transports/polling-xhr.js b/lib/transports/polling-xhr.js index e4954ec3..1328cedc 100644 --- a/lib/transports/polling-xhr.js +++ b/lib/transports/polling-xhr.js @@ -34,18 +34,14 @@ XHR.prototype.__proto__ = Polling.prototype; * @api private */ -XHRPolling.prototype.doWrite = function (data) { - Polling.prototype.doWrite.call(this); +XHR.prototype.doWrite = function (data) { + var headers = { + 'Content-Type': 'text/plain; charset=UTF-8' + , 'Content-Length': Buffer.byteLength(data) + , 'Connection': 'Keep-Alive' + }; - var origin = this.req.headers.origin - , headers = { - 'Content-Type': 'text/plain; charset=UTF-8' - , 'Content-Length': data === undefined ? 0 : Buffer.byteLength(data) - , 'Connection': 'Keep-Alive' - }; - - if (origin) { - // https://developer.mozilla.org/En/HTTP_Access_Control + if (this.req.headers.origin) { headers['Access-Control-Allow-Origin'] = '*'; if (this.req.headers.cookie) { @@ -53,7 +49,6 @@ XHRPolling.prototype.doWrite = function (data) { } } - this.response.writeHead(200, headers); - this.response.write(data); - this.log.debug(this.name + ' writing', data); + this.res.writeHead(200, headers); + this.res.end(data); };