Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use .once() when listening for parser error

Also remove parser error listener when finished
  • Loading branch information...
commit 205dfd2e21c13407d89d3ed92dc2b44b987d962b 1 parent 975ea90
@mscdex mscdex authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 main.js
View
6 main.js
@@ -509,7 +509,7 @@ Request.prototype.start = function () {
self.req = self.httpModule.request(self, function (response) {
if (response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) {
- response.connection.on('error', self._parserErrorHandler)
+ response.connection.once('error', self._parserErrorHandler)
}
if (self._aborted) return
if (self._paused) response.pause()
@@ -677,7 +677,9 @@ Request.prototype.start = function () {
self.req.on('drain', function() {
self.emit('drain')
})
-
+ self.on('end', function() {
+ self.req.connection.removeListener('error', self._parserErrorHandler)
+ })
self.emit('request', self.req)
}

0 comments on commit 205dfd2

Please sign in to comment.
Something went wrong with that request. Please try again.