Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
http: gather code relating to finish event
Code relating to the `finish` event was split in to two areas of the
parent function. Gathered it together to clarify association within the
script.

Fixes #7295
  • Loading branch information
originalfoo committed Jun 22, 2016
commit 46b4a7fbc89616f3953574b24cdca8b49d7baf20
14 changes: 7 additions & 7 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,6 @@ OutgoingMessage.prototype.end = function(data, encoding, callback) {
return false;
}

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

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

if (!this._header) {
if (data) {
if (typeof data === 'string')
Expand Down Expand Up @@ -580,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

Copy link
Copy Markdown
Contributor Author

@originalfoo originalfoo Jun 23, 2016

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