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 withCredentials option #614

Merged
merged 1 commit into from
Sep 13, 2019
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Exposed as `eio` in the browser standalone build.
will be used instead.
- `forceBase64` (`Boolean`): forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary.
- `enablesXDR` (`Boolean`): enables XDomainRequest for IE8 to avoid loading bar flashing with click sound. default to `false` because XDomainRequest has a flaw of not sending cookie.
- `withCredentials` (`Boolean`): defaults to `true`, whether to include credentials (cookies, authorization headers, TLS client certificates, etc.) with cross-origin XHR polling requests.
- `timestampRequests` (`Boolean`): whether to add the timestamp with each
transport request. Note: polling requests are always stamped unless this
option is explicitly set to `false` (`false`)
Expand Down
2 changes: 2 additions & 0 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function Socket (uri, opts) {
this.jsonp = false !== opts.jsonp;
this.forceBase64 = !!opts.forceBase64;
this.enablesXDR = !!opts.enablesXDR;
this.withCredentials = false !== opts.withCredentials;
this.timestampParam = opts.timestampParam || 't';
this.timestampRequests = opts.timestampRequests;
this.transports = opts.transports || ['polling', 'websocket'];
Expand Down Expand Up @@ -183,6 +184,7 @@ Socket.prototype.createTransport = function (name) {
jsonp: options.jsonp || this.jsonp,
forceBase64: options.forceBase64 || this.forceBase64,
enablesXDR: options.enablesXDR || this.enablesXDR,
withCredentials: options.withCredentials || this.withCredentials,
timestampRequests: options.timestampRequests || this.timestampRequests,
timestampParam: options.timestampParam || this.timestampParam,
policyPort: options.policyPort || this.policyPort,
Expand Down
1 change: 1 addition & 0 deletions lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function Transport (opts) {
this.agent = opts.agent || false;
this.socket = opts.socket;
this.enablesXDR = opts.enablesXDR;
this.withCredentials = opts.withCredentials;

// SSL options for Node.js client
this.pfx = opts.pfx;
Expand Down
4 changes: 3 additions & 1 deletion lib/transports/polling-xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ XHR.prototype.request = function (opts) {
opts.agent = this.agent || false;
opts.supportsBinary = this.supportsBinary;
opts.enablesXDR = this.enablesXDR;
opts.withCredentials = this.withCredentials;

// SSL options for Node.js client
opts.pfx = this.pfx;
Expand Down Expand Up @@ -150,6 +151,7 @@ function Request (opts) {
this.isBinary = opts.isBinary;
this.supportsBinary = opts.supportsBinary;
this.enablesXDR = opts.enablesXDR;
this.withCredentials = opts.withCredentials;
this.requestTimeout = opts.requestTimeout;

// SSL options for Node.js client
Expand Down Expand Up @@ -224,7 +226,7 @@ Request.prototype.create = function () {

// ie6 check
if ('withCredentials' in xhr) {
xhr.withCredentials = true;
xhr.withCredentials = this.withCredentials;
}

if (this.requestTimeout) {
Expand Down