feat(request_overrider): Set IncomingMessage.client
for parity with real requests
#1385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ClientMessage.socket
is an instance of oursocket
class. As that class’ constructor setsauthorized
totrue
onhttps
requests, the code here that setsresponse.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#L67The old code, which sets
response.client.authorized
, is being replaced with new code which aliasesresponse.client
. This ensures thatresponse.client
andresponse.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 ofrequest
.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.