Skip to content

fix: keep bytes that arrive with the HTTP proxy's CONNECT response - #3382

Merged
wwqgtxx merged 1 commit into
MetaCubeX:Alphafrom
gtoxlili:fix/http-connect-buffered-bytes
Oct 30, 2026
Merged

wwqgtxx merged 1 commit into
MetaCubeX:Alphafrom
gtoxlili:fix/http-connect-buffered-bytes

Conversation

@gtoxlili

Copy link
Copy Markdown

shakeHandContext reads the CONNECT response through a bufio.Reader and then drops the reader. If the proxy writes the target's first bytes right behind its 200 response, they can arrive in the same read and stay in the dropped buffer. Server-first protocols such as SSH or SMTP then lose their banner and the connection hangs.

The reader is now created in StreamConnContext and passed to the handshake. N.WarpConnWithBioReader puts the buffered bytes in front of the returned connection, and returns the connection unchanged when nothing is buffered.

To reproduce, put an HTTP proxy outbound in front of a server that speaks first, and have the proxy send HTTP/1.1 200 Connection established\r\n\r\n and the server's first bytes in one write. The client never receives those bytes.

@wwqgtxx
wwqgtxx merged commit 69c1631 into MetaCubeX:Alpha Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants