Skip to content
Open
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
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,12 @@ function _createXHR(options) {
xhr.ontimeout = errorFunc
xhr.open(method, uri, !sync, options.username, options.password)
//has to be after open
if(!sync) {
xhr.withCredentials = !!options.withCredentials
}
// Set withCredentials for both sync and async requests when explicitly requested.
// Previously this was guarded by `if (!sync)` to work around a Firefox crash
// when withCredentials was always forced on sync requests. Setting it only when
// the caller opts in (options.withCredentials is truthy) is safe in all modern
// browsers for both sync and async. See: https://github.com/naugtur/xhr/issues/168
xhr.withCredentials = !!options.withCredentials
// Cannot set timeout with sync request
// not setting timeout on the xhr object, because of old webkits etc. not handling that correctly
// both npm's request and jquery 1.x use this kind of timeout, so this is being consistent
Expand Down