Skip to content

fix: request.end accepted arguments#1591

Merged
paulmelnikow merged 2 commits intonock:betafrom
mastermatt:bug/request-end-args
Jul 7, 2019
Merged

fix: request.end accepted arguments#1591
paulmelnikow merged 2 commits intonock:betafrom
mastermatt:bug/request-end-args

Conversation

@mastermatt
Copy link
Copy Markdown
Member

Fixes #1549

The method now correctly accepts all the permutations allowed.

request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.

I'm making this change it's own commit so I have a place to comment the
findings.

Digging through Node git history, I found the change that created the
breaking change in nock (ref nock PR 929).
nodejs/node@a10bdb5#diff-286202fdbdd74ede6f5f5334b6176b5cL779

Before Node v8, `OutgoingMessage`, which is extended by `ClientRequest`,
would literally do what it says in the docs if data was provided. It
would call `this.write(data, encoding)`. This meant that nock could wrap
only the `write` method when recording and gather all the chunks even if
the last chunk was sent to `end`. But, the above changed that to call an
internal function dual used by `end` and `write`.
Fixes nock#1549

The method now correctly accepts all the permutations allowed.
request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.
@mastermatt mastermatt changed the title fix: request.end accepted arguments. fix: request.end accepted arguments Jun 21, 2019
Copy link
Copy Markdown
Member

@paulmelnikow paulmelnikow left a comment

Choose a reason for hiding this comment

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

💯

@nockbot
Copy link
Copy Markdown
Collaborator

nockbot commented Jul 7, 2019

🎉 This PR is included in version 11.0.0-beta.21 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mastermatt mastermatt deleted the bug/request-end-args branch July 8, 2019 13:10
@nockbot
Copy link
Copy Markdown
Collaborator

nockbot commented Aug 12, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

gr2m pushed a commit that referenced this pull request Sep 4, 2019
* Fix typo about wrapping request.end.

I'm making this change it's own commit so I have a place to comment the
findings.

Digging through Node git history, I found the change that created the
breaking change in nock (ref nock PR 929).
nodejs/node@a10bdb5#diff-286202fdbdd74ede6f5f5334b6176b5cL779

Before Node v8, `OutgoingMessage`, which is extended by `ClientRequest`,
would literally do what it says in the docs if data was provided. It
would call `this.write(data, encoding)`. This meant that nock could wrap
only the `write` method when recording and gather all the chunks even if
the last chunk was sent to `end`. But, the above changed that to call an
internal function dual used by `end` and `write`.

* fix: request.end accepted arguments.

Fixes #1549

The method now correctly accepts all the permutations allowed.
request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.
gr2m pushed a commit that referenced this pull request Sep 4, 2019
* Fix typo about wrapping request.end.

I'm making this change it's own commit so I have a place to comment the
findings.

Digging through Node git history, I found the change that created the
breaking change in nock (ref nock PR 929).
nodejs/node@a10bdb5#diff-286202fdbdd74ede6f5f5334b6176b5cL779

Before Node v8, `OutgoingMessage`, which is extended by `ClientRequest`,
would literally do what it says in the docs if data was provided. It
would call `this.write(data, encoding)`. This meant that nock could wrap
only the `write` method when recording and gather all the chunks even if
the last chunk was sent to `end`. But, the above changed that to call an
internal function dual used by `end` and `write`.

* fix: request.end accepted arguments.

Fixes #1549

The method now correctly accepts all the permutations allowed.
request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.
gr2m pushed a commit that referenced this pull request Sep 5, 2019
* Fix typo about wrapping request.end.

I'm making this change it's own commit so I have a place to comment the
findings.

Digging through Node git history, I found the change that created the
breaking change in nock (ref nock PR 929).
nodejs/node@a10bdb5#diff-286202fdbdd74ede6f5f5334b6176b5cL779

Before Node v8, `OutgoingMessage`, which is extended by `ClientRequest`,
would literally do what it says in the docs if data was provided. It
would call `this.write(data, encoding)`. This meant that nock could wrap
only the `write` method when recording and gather all the chunks even if
the last chunk was sent to `end`. But, the above changed that to call an
internal function dual used by `end` and `write`.

* fix: request.end accepted arguments.

Fixes #1549

The method now correctly accepts all the permutations allowed.
request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.
juninmd pushed a commit to juninmd/nock that referenced this pull request Mar 21, 2026
* Fix typo about wrapping request.end.

I'm making this change it's own commit so I have a place to comment the
findings.

Digging through Node git history, I found the change that created the
breaking change in nock (ref nock PR 929).
nodejs/node@a10bdb5#diff-286202fdbdd74ede6f5f5334b6176b5cL779

Before Node v8, `OutgoingMessage`, which is extended by `ClientRequest`,
would literally do what it says in the docs if data was provided. It
would call `this.write(data, encoding)`. This meant that nock could wrap
only the `write` method when recording and gather all the chunks even if
the last chunk was sent to `end`. But, the above changed that to call an
internal function dual used by `end` and `write`.

* fix: request.end accepted arguments.

Fixes nock#1549

The method now correctly accepts all the permutations allowed.
request.end(data, encoding, callback)
request.end(data, callback)
request.end(data, encoding)
request.end(data)
request.end(callback)
request.end()

And a few tests were added to ensure all cases are explicitly covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants