Merge pull request #2746 from mjameswh/http-connect-proxy-early-server-packet

HTTP CONNECT: handle early server packets
This commit is contained in:
Michael Lumish 2024-06-18 15:36:28 -07:00 committed by GitHub
commit d90ca240fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -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.