Skip to content

HTTP inbound: Forward short 100 Continue responses promptly - #7298

Merged
RPRX merged 4 commits into
XTLS:mainfrom
Eljees:n/fix-http-continue-forwarding
Oct 31, 2026
Merged

RPRX merged 4 commits into
XTLS:mainfrom
Eljees:n/fix-http-continue-forwarding

Conversation

@Eljees

@Eljees Eljees commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

A minimal 100 Continue response must be forwarded before the client sends its body. Read the HTTP status prefix before inspecting the currently buffered response, then keep the adaptive peek of up to 56 buffered bytes. A partial first read containing only H must not cause the interim response to be treated as the final response.

The existing final-response test now reads its input one byte at a time. On the preceding implementation it returns status 100 instead of 200; with the minimum-prefix read it forwards Continue and returns the final response. The separate fixture removed during review remains removed.

Validation of the latest change:

  • Windows Go 1.27.3 and Linux Go 1.27.1: all tests in ./proxy/http ./proxy/socks ./common/protocol/http (11 leaf tests), plus seven HTTP scenarios selected by ^Test(Http|HTTP) in ./testing/scenarios, pass. Linux runs both scopes with -race; the upstream scenario helper builds ordinary child Xray binaries.
  • Four actual CLI cases against a synthetic loopback origin pass, including a status prefix split across writes. The preceding code loses the final response in that case, while the three controls pass. The test-suite regression uses a deterministic OneByteReader without timing.
  • Vet for the three packages, main builds, repository format and git diff --check pass.
  • The preceding full Windows CI run failed in TestSudokuE2ETemp/hysteria2/prefer_ascii with a Sudoku decode error. The HTTP tests passed in that run; this change does not claim to repair the Sudoku failure.

AI-assisted implementation and tests, separately reviewed and checked against the reproduced behavior.

Eljees and others added 3 commits October 30, 2026 23:41
Avoid waiting beyond the status prefix before forwarding an interim response. A client waiting for Continue cannot send its body while the origin waits for that body. Add a regression that withholds the final response until the interim response is forwarded.

Assisted-by: Codex
Signed-off-by: Eljees <3.14hell@gmail.com>
Removed the TestReadResponseAndHandle100ContinueForwardsBeforeFinalResponse test and related responseReaderFunc type.
Updated the peek size for reading response in readResponseAndHandle100Continue function.
@RPRX

RPRX commented Oct 31, 2026

Copy link
Copy Markdown
Member

@Fangliding 先执行 r.Peek(1) 是有啥说法吗

A fragmented first read can contain less than the status prefix. Wait for that prefix before the adaptive buffered peek, so a 100 Continue response is forwarded before parsing the final response. Exercise fragmentation in the existing response test.

Assisted-by: Codex
Signed-off-by: Eljees <3.14hell@gmail.com>
@Fangliding

Copy link
Copy Markdown
Member

先读一次再取出缓存中字节 应该不会有这个header都要拆开发的请求
改peek12就12吧 随便了

@RPRX
RPRX merged commit bc7c895 into XTLS:main Oct 31, 2026
39 checks passed
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.

3 participants