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

Add support for additional transport headers #521

Open
wants to merge 1 commit 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
24 changes: 12 additions & 12 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.

4 changes: 2 additions & 2 deletions lib/info-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:info-ajax');
}

function InfoAjax(url, AjaxObject) {
function InfoAjax(url, AjaxObject, options) {
EventEmitter.call(this);

var self = this;
var t0 = +new Date();
this.xo = new AjaxObject('GET', url);
this.xo = new AjaxObject('GET', url, null, options);

this.xo.once('finish', function(status, text) {
var info, rtt;
Expand Down
18 changes: 9 additions & 9 deletions lib/info-receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,44 @@ if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:info-receiver');
}

function InfoReceiver(baseUrl, urlInfo) {
function InfoReceiver(baseUrl, urlInfo, options) {
debug(baseUrl);
var self = this;
EventEmitter.call(this);

setTimeout(function() {
self.doXhr(baseUrl, urlInfo);
self.doXhr(baseUrl, urlInfo, options);
}, 0);
}

inherits(InfoReceiver, EventEmitter);

// TODO this is currently ignoring the list of available transports and the whitelist

InfoReceiver._getReceiver = function(baseUrl, url, urlInfo) {
InfoReceiver._getReceiver = function(baseUrl, url, urlInfo, options) {
// determine method of CORS support (if needed)
if (urlInfo.sameOrigin) {
return new InfoAjax(url, XHRLocal);
return new InfoAjax(url, XHRLocal, options);
}
if (XHRCors.enabled) {
return new InfoAjax(url, XHRCors);
return new InfoAjax(url, XHRCors, options);
}
if (XDR.enabled && urlInfo.sameScheme) {
return new InfoAjax(url, XDR);
return new InfoAjax(url, XDR, options);
}
if (InfoIframe.enabled()) {
return new InfoIframe(baseUrl, url);
}
return new InfoAjax(url, XHRFake);
return new InfoAjax(url, XHRFake, options);
};

InfoReceiver.prototype.doXhr = function(baseUrl, urlInfo) {
InfoReceiver.prototype.doXhr = function(baseUrl, urlInfo, options) {
var self = this
, url = urlUtils.addPath(baseUrl, '/info')
;
debug('doXhr', url);

this.xo = InfoReceiver._getReceiver(baseUrl, url, urlInfo);
this.xo = InfoReceiver._getReceiver(baseUrl, url, urlInfo, options);

this.timeoutRef = setTimeout(function() {
debug('timeout');
Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function SockJS(url, protocols, options) {
, sameScheme: urlUtils.isSchemeEqual(this.url, loc.href)
};

this._ir = new InfoReceiver(this.url, this._urlInfo);
this._ir = new InfoReceiver(this.url, this._urlInfo, options);
this._ir.once('finish', this._receiveInfo.bind(this));
}

Expand Down