From e7590295327b1bbd6dae812cf45f4c5c5b181985 Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Fri, 10 May 2024 16:17:06 -0400 Subject: [PATCH 1/2] HTTP CONNECT: handle early server packets --- packages/grpc-js/src/http_proxy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/grpc-js/src/http_proxy.ts b/packages/grpc-js/src/http_proxy.ts index 3e905c488..30eeb621e 100644 --- a/packages/grpc-js/src/http_proxy.ts +++ b/packages/grpc-js/src/http_proxy.ts @@ -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. From 5ae551445452ccf1db1d4ed8f3890f6b0dfc0c35 Mon Sep 17 00:00:00 2001 From: Brendan Myers Date: Wed, 29 May 2024 19:15:30 +1000 Subject: [PATCH 2/2] fix: add decoding for url encoded user credentials --- packages/grpc-js/src/http_proxy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/grpc-js/src/http_proxy.ts b/packages/grpc-js/src/http_proxy.ts index 30eeb621e..6fabf5025 100644 --- a/packages/grpc-js/src/http_proxy.ts +++ b/packages/grpc-js/src/http_proxy.ts @@ -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; }