Skip to content

Commit 3e89fdc

Browse files
committed
HTTP CONNECT: handle early server packets
1 parent 15b7d4d commit 3e89fdc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/grpc-js/src/http_proxy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)