Skip to content

Commit 3c55b5b

Browse files
authored
Merge pull request #2777 from murgatroid99/grpc-js_1.10_backports
Backport #2746 and #2761 to 1.10.x
2 parents 97c4cda + 5ae5514 commit 3c55b5b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/grpc-js/src/http_proxy.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function getProxyInfo(): ProxyInfo {
8080
if (proxyUrl.username) {
8181
if (proxyUrl.password) {
8282
log(LogVerbosity.INFO, 'userinfo found in proxy URI');
83-
userCred = `${proxyUrl.username}:${proxyUrl.password}`;
83+
userCred = decodeURIComponent(`${proxyUrl.username}:${proxyUrl.password}`);
8484
} else {
8585
userCred = proxyUrl.username;
8686
}
@@ -233,6 +233,12 @@ export function getProxiedConnection(
233233
' through proxy ' +
234234
proxyAddressString
235235
);
236+
// The HTTP client may have already read a few bytes of the proxied
237+
// connection. If that's the case, put them back into the socket.
238+
// See https://github.com/grpc/grpc-node/issues/2744.
239+
if (head.length > 0) {
240+
socket.unshift(head);
241+
}
236242
if ('secureContext' in connectionOptions) {
237243
/* The proxy is connecting to a TLS server, so upgrade this socket
238244
* connection to a TLS connection.

0 commit comments

Comments
 (0)