Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(request_overrider): Set IncomingMessage.client for parity with real requests #1385

Merged
merged 1 commit into from Jan 19, 2019

Conversation

paulmelnikow
Copy link
Member

@paulmelnikow paulmelnikow commented Jan 18, 2019

ClientMessage.socket is an instance of our socket class. As that class’ constructor sets authorized to true on https requests, the code here that sets response.socket.authorized is pointless.

ClientMessage.client was deprecated in iojs 2.2 and per request/request#1615 but is still aliased: https://github.com/nodejs/node/blob/2e613a9c301165d121b19b86e382860323abc22f/lib/_http_incoming.js#L67

The old code, which sets response.client.authorized, is being replaced with new code which aliases response.client. This ensures that response.client and response.socket point to the same thing, which provides parity with a non-overridden request. This may help with compatibility with libraries which depend on that undocumented property, such as some very old versions of request.

This also ensures that response.client.authorized remains set, without needing to set it directly.

This is being changed now to remove two bits of unreachable code in the conditional.

… real requests

`ClientMessage.socket` is an instance of our `socket` class. As that class’ constructor sets `authorized` to `true` on `https` requests, the code here that sets `response.socket.authorized` is pointless.

`ClientMessage.client` was deprecated in iojs 2.2 and per request/request#1615  but is still aliased: https://github.com/nodejs/node/blob/2e613a9c301165d121b19b86e382860323abc22f/lib/_http_incoming.js#L67

The old code, which sets `response.client.authorized`, is being replaced with new code which aliases `response.client`. This ensures that `response.client` and `response.socket` point to the same thing, which provides parity with a non-overridden request. This may help with compatibility with libraries which depend on that undocumented property, such as some very old versions of `request`.

This also ensures that `response.client.authorized` remains set, without needing to set it directly.

This is being changed now to remove two bits of unreachable code in the conditional.
Copy link
Member

@RichardLitt RichardLitt left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

fascinating

@gr2m gr2m merged commit dc71a3b into beta Jan 19, 2019
@gr2m gr2m deleted the set-socket branch January 19, 2019 03:03
@nockbot
Copy link
Collaborator

nockbot commented Jan 19, 2019

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

The release is available on:

Your semantic-release bot 📦🚀

@nockbot
Copy link
Collaborator

nockbot commented Aug 13, 2019

🎉 This PR is included in version 11.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants