feat(http2): add synchronous HTTP/2 transport over TLS #10167

Merged
Felipebmaitan merged 5 commits from upstream-pr/10167 into main 2026-10-26 18:38:17 +00:00
Felipebmaitan commented 2026-10-23 11:54:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-23T11:54:44Z.


What

Sending a libSceHttp2 request currently never contacts a server. This adds a synchronous HTTPS request path for version 3 with strict ALPN h2, using nghttp2 1.70.0 pinned as a source-built submodule. SendRequest uploads until completion or an early final response and receives final response headers; ReadData streams the response with bounded buffering and HTTP/2 flow control. Status and Content-Length come from the peer. Request headers and supported settings are copied from the template.

Final responses stop the upload without discarding response status, Content-Length or body. Response END_STREAM is tracked independently of the request half, and a NO_ERROR reset is accepted only after a complete response, following RFC 9113 section 8.1. Automatic proxy flags 0 and 1 connect directly, matching libSceNetCtl's advertised proxy-off configuration; other values throw. On Windows the transport starts networking through libSceNet before submitting DNS work.

Contexts enforce a connection cap. Request/template/context deletion cancels active I/O, waits for the operation to quiesce, and releases socket/TLS resources before returning. Abort and resolve/connect/send/receive/overall deadlines stop blocked operations, including an upload waiting for WINDOW_UPDATE. DNS has two host workers and an eight-job queue; abandoning a request does not cancel libc's underlying lookup. A small SslRead_nid_no_patch bridge keeps the short SSL read import compatible with Windows NID patching.

Async send/read/wait and equeue completion remain unimplemented: the old immediate offline completion used an unknown event type. Raw response-header serialization, HTTP/1.x and ALPN fallback, cleartext HTTP/2, connection reuse/multiplexing, CONNECT, trailers, automatic redirect/authentication handling, cookie storage, gzip inflation and additional TLS controls also throw. Unknown console error mappings throw instead of returning guessed SCE errors. HTTP allocations are not charged to the context pool, so the live-context pool-stats query throws rather than reporting zero usage. These limits are recorded in docs/dev/debt/libSceHttp2.md.

Default TLS trust remains a limitation: fresh libSceSsl contexts have no roots. This branch verifies against explicitly loaded authorities and does not disable checks to make public HTTPS succeed. Shared system-root loading belongs to #11134 and the stacked #11145; the reason for keeping it out of this slice is now explicit in the debt file. Stock callers that load no roots are not unblocked by this PR alone.

Contract evidence:

  • SharpProspero's pinned HTTP2 bindings supply version values, string methods, header modes, content-length kinds, timeout units and certificate-check flags. prosper records the method argument as an integer instead; this change retains the repository's string declaration and records the disagreement.
  • RFC 9113 sections 3, 5, 6 and 8 and the pinned nghttp2 API define wire negotiation, framing, HPACK and flow control.
  • prosper's module-analysis report supports propagation of raw libSceNet connect errors. It does not establish every exported error path.

No PS5 hardware, new dumps, title run or console measurements were used. Public compatibility contracts and loopback fixtures are the evidence for this slice.

Overlap review: #9598 still changes the same teardown functions and remains a sequencing dependency. This transport removes the offline completion queues, so its allocation-failure test cannot be applied unchanged; the combined branch has not been built. #11145 is already stacked on this PR and covers proxy, DNS and default trust: this update folds in the proxy/DNS fixes with targeted regressions; the follow-up must drop those overlapping hunks when rebased and retain its system-root work. #11134 supplies the same SSL trust hook for libSceHttp and duplicates the identical SSL read bridge; the later merge must retain a single bridge definition. #10534 and #10536 modify cookie/option bookkeeping; #11470 adds WebSocket handling. These open changes are not included here. The refreshed overlap scan reports those same HTTP2 changes; its comparison against this PR's old published head is a self-comparison after rebase. Manual inspection of #674, #1835, #5021, #9536 and #9571 found independent imgui, capstone/pyelftools/ps5link and libressl submodule entries, with no nghttp2 duplication. The scan used main a6bd8f957f; the final main refresh changes no files in this PR. There is still merge coordination to finish before merging these open changes. This work stays separate from NGS2 #10127.

Tested

Windows 11 Pro 10.0.26200; WinLibs GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON, bundled dependencies, a dedicated worktree build.

Validated source head: d07024f3cfc90862431c7992a1b8d35dd6384472; main base: 518d36eaec0ac37870a17b465bedb5551be91b42. The canonical-header conflicts were resolved, retaining main's public declarations and using those headers in the transport and tests.

  • Full all-target Windows build: passed after the initial rebase and again after the final main refresh.
  • Final focused runtime selection (all HTTP2/SSL/network tests, pool stats, existing libSceHttp regressions and patched libraries): 70/70 passed, zero skipped, 13.51 seconds.
  • The early-response and first-network-DNS regressions each passed 20 consecutive runs. The early fixture sends 413 before the upload is released, checks status, Content-Length, partial reads and EOF, and verifies the upload stays within its initial flow-control window. Cases cover an open request half, NO_ERROR reset, empty body, a 200,000-byte streamed body, and rejection of a reset before response completion.
  • Negative control: built the same new fixtures against the previous transport source. Both failed: the early response did not complete before upload release; fresh-process Windows DNS threw. The fixed source was restored and recompiled before the green runs.
  • Conventions, main-sync, whitespace and public-header audit: passed; main-sync reports zero commits behind and a clean merge. Test registration: 1,397 test executable targets, none built and unregistered.

The original 42 transport scenarios remain covered, including phase/overall deadlines, cancellation and concurrent request/template/context teardown. The bookkeeping test also accepts proxy flag 1, rejects unsupported flag values, and checks that unsupported async operations do not manufacture equeue events. All transport fixtures use controlled loopback endpoints and existing synthetic certificates. No external service is a test dependency. No Linux, console or title run is claimed. The earlier full-suite result in the PR history belongs to the older base; this update does not present it as validation of the rebased head.

Commands (supported WinLibs and Git for Windows on PATH):

cmake --build build --target guest_http2_tests guest_http2_transport_tests guest_memory_pool_stats_tests --parallel 10
cmake --build build --parallel 12
ctest --test-dir build -R "^(guest_http2(_.*)?|guest_ssl(_.*)?|guest_net_.*|net_.*|guest_sce_net(_.*)?|guest_memory_pool_stats|guest_http(_response_header|_options)?|patched_libraries|public_headers)$" --output-on-failure -j 4
ctest --test-dir build -R "^guest_http2_(early_response|dns_first)$" --repeat until-fail:20 --output-on-failure
python tools/check_conventions.py --base origin/main
python tools/check_main_sync.py --base origin/main --strict
python tools/check_test_registration.py build
python tools/pr_overlap.py --branch feat/http2-transport --repo boykopovar/AnyPS5 --jobs 8
git diff origin/main...HEAD --check

Checklist

  • Based on current main; no other open PR implements the same functions (known shared implementations and merge sequencing are disclosed in Overlap review above)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #9598
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4982326588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10167). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-23T11:54:44Z. --- ### What Sending a libSceHttp2 request currently never contacts a server. This adds a synchronous HTTPS request path for version 3 with strict ALPN `h2`, using nghttp2 1.70.0 pinned as a source-built submodule. `SendRequest` uploads until completion or an early final response and receives final response headers; `ReadData` streams the response with bounded buffering and HTTP/2 flow control. Status and Content-Length come from the peer. Request headers and supported settings are copied from the template. Final responses stop the upload without discarding response status, Content-Length or body. Response END_STREAM is tracked independently of the request half, and a NO_ERROR reset is accepted only after a complete response, following [RFC 9113 section 8.1](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.1). Automatic proxy flags 0 and 1 connect directly, matching libSceNetCtl's advertised proxy-off configuration; other values throw. On Windows the transport starts networking through libSceNet before submitting DNS work. Contexts enforce a connection cap. Request/template/context deletion cancels active I/O, waits for the operation to quiesce, and releases socket/TLS resources before returning. Abort and resolve/connect/send/receive/overall deadlines stop blocked operations, including an upload waiting for WINDOW_UPDATE. DNS has two host workers and an eight-job queue; abandoning a request does not cancel libc's underlying lookup. A small `SslRead_nid_no_patch` bridge keeps the short SSL read import compatible with Windows NID patching. Async send/read/wait and equeue completion remain unimplemented: the old immediate offline completion used an unknown event type. Raw response-header serialization, HTTP/1.x and ALPN fallback, cleartext HTTP/2, connection reuse/multiplexing, CONNECT, trailers, automatic redirect/authentication handling, cookie storage, gzip inflation and additional TLS controls also throw. Unknown console error mappings throw instead of returning guessed SCE errors. HTTP allocations are not charged to the context pool, so the live-context pool-stats query throws rather than reporting zero usage. These limits are recorded in `docs/dev/debt/libSceHttp2.md`. Default TLS trust remains a limitation: fresh libSceSsl contexts have no roots. This branch verifies against explicitly loaded authorities and does not disable checks to make public HTTPS succeed. Shared system-root loading belongs to #11134 and the stacked #11145; the reason for keeping it out of this slice is now explicit in the debt file. Stock callers that load no roots are not unblocked by this PR alone. Contract evidence: - [SharpProspero's pinned HTTP2 bindings](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Interop/Net/Http2.cs) supply version values, string methods, header modes, content-length kinds, timeout units and certificate-check flags. [prosper](https://github.com/mattias800/prosper/blob/b1bec57186a0/prosper/src/hle/net/hle_http2.cpp) records the method argument as an integer instead; this change retains the repository's string declaration and records the disagreement. - [RFC 9113 sections 3, 5, 6 and 8](https://www.rfc-editor.org/rfc/rfc9113.html) and the pinned nghttp2 API define wire negotiation, framing, HPACK and flow control. - [prosper's module-analysis report](https://github.com/mattias800/prosper/issues/2894) supports propagation of raw libSceNet connect errors. It does not establish every exported error path. No PS5 hardware, new dumps, title run or console measurements were used. Public compatibility contracts and loopback fixtures are the evidence for this slice. Overlap review: #9598 still changes the same teardown functions and remains a sequencing dependency. This transport removes the offline completion queues, so its allocation-failure test cannot be applied unchanged; the combined branch has not been built. #11145 is already stacked on this PR and covers proxy, DNS and default trust: this update folds in the proxy/DNS fixes with targeted regressions; the follow-up must drop those overlapping hunks when rebased and retain its system-root work. #11134 supplies the same SSL trust hook for libSceHttp and duplicates the identical SSL read bridge; the later merge must retain a single bridge definition. #10534 and #10536 modify cookie/option bookkeeping; #11470 adds WebSocket handling. These open changes are not included here. The refreshed overlap scan reports those same HTTP2 changes; its comparison against this PR's old published head is a self-comparison after rebase. Manual inspection of #674, #1835, #5021, #9536 and #9571 found independent imgui, capstone/pyelftools/ps5link and libressl submodule entries, with no nghttp2 duplication. The scan used main `a6bd8f957f`; the final main refresh changes no files in this PR. There is still merge coordination to finish before merging these open changes. This work stays separate from NGS2 #10127. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Pro 10.0.26200; WinLibs GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON, bundled dependencies, a dedicated worktree build. Validated source head: `d07024f3cfc90862431c7992a1b8d35dd6384472`; main base: `518d36eaec0ac37870a17b465bedb5551be91b42`. The canonical-header conflicts were resolved, retaining main's public declarations and using those headers in the transport and tests. - Full all-target Windows build: passed after the initial rebase and again after the final main refresh. - Final focused runtime selection (all HTTP2/SSL/network tests, pool stats, existing libSceHttp regressions and patched libraries): **70/70 passed, zero skipped, 13.51 seconds**. - The early-response and first-network-DNS regressions each passed 20 consecutive runs. The early fixture sends 413 before the upload is released, checks status, Content-Length, partial reads and EOF, and verifies the upload stays within its initial flow-control window. Cases cover an open request half, NO_ERROR reset, empty body, a 200,000-byte streamed body, and rejection of a reset before response completion. - Negative control: built the same new fixtures against the previous transport source. Both failed: the early response did not complete before upload release; fresh-process Windows DNS threw. The fixed source was restored and recompiled before the green runs. - Conventions, main-sync, whitespace and public-header audit: passed; main-sync reports zero commits behind and a clean merge. Test registration: 1,397 test executable targets, none built and unregistered. The original 42 transport scenarios remain covered, including phase/overall deadlines, cancellation and concurrent request/template/context teardown. The bookkeeping test also accepts proxy flag 1, rejects unsupported flag values, and checks that unsupported async operations do not manufacture equeue events. All transport fixtures use controlled loopback endpoints and existing synthetic certificates. No external service is a test dependency. No Linux, console or title run is claimed. The earlier full-suite result in the PR history belongs to the older base; this update does not present it as validation of the rebased head. Commands (supported WinLibs and Git for Windows on PATH): ```text cmake --build build --target guest_http2_tests guest_http2_transport_tests guest_memory_pool_stats_tests --parallel 10 cmake --build build --parallel 12 ctest --test-dir build -R "^(guest_http2(_.*)?|guest_ssl(_.*)?|guest_net_.*|net_.*|guest_sce_net(_.*)?|guest_memory_pool_stats|guest_http(_response_header|_options)?|patched_libraries|public_headers)$" --output-on-failure -j 4 ctest --test-dir build -R "^guest_http2_(early_response|dns_first)$" --repeat until-fail:20 --output-on-failure python tools/check_conventions.py --base origin/main python tools/check_main_sync.py --base origin/main --strict python tools/check_test_registration.py build python tools/pr_overlap.py --branch feat/http2-transport --repo boykopovar/AnyPS5 --jobs 8 git diff origin/main...HEAD --check ``` ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions (known shared implementations and merge sequencing are disclosed in Overlap review above) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #9598 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-23 11:56:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:56:31Z.

Review: DISMISSED


Reviewed exact head 98dda7cbedc567bedeaff4e255e7fce793b4d10f. One HTTP/2 behavior is missing: a peer may send a final response before consuming the request body (for example, reject a large upload with 413). In Request::Send, if the server ends the stream while uploadOffset < uploadSize, End sets ended and the next loop iteration fails Require(!state->ended, "response ended before upload completed"). So a valid final response is turned into an exception rather than making its status/body available. The 42 loopback scenarios cover a flow-control-blocked upload that is stalled/cancelled, but I found no early-final-response case. Please handle the peer’s final response/stream close without treating it as a transport failure, and add a server fixture that returns a final status before releasing the blocked upload; assert SendRequest and status/read behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627869307 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10167#pullrequestreview-5627869307). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T11:56:31Z. **Review:** DISMISSED --- Reviewed exact head `98dda7cbedc567bedeaff4e255e7fce793b4d10f`. One HTTP/2 behavior is missing: a peer may send a final response before consuming the request body (for example, reject a large upload with 413). In `Request::Send`, if the server ends the stream while `uploadOffset < uploadSize`, `End` sets `ended` and the next loop iteration fails `Require(!state->ended, "response ended before upload completed")`. So a valid final response is turned into an exception rather than making its status/body available. The 42 loopback scenarios cover a flow-control-blocked upload that is stalled/cancelled, but I found no early-final-response case. Please handle the peer’s final response/stream close without treating it as a transport failure, and add a server fixture that returns a final status before releasing the blocked upload; assert `SendRequest` and status/read behavior.
adriadam10 commented 2026-10-26 15:11:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-26T15:11:02Z.

Review: CHANGES_REQUESTED


Thanks for the transport work. Points to address before this can merge:

  • Transport.cpp:571: a peer that ends the stream with a final response before consuming the upload (e.g. 413) makes Send throw "response ended before upload completed". This is the open request from @MarcZX10 on this head. Treat the peer's final response as a valid result (status/headers/body readable, stop uploading) and add a loopback fixture that returns a final status while the upload is blocked, asserting SendRequest and status/read.
  • Export.cpp:125: sceHttp2CreateTemplate throws for is_auto_proxy_conf != 0. Titles that use libSceHttp2 (RetroArch PPSA99169, PS5LM PPSA99575, Porpoise PPSA99764, OliSe PPSA01153, per @p3n1cillin) all pass 1, so they now abort at template creation where main only failed the send. AnyPS5 has no system proxy, so accepting the flag and connecting directly looks like the right behaviour; please decide and record it in docs/dev/debt/libSceHttp2.md.
  • TLS trust: every libSceSsl context starts with no trust anchors, and those titles install no SSL callback, so real HTTPS fails with TLS failed. @p3n1cillin reports a working approach (system CA list per connection) in their comment; please handle default trust or state in the debt file why it is out of scope.
  • Windows: DNS fails with "console error mapping is unknown" if nothing has called WSAStartup yet (libSceNet only does it on its first socket call). Ensure Winsock is started before resolving.
  • The branch conflicts with main (Export.cpp, GuestHttp2.cpp, GuestMemoryPoolStats.cpp, after the canonical-header refactor) and depends on #9598, which is still open. Please rebase once that is settled and rerun the HTTP/2, pool-stats and SSL tests.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5654300998 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10167#pullrequestreview-5654300998). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-26T15:11:02Z. **Review:** CHANGES_REQUESTED --- Thanks for the transport work. Points to address before this can merge: - `Transport.cpp:571`: a peer that ends the stream with a final response before consuming the upload (e.g. 413) makes `Send` throw "response ended before upload completed". This is the open request from @MarcZX10 on this head. Treat the peer's final response as a valid result (status/headers/body readable, stop uploading) and add a loopback fixture that returns a final status while the upload is blocked, asserting `SendRequest` and status/read. - `Export.cpp:125`: `sceHttp2CreateTemplate` throws for `is_auto_proxy_conf != 0`. Titles that use libSceHttp2 (RetroArch PPSA99169, PS5LM PPSA99575, Porpoise PPSA99764, OliSe PPSA01153, per @p3n1cillin) all pass 1, so they now abort at template creation where `main` only failed the send. AnyPS5 has no system proxy, so accepting the flag and connecting directly looks like the right behaviour; please decide and record it in `docs/dev/debt/libSceHttp2.md`. - TLS trust: every libSceSsl context starts with no trust anchors, and those titles install no SSL callback, so real HTTPS fails with `TLS failed`. @p3n1cillin reports a working approach (system CA list per connection) in their comment; please handle default trust or state in the debt file why it is out of scope. - Windows: DNS fails with "console error mapping is unknown" if nothing has called `WSAStartup` yet (libSceNet only does it on its first socket call). Ensure Winsock is started before resolving. - The branch conflicts with `main` (`Export.cpp`, `GuestHttp2.cpp`, `GuestMemoryPoolStats.cpp`, after the canonical-header refactor) and depends on #9598, which is still open. Please rebase once that is settled and rerun the HTTP/2, pool-stats and SSL tests.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!10167
No description provided.