-
Notifications
You must be signed in to change notification settings - Fork 616
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
Fix missing port in proxy CONNECT when using the default HTTPS port #2608
Fix missing port in proxy CONNECT when using the default HTTPS port #2608
Conversation
Indeed it works and solved us a problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable change, functionally, but it could be cleaner:
- I don't like "443" as a magic string. It would be better to export
DEFAULT_PORT
fromresolver-dns.ts
, and reference that here. - With nullish coalescing,
(targetHostPost.port != null ? targetHostPost.port : '443')
can be shortened totargetHostPort.port ?? 443
(or, integrating the previous point,targetHostPort.port ?? DEFAULT_PORT
). - Use string templates to make the string construction more concise:
`${targetHostPort.host}:${targetHostPort.port ?? DEFAULT_PORT}`
- You are constructing the same string twice, once for
options.path
and once forheaders.Host
. Instead create it once, assign it to a variable, and use that variable in the other two lines.
Yeah. Wasn't really sure what ECMAScript version this was targeting, but will do. |
One of the great things about TypeScript is that it will allow the use of ECMAScript features that are incompatible with the target, and it will transpile shims as necessary. The library currently uses typescript |
Yeah. Guess it was late when I debugged this, and didn't even notice I was in TypeScript 😋 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that looks good now. If you rebase the change onto the @grpc/grpc-js@1.9.x
branch and change the PR target, it will go out in the next patch release.
121ba8b
to
0854192
Compare
Rebased. |
This is now out in 1.9.10. |
When the target gRPC URI doesn't contain a port, and as such defaults to the default HTTPS port, the code didn't send the port as part of the
HTTP
CONNECT
request when a proxy is configured, leading to proxies rejected the request with a 400 Bad Request, as the request line is malformed.We saw this while using
firebase/firestore
which uses gRPC underneath by default, and connect to "firestore.googleapis.com" without a port by default.Contributed by courtesy of swimm.io