Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,6 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
return false;
}

var self = this;
function finish() {
self.emit('finish');
}

if (typeof callback === 'function')
this.once('finish', callback);

if (!this._header) {
if (data) {
if (typeof data === 'string')
Expand Down Expand Up @@ -581,6 +573,13 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
this.write(data, encoding);
}

if (typeof callback === 'function')
this.once('finish', callback);

var finish = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if better if in places like this you use const instead var

@originalfoo originalfoo Jun 23, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, will update PR shortly.

EDIT: Done.

this.emit('finish');
};

if (this._hasBody && this.chunkedEncoding) {
ret = this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
} else {
Expand Down