feat(libSceHttp): keep options per template, connection and request and implement their getters #8245
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8245"
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 YossiYad on 2026-10-20T06:46:27Z.
What
libSceHttp handed out template, connection and request ids but kept nothing about them, so its option setters dropped their values and the matching getters threw. Each template, connection and request now keeps its options in
src/Options.cpp, copied from its parent when it is created (a template from its context), as in shadPS4. With that, 12 exports are implemented:sceHttpGetAutoRedirectreads whatsceHttpSetAutoRedirectsets (default: follow redirects).sceHttpGetNonblock,sceHttpTryGetNonblockandsceHttpTrySetNonblockread and set the flag ofsceHttpSetNonblock(default: blocking); the Try forms do what the plain ones do, as in shadPS4.sceHttpSetAcceptEncodingGZIPEnabledandsceHttpGetAcceptEncodingGZIPEnabledset and read the gzip request option (default: off).sceHttpSetDefaultAcceptEncodingGZIPEnabled(ctx, enable)sets the value later templates of that context start with; shadPS4 keeps one value for the whole library, and the debt entry says this differs.sceHttpGetEpollreturns the epoll and argumentsceHttpSetEpollbinds;sceHttpUnsetEpollclears them.sceHttpCacheRedirectedConnectionEnabled,sceHttpsEnableOptionPrivateandsceHttpsDisableOptionPrivatecheck their arguments (the private SSL mask0x2dfffirst, then the id) and return 0, andsceHttpAbortRequestForcedoes whatsceHttpAbortRequestdoes. No request reaches the network, so they keep nothing; they are listed under Silent stubs.Getters return
ERROR_INVALID_VALUE(0x804311FE) for a null output before they look at the id, andERROR_INVALID_ID(0x80431100) for an id that is not a live template, connection or request, also after it is deleted. The setters touched here (sceHttpSetAutoRedirect,sceHttpSetNonblock,sceHttpSetEpoll,sceHttpUnsetEpoll) now returnERROR_INVALID_IDfor such an id instead of 0. Every option call returnsERROR_BEFORE_INIT(0x80431001) first when no context is open, and the lastsceHttpTermends every object's options.sceHttpSetEpollreturnsERROR_INVALID_IDfor a handle that is not a live epoll. Creation stays as permissive as it was: a connection or request whose parent id is unknown starts from the defaults.None of this is measured on a PS5; the defaults, signatures and check order are shadPS4's (PS4), and the two debt entries in
docs/dev/debt/libSceHttp.mdsay so.Tested
Linux (Fedora 44, GCC, Ninja,
-DBUILD_TESTING=ON), based onmain1ed63f63c2:guest_http_options(core/libs/tests/GuestHttpOptions.cpp): defaults, inheritance from template to connection to request, that a later change to a parent leaves existing children alone, the per-context gzip default across two contexts and aftersceHttpTerm, the epoll binding and its clearing, the SSL mask, and the error codes and their order, the option calls after the lastsceHttpTermand after a newsceHttpInit, andsceHttpSetEpollwith a handle that is not an epoll. Each feature commit was checked against a mutation of its own code: a setter that drops its value, children that start from the defaults instead of the parent,sceHttpTrySetNonblockas a no-op, templates that ignore their context's gzip default,sceHttpUnsetEpollas a no-op, and the public SSL mask0x20ffin place of the private one. Each fails the test.guest_http,guest_http_response_headerandguest_http2still pass.ctest: 1668 of 1673 pass. The 5 failures (application_heap_scripting,application_heap_lazy,agc_driver_bda_device,agc_driver_guest_memory_lifetime,agc_driver_tessellation) fail the same way onmainon this machine.sceHttpSetAutoRedirect(PPSA85300, PPSA94002, PPSA98001, PPSA99000, PPSA99009, PPSA99169, PPSA99666) ran for 20 s each on an RX 7700 XT with a local print in the option setter: ProsperoStore (PPSA99000) made 8 setter calls, all on live ids, and none of the seven stops. The other six made no setter call in that time.tools/progress.py --compare: libraries 66.62% to 66.81%, 12 functions implemented, none lost.tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pyfinds no overlap; it could not comparelibSceHttp/CMakeLists.txtwith #6044, which conflicts withmainand moves test registrations.Checklist
main; no other open PR implements the same 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 github-actions[bot] on 2026-10-20T06:47:13Z.
Progress report (
65c393a→0406a1b)📈 System libraries: 53.37% (+0.14%, +12 implemented functions)
✅ 12 implemented
sceHttpAbortRequestForcesceHttpCacheRedirectedConnectionEnabledsceHttpGetAcceptEncodingGZIPEnabledsceHttpGetAutoRedirectsceHttpGetEpollsceHttpGetNonblocksceHttpSetAcceptEncodingGZIPEnabledsceHttpSetDefaultAcceptEncodingGZIPEnabledsceHttpTryGetNonblocksceHttpTrySetNonblocksceHttpsDisableOptionPrivatesceHttpsEnableOptionPrivateImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T06:52:50Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libSceHttp.mdL5docs/dev/debt/libSceHttp.mdL8-9Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceHttp/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T20:40:32Z.
I built this PR's
Export.cppandsrc/Options.cppstandalone (g++ 15.2, Linux) and compared them with the shadPS4 commit the PR cites.1. No
BEFORE_INITcheck, and objects outlive the lastsceHttpTerm.RemoveHttpContextonly drops the context's gzip default. None of the new getters and setters (for examplesceHttpGetAutoRedirect) checks that a context is alive.ctx = sceHttpInit(...),t = sceHttpCreateTemplate(ctx, ...),c = sceHttpCreateConnectionWithURL(t, ...)andsceHttpTerm(ctx),sceHttpGetAutoRedirect(t, &v)returns 0 withv = 1, andsceHttpSetNonblock(c, 1)returns 0.sceHttpInit,sceHttpSetAutoRedirect(t, 0)still returns 0.sceHttpGetNonblock(1, nullptr)andsceHttpsEnableOptionPrivate(1, 0x4000)return0x804311FE.In shadPS4, each of these calls checks
g_state.initedfirst (L2939-L2942, L2441-L2444, L2642-L2645). ThesceHttpTermthat ends the last context also clears templates, connections and requests (L2146-L2175). So these calls return0x80431001, and0x80431100after the new init.The debt entry says the checks run in shadPS4's order, and this PR's
sceHttpSetDefaultAcceptEncodingGZIPEnabledalready returnsBEFORE_INIT.g_contextAcceptEncodingGzipholds the same ids asg_contexts, so this is enough:Then put
if (!HttpInitialised()) return ERROR_BEFORE_INIT;first in each export inOptions.cpp, and insceHttpSetAutoRedirect,sceHttpSetNonblockandsceHttpUnsetEpoll. With this change,guest_http_optionsstill passes and the calls above return0x80431001, or0x80431100after the new init. A test case of Init, CreateTemplate, Term and then a getter would cover it.2.
sceHttpSetEpolldoes not check the handle. Export.cpp L315-L317 stores anyeh.sceHttpSetEpoll(req, nullptr, &m)andsceHttpSetEpoll(req, (HttpEpollHandle)0x1234, &m)both return 0, andsceHttpGetEpollthen reports0x1234. AftersceHttpDestroyEpoll(ctx, eh),sceHttpSetEpoll(req, eh, &m)returns 0, andsceHttpGetEpollhands back the freed handle. shadPS4 returnsINVALID_IDwhen the handle is not a live epoll, before it looks at the id (L2378-L2382).FindEpollis already in the same file:sceHttpUnsetEpollalso returns 0 for template and connection ids, while shadPS4 looks only at requests (L2404-L2408). If that is kept, the debt entry should say so.3. Stale "unknown signature" entries. In docs/dev/debt/libSceHttp.md, lines 35, 39-42, 45, 57-58, 62-64 and 72 still list the 12 functions this PR implements as "unknown signature". Nine of them link
Export.cpp, although they now live insrc/Options.cpp. CONTRIBUTING.md says a pull request that closes a gap removes its entry, asa84a2b1240andfd5eb8458bdid. To fix this, delete the 12 lines and say in the "HTTP object options" entry that the signatures come from shadPS4, as the PR body does.Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-21T06:36:56Z.
@nikowolf123 thanks for building it against shadPS4, all three points were right. Fixed in
ede012406and0406a1b54:RemoveHttpContextclears every object's options when the last context goes, and the option calls inOptions.cpp,sceHttpSetAutoRedirect,sceHttpSetNonblockandsceHttpUnsetEpollreturnBEFORE_INITfirst, as you suggested. The newCheckTermEndsOptionscreates a template and a connection, terminates the context, expects0x80431001from every option call (also with a null output, and with the outputs left untouched), and then0x80431100for the same ids after a newsceHttpInit.sceHttpSetEpolltakesg_stateMutex, returnsBEFORE_INITwith no context andINVALID_IDwhenFindEpolldoesn't know the handle. The epoll test now tries a null handle,0x1234and a destroyed epoll, and checks the binding stays unset. I keptsceHttpUnsetEpolltaking template and connection ids, and the debt entry now says shadPS4 looks only at requests.BEFORE_INITfirst, the lastsceHttpTermending every object's options) come from shadPS4. I also cut the clause that described the newINVALID_IDresults.I checked that the test fails without the clear on the last
sceHttpTerm, without the init checks and without theFindEpollcheck.guest_http,guest_http_options,guest_http_response_headerandguest_http2pass, andcheck_conventionshas no findings.Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-21T06:39:20Z.
Checked
0406a1b54. All three fixes are in:BEFORE_INITbefore looking at its arguments, and the lastsceHttpTermclears every object's options (RemoveHttpContext);sceHttpSetEpollreturnsBEFORE_INITwith no context andINVALID_IDfor an epoll handle thatFindEpolldoesn't know;CheckTermEndsOptionspins the term and re-init sequence. Nothing further from me.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T12:04:53Z.
Checked the option storage and lock order, the error codes and check order against the cited shadPS4 commit, the debt entries, and that
guest_http_optionsis registered and pins values the old stubs could not return (including the term/re-init sequence nikowolf123 asked for); merged.