Skip to content

XHTTP: bound HTTP/1.1 packet uploads and stream request bodies - #7569

Closed
wywywywycloud wants to merge 1 commit into
XTLS:mainfrom
wywywywycloud:fix/xhttp-h1-upload-order
Closed

wywywywycloud wants to merge 1 commit into
XTLS:mainfrom
wywywywycloud:fix/xhttp-h1-upload-order

Conversation

@wywywywycloud

@wywywywycloud wywywywycloud commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Related to #7568. This branch targets HTTP/1.1 packet-up. See #7572 for HTTP/2 and #7571 for the queue budget.

Changes

Serializing a POST into a memory buffer could fire WroteRequest before a socket was connected. Later packets could run ahead while earlier packets were still waiting to be sent.

Use a separate HTTP/1.1 upload transport, wait for the socket write and account for the response before reusing the connection. Bound the outstanding sequence gap using the configured reorder window. Stream pooled buffers and allow stale-connection replay only while the body is unread.

The commit also fixes a Windows CI failure in the Sudoku/Hysteria2 integration test by binding the relay to an ephemeral UDP port and selecting the server port via UDP while the relay is bound.

Verification

OpenWrt 25.12.5 amd64 VM, two vCPUs, 256 MiB RAM, no swap, GOMEMLIMIT=28MiB, GOGC=30. The server was unmodified Xray v26.11.9. Each round uploaded 32 MiB plus 23 bytes times the stream index per VLESS/XHTTP packet-up stream. The receiver sent back the SHA-256 of each stream. Rounds ran in one client process with five-second pauses. Memory figures are sampled RssAnon, not total system memory.

This branch alone (769b2fe) passed 96/96 SHA-256 checks over plain HTTP/1.1 in three rounds of 32 parallel streams without an artificial RAM reservation. Peak RssAnon was 30.55 MiB. No failed uploads or server queue overflows appeared.

In the earlier 90 MiB reservation test from #7568, main (919d0ae) was OOM-killed after receiving 71,064,280 bytes. The same HTTP/1.1 fix before the test-only Windows change (7231a1d) completed the eight-then-32-stream workload with 6,068,247,104 bytes received. Separate plain and TLS HTTP/1.1 runs matched all eight digests each.

The splithttp package passed three times. Four HTTP/1.1 regression tests passed ten times with the race detector, covering response errors, out-of-order acknowledgements, stale-socket retry and blocked writes. Linux arm64 cross-build passed.

Combined low-memory check

The three single-commit branches (769b2fe, 3bc0585, 889c083) merged cleanly into tree 80efcd74215b16ccbac413eb811f75eb90a7b53c. With 90 MiB reserved in tmpfs and a 12 MiB available-memory stop threshold, each protocol ran six rounds of 32 concurrent streams without restarting the client between rounds.

Protocol SHA-256 matches Peak RssAnon Minimum available Elapsed incl. pauses
HTTP/1.1 192/192 21.82 MiB 20.59 MiB 103.69 s
HTTP/2 over TLS 192/192 26.82 MiB 15.51 MiB 102.99 s

A separate three-round HTTP/1.1 over TLS run passed 96/96 checks, with a 27.77 MiB peak RssAnon and 16.88 MiB minimum available. No run hit the guard, logged failed uploads or reported a server queue overflow. These are synthetic VM results. Physical ARM64 hardware was not tested.

Codex + Astra 6.2 was used for debbugging and assisted writing the code. The chat will not be included.

Use a separate HTTP/1.1 upload transport, respect the reorder window and stream pooled buffers with safe stale-connection retries. Cover blocked writes, response errors, ordering and replay.

Fix the Windows Hysteria2 integration test by binding the relay directly to an ephemeral UDP port and choosing the server port via UDP while the relay is bound.
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