added ability to define request timeout

This commit is contained in:
tigerbot 2017-10-25 14:12:41 -06:00
parent 815ba04d37
commit 081b2a23de
2 changed files with 10 additions and 1 deletions

View File

@ -821,7 +821,7 @@
var logoutReq = OAUTH3.urls.logout(
directives
, { client_id: (opts.client_id || opts.client_uri || OAUTH3.clientUri(OAUTH3._browser.window.location))
, windowType: 'popup' // we'll figure out background later
, windowType: 'popup' // TODO: figure out background later
, broker: opts.broker
//, state: opts._state
, debug: opts.debug
@ -964,6 +964,11 @@
, status: xhr.status
});
};
xhr.ontimeout = function () {
var err = new Error('ETIMEDOUT');
err.code = 'ETIMEDOUT';
reject(err);
};
if (preq.progress) {
xhr.upload.onprogress = function (ev) {
@ -981,6 +986,9 @@
// For assets.example.com/assets
xhr.withCredentials = true;
if (preq.timeout) {
xhr.timeout = preq.timeout;
}
if (preq.data) {
headers['Content-Type'] = 'application/json'; // TODO XXX TODO utf8
}

View File

@ -44,6 +44,7 @@ OAUTH3._node.request = function(preq/*, _sys*/) {
method: preq.method
, url: preq.url || preq.uri
, headers: preq.headers
, timeout: preq.timeout || undefined
, json: preq.data || preq.body || preq.json || undefined // TODO which to use?
, formData: preq.formData || undefined
};