feat(libSceHttp): add synchronous HTTP request transport #9834
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9834"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by DoubleAAGuy on 2026-10-22T16:51:39Z.
What
Implement a synchronous HTTP/1.1 request path in
libSceHttpover the existinglibSceNetandlibSceSsllibraries. Connections and requests retain their URL/method and request headers;sceHttpSendRequestsends the request and parses response status/headers, whilesceHttpReadDatastreams fixed-length, chunked, or connection-close bodies. Status, content length, response headers, TLS verification callbacks, DNS/connect/I/O timeouts, and automatic redirects are wired into this path. DNS lookups use a bounded process-lifetime worker pool so the configured resolve deadline bounds the caller even though libcgetaddrinfocannot be cancelled; late results are discarded. Connect timeouts use a nonblocking socket pluslibSceNetepoll; cross-origin redirects drop caller-suppliedAuthorization,Proxy-Authorization,Cookie, andHostheaders.The concrete caller is Prospero Themes (
PPSA90210): its StoreHttpClient loadslibSceHttpandlibSceSsland uses GET/POST, request headers, TLS callbacks, response headers and body reads for its community store.Nonblocking requests and epoll completion events, request-side chunked transfer, persistent connection reuse, gzip, cookies/authentication and proxy routing remain unsupported. TLS uses
libSceSslverification and the caller's verify callback, including PPSA90210's accept-certificate callback; other HTTP-specific TLS flags remain unimplemented.Tested
AArch64 Linux host; focused x86-64 build and execution under QEMU user emulation:
libc,libkernel,libSceNetCtl,libSceNet,libSceSsl,libSceHttp, and committed HTTP test targets using GCC 12.2.0 in an out-of-tree CMake harness.guest_http,guest_http_response_header,guest_http_options,guest_http_transport, andguest_http_transport_context_allocationunder QEMU x86-64 emulation; all five passed.guest_http_transportincludes fixed-length/chunked bodies, redirects with cross-origin credential stripping, deterministic DNS/connect timeout cases, and a TLS loopback exchange whose untrusted certificate is accepted through the supplied verification callback. The allocation test sweeps 16 one-shot failure budgets with and without an existing context, checks failed-context rollback and retry, and verifies failed IDs have neither pool stats nor transport templates.python3 tools/check_conventions.py --base origin/main, syntax checks for changed sources/tests, andRequest.cppwith-Wall -Wextra -Werrorpassed.This was not a native x86-64 run or a full project build. The standard root CMake configuration is unavailable here because SDL lacks XRandR development support; the focused CMake harness bypassed the unrelated SDL build. No PS5 console test was available.
Overlap review
tools/pr_overlap.py --branch feat/libscehttp-request-transport --repo boykopovar/AnyPS5could not run to completion because this host has Git 2.34.1 and the tool uses the newergit merge-tree --write-treeinterface. I manually reviewed the overlapping work. #8357 has merged and is in the current base; this PR now registers its pool-size metadata transactionally with HTTP options and transport state. #9630 remains a dependency for the context/epoll allocation-safety changes. #8620 has been closed without title evidence; its cookie-limit changes are not included, so this PR owns the transport debt update. #9417, #9405 and #9413 have since merged and are in the current base; this PR does not modify their request-header-removal, auth-option or cookie-option behavior. #8541’s TLS test CMake hunk is no longer touched, and #9073’s author confirmed no exact hunk overlap after the UriCopy debt-line change. #6044’s test reorganization is handled by placing the new test intests/networking; the uncomparable #8646 offline-import hunk does not change the assertion modified here.Checklist
main; no other open PR implements the same request functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T17:18:00Z.
Review: CHANGES_REQUESTED
Blocking findings in the current draft:
connectTimeOutUsecdoes not bound connection establishment.CreateSocketStreamapplies it asSO_SNDTIMEO, then callssceNetConnect; the currentlibSceNetimplementation uses blockingconnect, and on Windows waits inselectwith no timeout. A peer that does not complete the handshake can therefore block indefinitely despite the configured connect timeout. Please implement a deadline-aware connect and test it, or explicitly leave this option unsupported and record that in the debt entry.Automatic redirects reuse
request.requestHeadersunchanged aftercurrentchanges. A cross-origin redirect (including HTTPS to HTTP) can forward caller-suppliedAuthorizationorCookieheaders to the new server. Strip sensitive credentials when the origin changes, and add a redirect test that verifies they are not forwarded; ensure theHostheader cannot remain pinned to the old origin either.The overlap report for this head flags a direct
libSceSsl/CMakeLists.txtconflict with #8541 and alibSceHttp.mdconflict with #9073. The body lists #9630, #8357 and #8620 but does not mention these overlaps. Please agree on sequencing with those authors and record the actual merge dependency/order in the checklist as CONTRIBUTING.md requires.The current hosted run has conventions/intake/labels checks, but no build or test jobs. The PR reports syntax checks and temporary plain-HTTP loopback smoke tests; the committed
guest_http_transportand TLS integration tests were source-checked but not run. Please run the committed focused transport tests on a supported host before marking the PR ready, including the TLS path.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T17:55:52Z.
Review: CHANGES_REQUESTED
Blocking security issue in automatic redirects:
PerformSendfollows aLocationto a newly parsed URL but reusesrequest.requestHeadersunchanged, andBuildRequestemits every retained header on each hop. A caller-suppliedAuthorizationor other origin-scoped credential header is therefore sent to an unrelated host if the original server redirects there. The feature supports both automatic redirects and arbitrary request headers, so please strip sensitive headers when scheme/host/effective port changes (and add a loopback cross-origin redirect test proving the second server does not receive them). The existing relative redirect test does not cover this case.The integration HTTP/TLS tests are reported source-checked but not executed locally; only native fixed/chunked smoke tests ran, with no TLS. CI product jobs are skipped. Also, the PR base is
0def01bcand currentmainisa6646f84(44 commits ahead); please rebase after the redirect fix and rerun the committed transport tests on the final head. The declared dependencies on #9630, #8357, and #8620 are still open and are correctly listed.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T20:29:32Z.
Review: COMMENTED
I re-reviewed the latest head
3381f7297ac4679fd49beab9467474e2b5f08320. The earlier redirect credential leak is addressed: authorization, proxy authorization, cookie, and host headers are removed when scheme, host, or effective port changes, and the author reports a cross-origin loopback test. The focused x86-64 build and QEMU test runs are also described with their limits. The current hosted product jobs (Linux, Windows, relinker, write-watch, and register-context) are skipped; conventions, eligibility, labels, and report pass. I did not run the transport tests locally. No additional actionable finding in this pass. I note the PR remains draft while its stated dependencies #9630, #8357, and #8620 are open and native x86-64 validation is outstanding.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T05:33:01Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The current head still has a Windows link failure, and the chunked-response parser leaves both trailer size and consumed-buffer growth unbounded.
What I ran
52c09d567d.Results
Negative control
Findings
Blocking
Windows libSceHttp does not link. The current target links only libSceNet and libSceSsl. The exact-head Windows workflow fails while linking libSceHttp with unresolved __imp_getaddrinfo and __imp_freeaddrinfo references from the newly added resolver/request objects. Please link ws2_32 to libSceHttp under WIN32, then rerun the Windows build and focused tests. The test executables’ ws2_32 links do not fix the library target’s own unresolved imports.
Chunk trailers have no total size limit. ReadChunkedBody loops over trailer lines until it sees an empty line, applying only the 8,192-byte per-line limit. A peer can send an unbounded number of individually valid lines. The loop does not enforce the configured response-header maximum, so the parser can keep reading indefinitely and retain unbounded pending data. Apply a total trailer-section bound and add a test that exceeds it.
Non-blocking
Sources
Not verified
To get this to a good state
Add the Windows resolver library to libSceHttp, bound the total chunk-trailer section, compact consumed pending data, and add the related regression cases. Then rerun the focused HTTP transport tests and exact-head Windows build with the complete dependency stack.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T06:30:09Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
On head
b6df6465e75b9c7ed6184dd1023e3be7aece34fd, the new context-allocation rollback coverage is useful, but the HTTP transport still has unbounded chunk trailers and the Windows library link remains unverified after a prior failure.What I ran
b6df6465e75b9c7ed6184dd1023e3be7aece34fd; recorded PR base:102c4f95a24d97dd7d000fb1830f26c103d03342.main:3b32cc7b61f1c09bff248c4a788ca7cf95f78ce0; merge preview was clean (760c612f6ecfec4b30289986e23b667168ad1c3b).Results
git diff --checkexited 0 with no output.libSceHttpcalls hostgetaddrinfo/freeaddrinfobut its target does not declarews2_32. Open PR #10957 changes the same CMake file and addsws2_32; the overlap requires author agreement and a declared landing order under the repository rule. #9630 is declared as a dependency; #11134 is stacked on #9834. #8646's uncomparableGuestOfflineImports.cppinsertion was manually checked and is in a separate test block.449a38aa084128589a9c63aab3fe2366dd8bc339failed; that result does not establish the outcome for this head.3f6fd99c78, which included separatews2_32and chunk-trailer fixes plus a test fix. This is useful author-provided evidence, but it is not the live PR head and was not independently reproduced.Unedited check output
Negative control
Findings
Blocking
Windows resolver symbols are not explicitly linked by
libSceHttp.Resolver.cppcalls hostgetaddrinfo/freeaddrinfo, while this head's target links onlylibSceNetandlibSceSsl. A previous Windows workflow failed on the earlier head; the exact-head Windows job is still pending. Add the required Windows socket library tolibSceHttpand verify the current head's Windows job.Chunked trailers have no aggregate size limit. The zero-size chunk path reads trailer lines until an empty line, applying only the per-line
kMaximumChunkLinelimit. A peer can send an unbounded number of individually valid lines and keep the response reader consuming data. Bound the whole trailer section and add a regression that exceeds that bound.The overlapping CMake changes lack a declared landing order. The current #9834 checklist does not declare #10957, although both change
libSceHttp/CMakeLists.txtand the #10957 version adds the Windows socket-library link. Please agree with that PR's author which change lands first and record the dependency on the appropriate checklist line.Non-blocking
ReadLineadvancespendingOffsetand appends new input topendingwithout dropping consumed bytes. With a long chunked response, the buffer retains prior chunk data; compact consumed prefixes and cover a many-chunk response to bound this growth.Sources
libSceHttptarget at headb6df6465e75b9c7ed6184dd1023e3be7aece34fdmain3b32cc7b61f1c09bff248c4a788ca7cf95f78ce03f6fd99c78449a38aa084128589a9c63aab3fe2366dd8bc339b6df6465e75b9c7ed6184dd1023e3be7aece34fdNot verified
I did not build or run CTest locally, exercise a negative control, or run console behavior. The current Windows job was pending when checked; Linux product and specialized hosted jobs were skipped. The reported 104-test Windows run used a different stacked head with separate fixes, and the five QEMU tests are author-reported; neither was independently reproduced here.
To get this to a good state
Add the Windows socket-library link, cap total chunk-trailer bytes with a regression test, and record the agreed #10957 landing order. Keep the declared #9630 dependency. I will rerun the same source checks and review the exact new head and its updated CI after those changes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T10:03:53Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the connection-timeout conversion so a configured timeout is interpreted in microseconds by epoll.
What I ran
Reviewed head
974dfd5adeacd42557add90af180f96d06742d88using the prepared diff andrepo_read.pyfor relevant source ranges. No build or tests were run; reported test results below are author supplied.Results
Findings
Blocking
core/libs/prx/libSceHttp/src/Request.cpp:763:sceNetEpollWaitreceives the configured timeout directly, but its timeout argument is in milliseconds whileusecis microseconds. A configured one second deadline therefore waits about one millisecond, and smaller values truncate to zero, causing valid connections to fail prematurely. Convert microseconds to the epoll API's unit with appropriate rounding and bounds before waiting.Non-blocking
None.
Not verified
Did not run tests, build, native x86-64 execution, Windows execution, or PS5 console behavior. Author reports five focused tests passed under QEMU x86-64 emulation on an AArch64 Linux host with GCC 12.2.0. Read
Export.cpp,Request.cpp,Resolver.cppand the relevant ranges ofdiff.patch; other changed files and excluded files listed infiles.jsonwere not read. The repository reader was pinned to the stated head.To get this to a good state
Correct the timeout unit conversion, then rerun the focused transport tests and timeout coverage on the new head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T08:39:39Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
6f0f98b3a5cfe2aec1cc3091ec8ea81e3b7c31e1againstmain. I inspected the prepared diff and targeted source sections using shell tools andrepo_read.py; no merged-preview check or build was run.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceHttp/src/Resolver.cpp:64-65adds every lookup to an unbounded queue. If concurrent calls accumulate while resolver workers are occupied ingetaddrinfo, queued jobs retain their host and service strings even after callers time out. Consider bounding the queue or rejecting excess work.Sources
Not verified
No build, tests, native x86-64 run, or PS5 console behavior was verified. The focused test runs described by the author were not run during this review. The manifest lists no excluded files. Reviewed changed paths:
core/libs/prx/libSceAvPlayer/CMakeLists.txt,core/libs/prx/libSceHttp/CMakeLists.txt,core/libs/prx/libSceHttp/Export.cpp,core/libs/prx/libSceHttp/src/Request.cpp,core/libs/prx/libSceHttp/src/Request.hpp,core/libs/prx/libSceHttp/src/Resolver.cpp,core/libs/prx/libSceHttp/src/Resolver.hpp,core/libs/tests/AvPlayerHttpModules.cmake,core/libs/tests/GuestHttp.cpp,core/libs/tests/GuestOfflineImports.cpp,core/libs/tests/HttpTransportContextAllocation.cpp,core/libs/tests/networking/GuestHttpTransport.cpp, anddocs/dev/debt/libSceHttp.md.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.