mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-07-09 17:25:37 -06:00
Stub libSceHttp2 calls using libSceHttp
Also some bug fixes to make sure requests actually work properly.
This commit is contained in:
parent
3f7af4421b
commit
4626c3673e
@ -4,13 +4,22 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
#include "core/libraries/network/http.h"
|
||||
#include "core/libraries/network/http2.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Libraries::Http2 {
|
||||
|
||||
std::map<s32, s32> requests_to_connections{};
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2AbortRequest(s32 req_id) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpAbortRequest(req_id);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to get abort HTTP request, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2AddCookie() {
|
||||
@ -21,7 +30,11 @@ s32 PS4_SYSV_ABI sceHttp2AddCookie() {
|
||||
s32 PS4_SYSV_ABI sceHttp2AddRequestHeader(s32 template_or_req_id, const char* name,
|
||||
const char* value, u32 mode) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpAddRequestHeader(template_or_req_id, name, value, mode);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to add HTTP response header, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2AuthCacheFlush() {
|
||||
@ -52,13 +65,31 @@ s32 PS4_SYSV_ABI sceHttp2CreateCookieBox() {
|
||||
s32 PS4_SYSV_ABI sceHttp2CreateRequestWithURL(s32 tmpl_id, const char* method, const char* url,
|
||||
u64 content_length) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
// Http1 has a connection thing to go through first
|
||||
s32 conn_id = Libraries::Http::sceHttpCreateConnectionWithURL(tmpl_id, url, true);
|
||||
if (conn_id < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to create HTTP connection, error = {:#x}", conn_id);
|
||||
return conn_id;
|
||||
}
|
||||
s32 req_id =
|
||||
Libraries::Http::sceHttpCreateRequestWithURL2(conn_id, method, url, content_length);
|
||||
if (req_id < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to create HTTP request, error = {:#x}", req_id);
|
||||
return req_id;
|
||||
}
|
||||
requests_to_connections[req_id] = conn_id;
|
||||
return req_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2CreateTemplate(s32 ctx_id, const char* user_agent, s32 http_ver,
|
||||
s32 auto_proxy_conf) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 tmpl_id =
|
||||
Libraries::Http::sceHttpCreateTemplate(ctx_id, user_agent, http_ver, auto_proxy_conf);
|
||||
if (tmpl_id < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to create HTTP template, error = {:#x}", tmpl_id);
|
||||
}
|
||||
return tmpl_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2DeleteCookieBox() {
|
||||
@ -68,7 +99,17 @@ s32 PS4_SYSV_ABI sceHttp2DeleteCookieBox() {
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2DeleteRequest(s32 req_id) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpDeleteRequest(req_id);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to delete HTTP request, error = {:#x}", result);
|
||||
return result;
|
||||
}
|
||||
s32 conn_id = requests_to_connections[req_id];
|
||||
result = Libraries::Http::sceHttpDeleteConnection(conn_id);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to delete HTTP connection, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2DeleteTemplate() {
|
||||
@ -78,7 +119,11 @@ s32 PS4_SYSV_ABI sceHttp2DeleteTemplate() {
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2GetAllResponseHeaders(s32 req_id, char** header, u64* header_size) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpGetAllResponseHeaders(req_id, header, header_size);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to get HTTP response headers, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2GetAuthEnabled() {
|
||||
@ -116,15 +161,22 @@ s32 PS4_SYSV_ABI sceHttp2GetResponseContentLength() {
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2GetStatusCode(s32 request_id, s32* status_code) {
|
||||
s32 PS4_SYSV_ABI sceHttp2GetStatusCode(s32 req_id, s32* status_code) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpGetStatusCode(req_id, status_code);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to get HTTP status code, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2Init(s32 net_id, s32 ssl_id, u64 pool_size, s32 max_requests) {
|
||||
LOG_ERROR(Lib_Http2, "(DUMMY) called");
|
||||
static s32 id = 0;
|
||||
return ++id;
|
||||
s32 ctx_id = Libraries::Http::sceHttpInit(net_id, ssl_id, pool_size);
|
||||
if (ctx_id < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to init HTTP context, error = {:#x}", ctx_id);
|
||||
}
|
||||
return ctx_id;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2ReadData() {
|
||||
@ -149,7 +201,11 @@ s32 PS4_SYSV_ABI sceHttp2RemoveRequestHeader() {
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2SendRequest(s32 req_id, const void* data, u64 size) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpSendRequest(req_id, data, size);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to send HTTP request, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2SendRequestAsync() {
|
||||
@ -240,7 +296,11 @@ s32 PS4_SYSV_ABI sceHttp2SetRedirectCallback() {
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2SetRequestContentLength(s32 req_id, u64 content_length) {
|
||||
LOG_ERROR(Lib_Http2, "(STUBBED) called");
|
||||
return ORBIS_OK;
|
||||
s32 result = Libraries::Http::sceHttpSetRequestContentLength(req_id, content_length);
|
||||
if (result < 0) {
|
||||
LOG_ERROR(Lib_Http2, "Failed to set HTTP request content length, error = {:#x}", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
s32 PS4_SYSV_ABI sceHttp2SetResolveRetry() {
|
||||
|
||||
@ -88,7 +88,7 @@ s32 UserContext::Initialize() {
|
||||
this->user_agent = std::string{user_agent_buf};
|
||||
|
||||
s32 http_ctx_id = this->parent_ctx->GetHttpCtxId();
|
||||
s32 http_template_id = Libraries::Http2::sceHttp2CreateTemplate(
|
||||
http_template_id = Libraries::Http2::sceHttp2CreateTemplate(
|
||||
http_ctx_id, user_agent_buf,
|
||||
Libraries::Http2::OrbisHttp2HttpVersion::ORBIS_HTTP2_VERSION_2_0, 0);
|
||||
if (http_template_id < 0) {
|
||||
|
||||
@ -306,7 +306,7 @@ s32 sendRequest(s64 request_id, s32 part_index, void* data, u64 data_size,
|
||||
if (resp_info_option) {
|
||||
resp_info_option->http_status = http_status;
|
||||
}
|
||||
if (http_status < 400) {
|
||||
if (http_status >= 400) {
|
||||
result = http_status | 0x82f00000;
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user