mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Simplified XHR#doWrite
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user