Merge pull request #795 from CnRJay/feat/http2-cookie-box

feat(libSceHttp2): implement cookie boxes and requests without a content length
This commit is contained in:
Dean
2026-10-07 10:19:25 +13:00
committed by GitHub
4 changed files with 70 additions and 11 deletions
+21
View File
@@ -0,0 +1,21 @@
add_library(libSceHttp2 SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceHttp2 PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceHttp2)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_http2_tests ${LIBS_INCLUDE_DIR}/tests/GuestHttp2.cpp)
target_include_directories(guest_http2_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_http2_tests PRIVATE libSceHttp2 libc)
configure_windows_unwind(guest_http2_tests)
add_test(NAME guest_http2 COMMAND guest_http2_tests)
if(WIN32)
set_tests_properties(guest_http2 PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceHttp2>")
endif()
endif()
+12 -11
View File
@@ -214,23 +214,24 @@ int APS5_VABI sceHttp2GetMemoryPoolStats() {
return 0;
}
int APS5_VABI sceHttp2CookieFlush(void) {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceHttp2CookieFlush(int id) {
(void)id;
return 0;
}
int APS5_VABI sceHttp2CreateCookieBox(void) {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceHttp2CreateCookieBox(int lib_http2_ctx_id) {
(void)lib_http2_ctx_id;
return g_nextHandle.fetch_add(1, std::memory_order_relaxed);
}
int APS5_VABI sceHttp2SetCookieBox(int id, int cookie_box_id) {
(void)id;
(void)cookie_box_id;
return 0;
}
int APS5_VABI sceHttp2SetCookieBox(void) {
NotImplemented_nid_no_patch(__func__);
return 0;
}
int APS5_VABI sceHttp2SetRequestNoContentLength(void) {
NotImplemented_nid_no_patch(__func__);
int APS5_VABI sceHttp2SetRequestNoContentLength(int id) {
(void)id;
return 0;
}
+36
View File
@@ -0,0 +1,36 @@
#include "SceTypes.hpp"
#include <cstdint>
#include <cstdlib>
extern "C" {
int APS5_VABI sceHttp2Init(int, int, std::size_t, int);
int APS5_VABI sceHttp2CreateTemplate(int, const char*, int, int);
int APS5_VABI sceHttp2CreateRequestWithURL(int, const char*, const char*, std::uint64_t);
int APS5_VABI sceHttp2CreateCookieBox(int);
int APS5_VABI sceHttp2SetCookieBox(int, int);
int APS5_VABI sceHttp2CookieFlush(int);
int APS5_VABI sceHttp2SetRequestNoContentLength(int);
int APS5_VABI sceHttp2SendRequest(int, const void*, std::size_t);
int APS5_VABI sceHttp2Term(int);
}
static void Require(bool value) { if (!value) std::abort(); }
int main() {
const int context = sceHttp2Init(1, 1, 0x10000, 4);
Require(context > 0);
const int box = sceHttp2CreateCookieBox(context);
const int other = sceHttp2CreateCookieBox(context);
Require(box > 0 && other > 0 && box != other && box != context);
const int tmpl = sceHttp2CreateTemplate(context, "agent", 2, 0);
Require(tmpl > 0 && tmpl != box && tmpl != other);
Require(sceHttp2SetCookieBox(tmpl, box) == 0);
Require(sceHttp2SetCookieBox(tmpl, 0) == 0);
const int request = sceHttp2CreateRequestWithURL(tmpl, "POST", "https://example.com/", 16);
Require(request > 0);
Require(sceHttp2SetCookieBox(request, other) == 0);
Require(sceHttp2SetRequestNoContentLength(request) == 0);
Require(sceHttp2CookieFlush(context) == 0);
Require(sceHttp2SendRequest(request, nullptr, 0) == static_cast<int>(0x80436063));
Require(sceHttp2Term(context) == 0);
}
+1
View File
@@ -124,6 +124,7 @@ Throughout the project, every function at every stage either **does exactly what
- [sceHttpUriSweepPath](../../core/libs/prx/libSceHttp/src/Uri.cpp) (libSceHttp) - behaviour follows the [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/network/http.cpp) reimplementation of the PS4 library and its tests (including the PS4 SDK example), not confirmed on a PS5 title or hardware. It is not RFC 3986 5.2.4: a path that doesn't start with `/` is copied unchanged and a trailing `.` or `..` without a slash is kept. Unlike shadPS4, nothing at or past `srcSize - 1` is read, and `srcSize == 1` writes only the terminator
- [sceHttpSetResponseHeaderMaxSize, sceHttpRedirectCacheFlush, sceHttpsUnloadCert](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - signatures follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/main/src/core/libraries/network/http.cpp) (PS4); no PS5 reference has them
- [sceHttp2GetMemoryPoolStats](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - unknown signature
- [libSceHttp2 cookie boxes](../../core/libs/prx/libSceHttp2/Export.cpp) (libSceHttp2) - `sceHttp2CreateCookieBox` is taken to take the library context id first, as in the [prosper](https://github.com/mattias800/prosper) reimplementation; further arguments are unknown and ignored. `sceHttp2SetRequestNoContentLength` is assumed to take only the request id. Cookies are never stored, so `sceHttp2CookieFlush` has nothing to discard
- [sceNetGetMemoryPoolStats](../../core/libs/prx/libSceNet/Export.cpp) (libSceNet) - unknown signature
- [sceHttpSetRequestStatusCallback](../../core/libs/prx/libSceHttp/Export.cpp) (libSceHttp) - no reference implements it (shadPS4 only logs and returns 0); when the callback runs and what status it gets is unknown
- [sceNpSessionSignalingGetMemoryInfo](../../core/libs/prx/libSceNpSessionSignaling/Export.cpp) (libSceNpSessionSignaling) - unknown signature