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

Replace '.client' with '.socket' as the former was deprecated in 2.2.0. #1615

Merged
merged 1 commit into from May 31, 2015
Merged

Replace '.client' with '.socket' as the former was deprecated in 2.2.0. #1615

merged 1 commit into from May 31, 2015

Conversation

ChALkeR
Copy link
Contributor

@ChALkeR ChALkeR commented May 31, 2015

Actually, it's not only deprecated, checking it with .hasOwnProperty('client') is broken in 2.2.0, but that's going to be fixed in 2.2.1.

See nodejs/node#1572 nodejs/node#1850 nodejs/io.js#1852/files

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

Travis errors exactly because it has version 2.2.0 that runs npm install that in turn uses request that is atm not compatible with 2.2.0.

@othiym23
Copy link
Contributor

that in turn uses request that is atm not compatible with 2.2.0

This is backwards – it's io.js that has introduced a breaking change in a minor version and is now incompatible with request, npm, and any other package that uses request's strictSSL checking.

This patch shouldn't be accepted until and unless it adds support for .client as well as .socket, because it's going to go from a situation where request (and npm) are broken for io.js 2.2.0 to a situation where request (and npm) are broken for io.js and Node.js everywhere else. While it's at it, somebody should figure out if using .hasOwnProperty() is absolutely necessary for this to work and replace it with a simple property presence test otherwise – .hasOwnProperty() seems unnecessarily stringent and is part of what made this bug so severe and unpredictable in the first place.

@thefourtheye
Copy link

if using .hasOwnProperty() is absolutely necessary for this to work

Exactly what I had in my mind too.

@simov
Copy link
Member

simov commented May 31, 2015

Yep both properties should be supported, and that should be implemented by simply converting the property to the one or the other before it's been used for the first time, in any of the contexts where it's used.

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

@othiym23 .socket is there from nodejs 0.1.90. How could this break anything?

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

This is backwards – it's io.js that has introduced a breaking change in a minor version and is now incompatible with request, npm, and any other package that uses request's strictSSL checking.

That is indeed a bug and will be fixed in 2.2.1, as already mentioned. But it would stil emit a deprecation warning.

@simov
Copy link
Member

simov commented May 31, 2015

@ChALkeR

res.client = res.client || res.socket

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

@simov Why? Just why? .client and .socket (and .connection) are there from nodejs version 0.1.90 and they were always the same object since then. Until .client got deprecated, of course.

Edit: ok. Not true for nodejs version 0.1.x (below 0.1.90): it had .client and .connection (as the same object), but didn't have .socket. And nodejs 0.1.x didn't have https support at all. And I guess that you don't support nodejs 0.1.x for other reasons =).

And setting to res.client as you proposed would still emit a deprecation warning, btw. Check the links above.

@othiym23
Copy link
Contributor

To summarize my discussion with @ChALkeR on IRC: my initial comment about just swapping the property names being insufficient was in error: since client is an alias for connection, the suggested change is fine and will fix request with io.js@2.2.0.

It shouldn't be necessary, though, because there's no compelling reason to have removed this property from the object in the first place (and any further discussion along those lines should probably be had over in nodejs/io.js anyway, as this point isn't really related to request). As such I'm +0 on this PR.

@simov
Copy link
Member

simov commented May 31, 2015

Thanks for pointing that out @othiym23 I was wondering if I'm missing out something, while I was catching up with the issue.

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

The deprecation was completely reverted in 2.2.1. When I was filing this PR, I assumed that the deprecation would be fixed instead (as nodejs/node#1852 was doing at that moment).

With this, there is no actual reason to merge this, except for using a (poorly) documented property instead of a non-documented one. If you want to merge this, I could change the commit message. If not, just close it.

@othiym23

will fix request with io.js@2.2.0.

I consider io.js@2.2.0 as broken. The purpose of this PR was not to fix the request module with io.js@2.2.0, but to make it not cause a deprecation warning in further versions. That is not applicable anymore.

simov added a commit that referenced this pull request May 31, 2015
Replace '.client' with '.socket' as the former was deprecated in 2.2.0.
@simov simov merged commit ab7062b into request:master May 31, 2015
@simov
Copy link
Member

simov commented May 31, 2015

I just saw that request is a bundled dependency in npm .. anyway 2.57 is out

@ChALkeR
Copy link
Contributor Author

ChALkeR commented May 31, 2015

Thanks.

paulmelnikow added a commit to nock/nock that referenced this pull request Jan 18, 2019
… 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 code to set `response.client.authorized` is being replaced with that aliasing. This ensures that `response.client` and `response.socket` point to the same thing, as is the case 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.
paulmelnikow added a commit to nock/nock that referenced this pull request Jan 18, 2019
… 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.
gr2m pushed a commit to nock/nock that referenced this pull request Jan 19, 2019
… 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.
gr2m pushed a commit to nock/nock that referenced this pull request Sep 4, 2019
… 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.
gr2m pushed a commit to nock/nock that referenced this pull request Sep 4, 2019
… 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.
gr2m pushed a commit to nock/nock that referenced this pull request Sep 5, 2019
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants