Files
AnyPS5/docs/dev/debt/libSceHttp.md
gnavarro24andDean Galvin 707fbf4e85 fix(libSceHttp): copy guest outputs through GuestCopy (#19769)
* fix(libSceHttp): copy guest outputs through GuestCopy
* docs(libSceHttp): restore the no-network debt paragraph
* fix(libSceIcu): rename colliding GuestPointers test namespaces
* ci: retrigger checks

Co-authored-by: Dean Galvin <dean.galvin@live.com>
2026-11-17 12:50:01 +13:00

28 KiB

libSceHttp technical debt

Sony guest HTTP requests still do not reach the network. The separate Aps5HttpClient_*_nid_postfix host client does not implement the Sony request, context, callback, authentication or cookie APIs described below.

Functional

  • sceHttpGetCookie, sceHttpParseResponseHeader, URI functions and Aps5HttpClient_Read still read or write guest buffers in place, so an unmapped buffer crashes the host instead of returning ERROR_INVALID_VALUE. sceHttpParseResponseHeader returns pointers into the guest header, so its input cannot be copied without changing its result; sceHttpGetCookie needs a stored cookie, which the tests cannot create offline. The Uri and Client functions overlap open pull requests.
  • sceHttpGetLastErrno still writes its errno output in place; open pull requests #9834, #11134 and #18515 rewrite its body, so it is left to them.

Silent stubs

  • libSceHttp - no request reaches the network, so sceHttpSetResponseHeaderMaxSize has no response header to limit, sceHttpSetRecvBlockSize ((int id, u32 blockSize) as in shadPS4) no response body to read in blocks and sceHttpRedirectCacheFlush no redirect to forget; sceHttpsUnloadCert returns success like sceHttpsLoadCert, which keeps no certificate; sceHttpSetRedirectCallback and sceHttpSetCookieRecvCallback accept callbacks that are never called, sceHttpsSetSslVersion has no TLS connection to configure and sceHttpsGetSslError reports error 0 with detail 0; sceHttpSetAuthInfoCallback accepts a callback that is never called, as no server asks for authentication; sceHttpsGetCaList and sceHttpsFreeCaList report an empty CA list (certs null, certsNum 0) and return 0, as no CA store is kept, and a null list returns ERROR_INVALID_VALUE; unlike shadPS4 they do not check that http_ctx_id is a live context nor that the library is initialised, and sceHttpsFreeCaList also nulls certs, which shadPS4 leaves untouched. The signatures and the { void* certs; int certsNum; } layout follow shadPS4 (PS4), not confirmed on a PS5 title

  • sceHttpSetSendTimeOut, sceHttpSetRecvTimeOut, sceHttpSetRequestContentLength (libSceHttp) - return 0 and keep nothing: no request reaches the network, so there is no send or receive to time out and no request body whose length to send. None checks its id. PPSA02225 calls the send and receive timeouts at two sites each; PPSA34502 calls them once each and sceHttpSetRequestContentLength at four sites. Console behaviour, including the error for a bad id, is not measured

  • HTTP options without a network (libSceHttp) - sceHttpCacheRedirectedConnectionEnabled, sceHttpsEnableOptionPrivate and sceHttpsDisableOptionPrivate return 0 for a live template, connection or request and keep nothing, since no request reaches the network; the private options refuse flags outside 0x2dff with ERROR_INVALID_VALUE before they look at the id, and sceHttpAbortRequestForce does what sceHttpAbortRequest does. Signatures, the mask and the order of the checks follow shadPS4 (PS4), not measured on a PS5

  • sceHttpSetProxy (libSceHttp) - returns 0 for a live template, connection or request and keeps nothing, since no request reaches the network. The signature (id, HTTP proxy conf, WLAN proxy conf, host, port) and the order of the checks (ERROR_BEFORE_INIT, then ERROR_INVALID_VALUE for a null host, then ERROR_INVALID_ID) follow shadPS4 (PS4), which stores the proxy; not measured on a PS5

  • sceHttpRemoveRequestHeader, sceHttpSetResolveRetry, sceHttpSetChunkedTransferEnabled, sceHttpsSetMinSslVersion (libSceHttp) - return 0 and keep nothing, for any ID, since no request reaches the network. Of the 38 titles relinked here, only Call of Duty: Black Ops II (PPSA34502) imports one of them, sceHttpSetChunkedTransferEnabled

  • sceHttpSetHttp09Enabled, sceHttpSetPriorityOption, sceHttpSetPolicyOption and sceHttpSetSocketCreationCallback (libSceHttp) - return 0 for a live template, connection or request and keep nothing, since no request reaches the network: no HTTP/0.9 response is read, no request is scheduled and no socket is created for the callback. Firmware 13.42 libSceHttp.sprx (read from disassembly, not run on a console) checks initialisation, then stores each value through one option setter that refuses an unknown id. A template made by a title built before SDK 1.50 (0x1500000) has no socket callback storage, so the callback setter returns ERROR_INVALID_VALUE for it. The console also returns 0x80431076 when less than 0x3FD0 bytes of the caller's stack remain; AnyPS5 does not check the stack

Unknown function info

  • Context and epoll allocation: PS5 out-of-memory errors and failed-call output values remain unverified. Host bookkeeping uses the C++ allocator and can throw std::bad_alloc; the guest HTTP memory pool is not used for these allocations.

  • HTTP object options (libSceHttp) - a template starts with redirects followed, blocking calls and no Accept-Encoding: gzip, and a connection or request copies its parent's options when it is created. The signatures of the option calls, these defaults, the copying and the order of the checks (BEFORE_INIT first; the last sceHttpTerm ends every object's options) follow shadPS4 (PS4) and are not measured on a PS5. sceHttpSetDefaultAcceptEncodingGZIPEnabled sets the gzip value for templates created later in that context, where shadPS4 keeps one value for the library, and sceHttpUnsetEpoll takes a template or connection id, where shadPS4 looks only at requests. The options change no request, as none reaches the network

  • sceHttpGetConnectionStat (libSceHttp) - connection diagnostic signature is recovered with a 16-byte (four 32-bit words) output structure. Validates context initialization (0x80431001), null destination pointer (0x804311FE), and connection id (0x80431100), zeroing stats on success. Field semantics remain incomplete under the offline backend. Epoll setters/getters distinguish a 32-bit epoll ID from a pointer-sized handle, and use a pointer-sized user argument. The supplied firmware getter dispatch does not handle the pointer-handle selector used by GetEpoll, so its intended successful behavior is not recoverable from this implementation.

  • sceHttpSetCookieEnabled - the two-argument signature follows VitaSDK and shadPS4; PPSA01521 passes 0 to disable cookies. On PS5 firmware 13.590.001 (a title process) a valid template accepts any value: 0, 1, 2, 3, 255, 256, -1 and INT_MIN each returned 0, and sceHttpGetCookieEnabled read the same value back (measured on a template; connections and requests are not measured). Before init an id is invalid: measured for id 1, and no object exists before init, so every id is taken as unknown; an unknown id returns ERROR_INVALID_ID, and the value is not checked first. No cookie is kept or sent, as no request reaches the network. The default (disabled) is unverified on a PS5

  • sceHttpParseResponseHeader (libSceHttp) - signature follows SharpProspero; the result, value bounds and error codes follow a payload process on a PS5 (firmware 13.60). Unmeasured there: a bare carriage return, and vertical tab or form feed around the value, which are skipped as blanks before it as before. A value end above INT_MAX throws instead of wrapping. PPSA01494 01.100.002 (at 0x34F6BA6) and PPSA34502 01.010.000 (0x71BB8E, 0x71D463), disassembled for this entry, pass the arguments in that order, the two outputs on the stack. PPSA01494 treats only a negative result as a failure; PPSA34502 treats 0 as one too, so for it an empty value is a missing field, and it compares the value length with its own buffer size before copying

  • sceHttpAbortRequest (libSceHttp) - returns 0 for every request ID, before sceHttpInit and for an unknown ID too; no request reaches the network, so nothing is aborted. sceHttpAbortRequestForce calls it. GuestHttpOptions.cpp tests only a live request, and the commit that added it names no measurement. shadPS4 (PS4, src/core/libraries/network/http.cpp, commit 0614ce324be092791b758d79f93d9f1ca5b10a81) returns BEFORE_INIT without a context and INVALID_ID for an unknown request, and marks a request that is created or sending as aborted; KytyPS5 (PS5, src/libs/network.cpp, commit 5e837a9beac82c031868eaad9348d6a48245fb99) returns INVALID_ID for an unknown request and otherwise OK without aborting; fpPS4 (PS4, src/ps4_libscehttp.pas, commit 04cefd43e6fddd1ab033e7980cd356d14c964905) always returns 0.

  • sceHttpParseStatusLine (libSceHttp) - follows a payload process on a PS5 (firmware 13.60) for 124 lines and lengths. As on the console, lineLen is only checked to be at least 8 and to leave the 3 code digits (lineLen - index < 3 in unsigned arithmetic): the version digits and the . and space after them are read past lineLen, and the line feed is searched up to and including the byte at lineLen, so a length that stops right before the line feed still parses. When the version ends past lineLen both subtractions wrap and the search goes on until a line feed; what the console does when none follows in readable memory was not measured

  • sceHttpUriMerge (libSceHttp) - signature follows SharpProspero; results, errors and require (the base's sceHttpUriParse size plus 2 and twice the two string lengths, also for a reference copied unchanged) follow a payload process on a PS5 (firmware 13.60). A reference with an authority (// after an optional scheme) is copied unchanged; any other, including mailto:x, http:d, ?q and #f, is appended unswept to the base path up to its last /, and the base query and fragment are dropped. A reference that sceHttpUriParse rejects returns that error, which was not measured.

  • sceHttpUriParse (libSceHttp) - follows a payload process on a PS5 (firmware 13.60) for every ASCII byte inside a scheme, userinfo and hostname, and for letters, digits, +, - and . at the start of a scheme, where a digit ends it; other bytes at the start of a scheme are taken as they are inside one. The userinfo ends at the first @ after bytes from the RFC 3986 userinfo set; a hostname is letters, digits, -, _ and . without a leading ., and the first byte outside it starts the path instead of failing (http://bad host/ has the host bad and the path host/). A port is up to 5 digits that end at / or the end, at most 65536, which reads as 0; an empty port takes 443 for a scheme starting with https, 80 for one starting with http (case-insensitive) and 0 otherwise. The path is swept as sceHttpUriSweepPath does, while the pool keeps room for the unswept path. With a pool too small the console returns ERROR_OUT_OF_MEMORY, leaves require alone and has already written part of the pool; how much is not known, so nothing is written here.

  • sceHttpUriSweepPath (libSceHttp) - follows a payload process on a PS5 (firmware 13.60), which agrees with the shadPS4 reimplementation of the PS4 library: it is not RFC 3986 5.2.4, a path that doesn't start with / is copied unchanged and a trailing . or .. is kept. Like the console, the byte at srcSize - 1 is read as the / that ends a .. segment, and srcSize == 1 with a leading / writes /; whether it also ends a . segment was not measured, so a . there is still kept as before

  • sceHttpSetResponseHeaderMaxSize, sceHttpRedirectCacheFlush, sceHttpsUnloadCert (libSceHttp) - signatures follow shadPS4 (PS4); no PS5 reference has them

  • sceHttpSetRequestStatusCallback - the three-argument ABI follows shadPS4. Registrations and user data are retained and removed on request deletion; the offline backend never dispatches callbacks. Invalid ids return 0x80431100, an uncited assumption, not a verified console error. Handle hierarchy, inheritance and deleted-handle validation remain incomplete; callback statuses and dispatch timing are unknown.

  • sceHttpSetRedirectCallback, sceHttpSetCookieRecvCallback, sceHttpsSetSslVersion, sceHttpsGetSslError (libSceHttp) - signatures follow shadPS4 (PS4), which only logs and returns 0; the sceHttpSetCookieSendCallback signature follows Orbital's type database (PS4), and the callback it accepts is never called as no request sends cookies; a null errNum or detail in sceHttpsGetSslError is assumed to return SCE_HTTP_ERROR_INVALID_VALUE like sceHttpGetLastErrno

  • sceHttpSetAuthInfoCallback (libSceHttp) - signature and callback type follow shadPS4 (PS4); no PS5 reference has them. The id is not checked, as in the other libSceHttp setters

  • sceHttpWaitRequest (libSceHttp) - measured on PS5 firmware 13.590.001 (a title process): the timeout is in microseconds (a 1000 µs wait returned after about 1.1 ms, 20000 µs after about 20.1 ms, 100000 µs after about 100.1 ms); a -1 timeout was still blocked 1.5 s later, consistent with waiting without a limit; the invalid-value error 0x804311FE is returned for a null handle, a null event array, and a count of 0 or -1; no request is ever pending, so a wait returns 0 events when its timeout passes. Two titles disassembled for this entry pass a stack event array and a small positive timeout: PPSA21564 01.007.000 (at 0x10A792A) one event and 10, PPSA34502 01.010.000 (0x717B8D) eight and 100000, which is 100 ms as microseconds but 100 s as milliseconds. Both treat a negative result as an error and 0 as no event

  • sceHttpUriCopy (libSceHttp) - unverified: whether the strings are written before the size check, which a short pool hides by ending cleared. The rest follows a payload process on a PS5 (firmware 13.60): the arguments are (out, src, pool, prepare, require) as in the disassembly; the whole output and all prepare pool bytes are cleared before the source is read, so a source that is the output or lies in the pool copies as empty; the scheme, hostname, path, username and password are copied in that order with terminators, a null one as empty, and the port, while the query, fragment and opaque flag stay 0; a short pool returns 0x80431022 and leaves require alone; a null source returns 0x80433060, and no output or pool with a null require 0x804311FE

  • sceHttpDbgEnableProfile (libSceHttp) - the export is absent from the supplied native module; its signature remains unresolved.

  • sceHttpDbgSetPrintf returns constant success without consuming arguments in the supplied module; the callback contract remains unresolved.

  • sceHttpDbgShowStat (libSceHttp) - the native diagnostic consumes no arguments; it prints library state. The throwing implementation remains unchanged.

  • sceHttpInit (libSceHttp) - a pool size of 0 returns a context id like any other size. That is an assumption that no console run has checked. shadPS4 (PS4, src/core/libraries/network/http.cpp, commit 0614ce324be092791b758d79f93d9f1ca5b10a81) returns the kernel EINVAL for 0, fpPS4 (PS4, src/ps4_libscehttp.pas, commit 04cefd43e6fddd1ab033e7980cd356d14c964905) accepts any size, and KytyPS5 (PS5, src/libs/network.cpp, commit 5e837a9beac82c031868eaad9348d6a48245fb99) treats 0 as not implemented (EXIT_NOT_IMPLEMENTED) and returns no value. sceSslInit with a pool size of 0 returns the kernel EINVAL on a PS5 (system software 13.40, see the libSceSsl connection entry); that is a neighbouring call, not a measurement of libhttp. Which result is right is not decided. Twenty-nine of the 53 local titles import sceHttpInit.

  • sceHttpDbgShowConnectionStat (libSceHttp) - the native diagnostic consumes no arguments; it prints library state. The throwing implementation remains unchanged.

  • sceHttpDbgShowRequestStat (libSceHttp) - the native diagnostic consumes no arguments; it prints library state. The throwing implementation remains unchanged.

  • sceHttpDbgShowMemoryPoolStat (libSceHttp) - the native diagnostic consumes no arguments; it prints library state. The throwing implementation remains unchanged.

  • sceHttpGetMemoryPoolStats (libSceHttp) - not measured on a console. The library takes nothing from the pool given to sceHttpInit, so it reports that size with peak and current use 0, where a console already holds bytes for a live context (0x1640 for Http2, see libSceNet). No live context returns BEFORE_INIT (0x80431001) and an unknown or terminated id INVALID_ID (0x80431100), as in sceHttpCookieFlush, with the output untouched; both codes are unmeasured. A null output throws, as its error code is unknown. Only the 24 bytes of the declared layout are written; SharpProspero's struct adds a 32-bit reserved field after them

  • sceHttpGetRegisteredCtxIds (libSceHttp) - not measured on a console. It reports the libnet memory pool id and the SSL context id given to sceHttpInit for the context, in the order of the recovered prototype (int contextId, int* netPoolId, int* sslContextId); no public source names its outputs, and neither id is checked against libSceNet or libSceSsl. No live context returns BEFORE_INIT and an unknown or terminated id INVALID_ID, as in sceHttpGetMemoryPoolStats, with the outputs untouched; both codes are unmeasured. A null output throws, as its error code is unknown

  • sceHttpSetDelayBuildRequestEnabled (libSceHttp) - sets the delay-build option on templates, connections or requests following the object option lifecycle. The options change no request, as none reaches the network.

  • sceHttpsEnableOption, sceHttpsDisableOption (libSceHttp) - the public TLS option toggles return 0 for any id and keep nothing, since no request reaches the network. Unlike the *Private variants above, they do not reject flags outside the 0x2dff mask: the ssl_flags argument is ignored outright.

  • sceHttpSetConnectTimeOut (libSceHttp) - returns 0 for any id and keeps the microsecond connection timeout nowhere, since no connection is made, as the send and receive timeout setters do. Call of Duty: Black Ops II (PPSA34502) imports it.

  • sceHttpSetResolveTimeOut (libSceHttp) - returns 0 for any id and keeps the microsecond DNS-resolve timeout nowhere, the counterpart of sceHttpSetResolveRetry above; no name is resolved, since no request reaches the network.

  • sceHttpAddRequestHeader (libSceHttp) - returns 0 for any id and keeps nothing: the header name, value and mode are all ignored, so a request's caller-added headers are silently dropped (the counterpart of sceHttpRemoveRequestHeader above). No request reaches the network.

  • sceHttpsSetSslCallback (libSceHttp) - returns 0 for any id and keeps nothing: the TLS verification callback and its user argument are discarded and never invoked, since no connection is made. A caller that relies on it to inspect or override certificate-verification results sees success but no callback.

Functional

  • Shared host HTTP client - HTTPS, URL user information, non-ASCII URLs, encoded representations and non-chunked transfer codings remain unsupported and throw. Host DNS is blocking and cannot be cancelled; opening has no deadline and consumes its initial response to determine size. Every 200 or 203 response is buffered in full, with memory use growing with source size. A 206 containing only part of the representation needs a strong ETag, or no ETag and a valid HTTP-date Last-Modified at least 60 seconds before Date; otherwise an unconditional complete 200 or 203 is required before opening, and opening fails without it. Later redirects fail because validators are scoped to one resource. Console timeout and network-error mapping remain unverified. This host helper lacks proxy, cookie, authentication and Sony HTTP-context integration.

  • sceHttpUriParse, sceHttpUriBuild, sceHttpUriMerge - bytes 0x80 to 0xFF were measured only as 0x80, 0xC3 and 0xFF in a hostname; the others, and any of them in a scheme or userinfo, are taken as the measured ASCII bytes outside those sets are. ASCII classification and scheme case folding are independent of the host locale. A bracketed host such as [::1] is parsed, merged and built without its brackets, as a PS5 (firmware 13.60) does; a PS4 (firmware 10.71) takes no bracketed host (http://[::1]x/ has an empty host and the path [::1]x/) and keeps [::1]:80 in a merge, as measured in #9058, so this follows the PS5 only.

  • sceHttpUriEscape escapes every byte except the ASCII unreserved set in RFC 3986 section 2.3, independently of the host locale. Console behaviour for non-ASCII input remains unmeasured.

  • sceHttpAuthCacheFlush, sceHttpCookieFlush (libSceHttp) - the context-id signatures follow SharpProspero, and the NIDs zzB0StvRab4 and seCvUt91WHY match shadPS4. The offline backend never stores authentication credentials, so flushing them succeeds with an empty cache; sceHttpCookieFlush empties the cookie store below. sceHttpCookieFlush returns INVALID_ID (0x80431100) for any id without a live context, as measured on firmware 13.42. sceHttpAuthCacheFlush returns BEFORE_INIT (0x80431001) when no context is alive and INVALID_ID for an unknown, deleted or non-context handle, following the existing context lifecycle checks; its codes have not been measured on PS5 hardware; shadPS4 only stubs these calls. Network-backed caches remain unimplemented.

  • sceHttpAbortWaitRequest, sceHttpWaitRequest (libSceHttp) - the abort takes only the epoll handle, as in Orbital and SharpProspero; behaviour and error codes follow shadPS4 (PS4). On a PS5 (13.590.001) later waits and polls returned SCE_HTTP_ERROR_ABORTED (0x80431080); lasting until destroy and waking a blocked wait are unconfirmed. A wait woken by sceHttpDestroyEpoll, or by the sceHttpTerm that ends the last context, returns 0 events. The epoll calls return BEFORE_INIT (0x80431001) while no sceHttpInit context is alive and INVALID_ID (0x80431100) for an unknown context or handle, and sceHttpTerm returns the same errors instead of succeeding for any id. Handles are pointers, so a stale handle whose address a newer epoll reuses is taken as that epoll

  • Cookie store (libSceHttp) - follows calls measured on firmware 13.42 libSceHttp.sprx in #10535, including the default limits (4096 bytes, 50 per domain, 3000 cookies, 81920 bytes) and eviction; RFC 6265 dates. No request sends or receives cookies. sceHttpSetCookieSendCallback is not measured.

  • sceHttpCookieExport and sceHttpCookieImport (libSceHttp) - export writes a host-defined binary blob (APS5CK1, little-endian length-prefixed fields, creation order and optional expiry) and import replaces the jar with it; the console's format and replacement-or-merge behavior are unmeasured, and this blob is only guaranteed to round-trip through this implementation. A blob exported on a console is rejected with ERROR_INVALID_VALUE. A null buffer queries the required size; a short buffer returns ERROR_OUT_OF_SIZE; malformed, truncated, oversized or unreadable data returns ERROR_INVALID_VALUE or ERROR_OUT_OF_SIZE and leaves the jar unchanged. An import above the current cookie-count, per-cookie, per-domain or total-size limits returns ERROR_OUT_OF_SIZE; expired cookies are dropped and an expiry outside the clock range is clamped. The error codes, size bound and import limit checks are host choices, not console measurements.

  • sceHttpCreateEpoll (libSceHttp) - returning SCE_HTTP_ERROR_INVALID_VALUE (0x804311FE) for an unwritable epoll handle pointer via GuestCopyOut_nid_no_patch is a host-safety fallback with console behavior unmeasured.

  • sceHttpsGetSslError (libSceHttp) - returning SCE_HTTP_ERROR_INVALID_VALUE (0x804311FE) when err_num or detail is null or unwritable via GuestCopyOut_nid_no_patch is a host-safety fallback preserving host errno; console behavior on unmapped pointers is not measured.

  • sceHttpParseStatusLine (libSceHttp) - reading the status line byte by byte with GuestCopyIn_nid_no_patch, at the same offsets as before, and returning ERROR_PARSE_HTTP_INVALID_RESPONSE (0x80432060) at the first unreadable byte, and writing each output with GuestCopyOut_nid_no_patch and returning ERROR_PARSE_HTTP_INVALID_VALUE (0x804321FE) when one cannot be written, is a host-safety fallback; outputs written before the failure keep their values, and console behavior on unmapped memory is unmeasured.