Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When possible, set the Accept header appropriately #542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dist/sockjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sockjs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sockjs.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/info-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function InfoAjax(url, AjaxObject) {

var self = this;
var t0 = +new Date();
this.xo = new AjaxObject('GET', url);
this.xo = new AjaxObject('GET', url, null, { headers: { 'Accept': 'application/json' } });

this.xo.once('finish', function(status, text) {
var info, rtt;
Expand Down
4 changes: 2 additions & 2 deletions lib/transport/lib/ajax-based.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ if (process.env.NODE_ENV !== 'production') {
function createAjaxSender(AjaxObject) {
return function(url, payload, callback) {
debug('create ajax sender', url, payload);
var opt = {};
var opt = { headers: { 'Accept': 'text/plain' } };
if (typeof payload === 'string') {
opt.headers = {'Content-type': 'text/plain'};
opt.headers['Content-type'] = 'text/plain';
}
var ajaxUrl = urlUtils.addPath(url, '/xhr_send');
var xo = new AjaxObject('POST', ajaxUrl, payload, opt);
Expand Down
2 changes: 1 addition & 1 deletion lib/transport/receiver/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function XhrReceiver(url, AjaxObject) {

this.bufferPosition = 0;

this.xo = new AjaxObject('POST', url, null);
this.xo = new AjaxObject('POST', url, null, { headers: { 'Accept': 'text/plain' } });
this.xo.on('chunk', this._chunkHandler.bind(this));
this.xo.once('finish', function(status, text) {
debug('finish', status, text);
Expand Down
8 changes: 4 additions & 4 deletions lib/transport/sender/xhr-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ var inherits = require('inherits')
, XhrDriver = require('../driver/xhr')
;

function XHRLocalObject(method, url, payload /*, opts */) {
XhrDriver.call(this, method, url, payload, {
noCredentials: true
});
function XHRLocalObject(method, url, payload, opts) {
opts = opts || {};
opts.noCredentials = true;
XhrDriver.call(this, method, url, payload, opts);
}

inherits(XHRLocalObject, XhrDriver);
Expand Down
3 changes: 2 additions & 1 deletion tests/support/sockjs_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ function startServer(port, config, prefix) {
} else {
serve(req, res, function(err) {
var status = err ? err.statusCode : 404;
return res.writeHead(status).end();
res.writeHead(status);
res.end();
});
}
});
Expand Down