mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 08:13:05 +00:00
net: implement the libSceHttp callback, gzip, chunked, cert and error ABIs
This commit is contained in:
1 parent
f186b35706
commit
12ca1599cf
3 files changed
+163
No files matched your search
@@ -136,6 +136,7 @@ public:
|
||||
bool HttpValidTemplate(Id tmpl_id);
|
||||
bool HttpValidConnection(Id conn_id);
|
||||
bool HttpValidRequest(Id req_id);
|
||||
bool HttpValidBase(Id id);
|
||||
Id HttpCreateConnection(Id tmpl_id, const char* server_name, const char* scheme, uint16_t port,
|
||||
bool enable_keep_alive);
|
||||
Id HttpCreateConnectionWithURL(Id tmpl_id, const char* url, bool enable_keep_alive);
|
||||
@@ -410,6 +411,12 @@ bool Network::HttpValidRequest(Id req_id) {
|
||||
m_requests[req_id.GetId()].used);
|
||||
}
|
||||
|
||||
bool Network::HttpValidBase(Id id) {
|
||||
Common::LockGuard lock(m_mutex);
|
||||
|
||||
return FindHttpBase(id, true) != nullptr;
|
||||
}
|
||||
|
||||
Network::HttpBase* Network::FindHttpBase(Id id, bool include_request) {
|
||||
const auto index = id.GetId();
|
||||
|
||||
@@ -3013,6 +3020,143 @@ int KYTY_SYSV_ABI HttpSetAuthEnabled(int id, int enable) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int HttpCheckBase(int id) {
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
return g_net->HttpValidBase(Network::Id(id)) ? OK : HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpSetRedirectCallback(int id, void* /*cbfunc*/, void* /*user_arg*/) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t id = %d\n", id);
|
||||
|
||||
return HttpCheckBase(id);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpSetCookieRecvCallback(int id, void* /*cbfunc*/, void* /*user_arg*/) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t id = %d\n", id);
|
||||
|
||||
return HttpCheckBase(id);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpSetRequestStatusCallback(int id, void* /*cbfunc*/, void* /*user_arg*/) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t id = %d\n", id);
|
||||
|
||||
return HttpCheckBase(id);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpSetInflateGZIPEnabled(int id, int is_enable) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t id = %d\n"
|
||||
"\t is_enable = %d\n",
|
||||
id, is_enable);
|
||||
|
||||
return HttpCheckBase(id);
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpSetChunkedTransferEnabled(int id, int is_enabled) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t id = %d\n"
|
||||
"\t is_enabled = %d\n",
|
||||
id, is_enabled);
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (is_enabled != 0 && is_enabled != 1) {
|
||||
return HTTP_ERROR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (!g_net->HttpValidRequest(Network::Id(id))) {
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpsLoadCert(int http_ctx_id, int ca_cert_num, const void** /*ca_list*/,
|
||||
const void* /*cert*/, const void* /*priv_key*/) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t http_ctx_id = %d\n"
|
||||
"\t ca_cert_num = %d\n",
|
||||
http_ctx_id, ca_cert_num);
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpValid(Network::Id(http_ctx_id))) {
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpsUnloadCert(int http_ctx_id) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t http_ctx_id = %d\n", http_ctx_id);
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpValid(Network::Id(http_ctx_id))) {
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpsGetSslError(int request_id, int32_t* err_num, uint32_t* detail) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t request_id = %d\n"
|
||||
"\t err_num = 0x%016" PRIx64 "\n"
|
||||
"\t detail = 0x%016" PRIx64 "\n",
|
||||
request_id, reinterpret_cast<uint64_t>(err_num), reinterpret_cast<uint64_t>(detail));
|
||||
|
||||
if (err_num == nullptr || detail == nullptr) {
|
||||
return HTTP_ERROR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
*err_num = 0;
|
||||
*detail = 0;
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpValidRequest(Network::Id(request_id))) {
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpGetLastErrno(int request_id, int* err_num) {
|
||||
PRINT_NAME();
|
||||
|
||||
LOGF("\t request_id = %d\n"
|
||||
"\t err_num = 0x%016" PRIx64 "\n",
|
||||
request_id, reinterpret_cast<uint64_t>(err_num));
|
||||
|
||||
if (err_num == nullptr) {
|
||||
return HTTP_ERROR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
*err_num = 0;
|
||||
|
||||
EXIT_IF(g_net == nullptr);
|
||||
|
||||
if (!g_net->HttpValidRequest(Network::Id(request_id))) {
|
||||
return HTTP_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int KYTY_SYSV_ABI HttpAddRequestHeader(int id, const char* name, const char* value, uint32_t mode) {
|
||||
PRINT_NAME();
|
||||
|
||||
|
||||
Reference in new issue
Block a user