We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c9ce6c commit fa18e1fCopy full SHA for fa18e1f
lib/request.js
@@ -156,20 +156,8 @@ Request.prototype.end = function (s) {
156
157
Request.prototype.setTimeout = function(msecs, callback) {
158
if (callback) this.once('timeout', callback);
159
-
160
- var self = this;
161
- function emitTimeout() {
162
- self.emit('timeout');
163
- }
164
165
- // set and handle the timeout signals on xhr
166
- if (this.xhr) {
167
- if (this.timeoutCb) {
168
- this.xhr.ontimeout = this.timeoutCb;
169
170
- this.timeoutCb = emitTimeout;
171
- this.xhr.timeout = msecs;
172
+ this.xhr.ontimeout = this.emit.bind(this, 'timeout');
+ this.xhr.timeout = msecs;
173
};
174
175
// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
0 commit comments