提交 1695f5cf 编写于 作者: M mzabriskie

Adding support for timeout config

closes #56
上级 a7caa97c
......@@ -88,6 +88,11 @@ module.exports = function httpAdapter(resolve, reject, config) {
reject(err);
});
// Handle request timeout
req.setTimeout(config.timeout, function () {
req.abort();
});
// Send the request
req.end(data);
};
......@@ -36,6 +36,9 @@ module.exports = function xhrAdapter(resolve, reject, config) {
var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true);
// Set the request timeout in MS
request.timeout = config.timeout;
// Listen for ready state
request.onreadystatechange = function () {
if (request && request.readyState === 4) {
......
......@@ -47,6 +47,8 @@ module.exports = {
put: utils.merge(DEFAULT_CONTENT_TYPE)
},
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN'
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册