Skip to content

Commit fa18e1f

Browse files
code simplifications
1 parent 4c9ce6c commit fa18e1f

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

lib/request.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,8 @@ Request.prototype.end = function (s) {
156156

157157
Request.prototype.setTimeout = function(msecs, callback) {
158158
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-
}
159+
this.xhr.ontimeout = this.emit.bind(this, 'timeout');
160+
this.xhr.timeout = msecs;
173161
};
174162

175163
// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html

0 commit comments

Comments
 (0)