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

Backport #2746 and #2761 to 1.10.x #2777

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/grpc-js/src/http_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function getProxyInfo(): ProxyInfo {
if (proxyUrl.username) {
if (proxyUrl.password) {
log(LogVerbosity.INFO, 'userinfo found in proxy URI');
userCred = `${proxyUrl.username}:${proxyUrl.password}`;
userCred = decodeURIComponent(`${proxyUrl.username}:${proxyUrl.password}`);
} else {
userCred = proxyUrl.username;
}
Expand Down Expand Up @@ -233,6 +233,12 @@ export function getProxiedConnection(
' through proxy ' +
proxyAddressString
);
// The HTTP client may have already read a few bytes of the proxied
// connection. If that's the case, put them back into the socket.
// See https://github.com/grpc/grpc-node/issues/2744.
if (head.length > 0) {
socket.unshift(head);
}
if ('secureContext' in connectionOptions) {
/* The proxy is connecting to a TLS server, so upgrade this socket
* connection to a TLS connection.
Expand Down