Fix HTTP RequestState values (fixes Pretendo Network support with HLE http) (#143)

* Fix http RequestState values

* Fix formatting
This commit is contained in:
PabloMK7 2024-06-01 23:26:37 +02:00 committed by GitHub
parent e15d4c0d4a
commit de1f082e75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 10 deletions

View file

@ -381,10 +381,10 @@ void Context::MakeRequestNonSSL(httplib::Request& request, const URLInfo& url_in
if (!client->send(request, response, error)) { if (!client->send(request, response, error)) {
LOG_ERROR(Service_HTTP, "Request failed: {}: {}", error, httplib::to_string(error)); LOG_ERROR(Service_HTTP, "Request failed: {}: {}", error, httplib::to_string(error));
state = RequestState::TimedOut; state = RequestState::Completed;
} else { } else {
LOG_DEBUG(Service_HTTP, "Request successful"); LOG_DEBUG(Service_HTTP, "Request successful");
state = RequestState::ReadyToDownloadContent; state = RequestState::ReceivingBody;
} }
} }
@ -439,10 +439,10 @@ void Context::MakeRequestSSL(httplib::Request& request, const URLInfo& url_info,
if (!client->send(request, response, error)) { if (!client->send(request, response, error)) {
LOG_ERROR(Service_HTTP, "Request failed: {}: {}", error, httplib::to_string(error)); LOG_ERROR(Service_HTTP, "Request failed: {}: {}", error, httplib::to_string(error));
state = RequestState::TimedOut; state = RequestState::Completed;
} else { } else {
LOG_DEBUG(Service_HTTP, "Request successful"); LOG_DEBUG(Service_HTTP, "Request successful");
state = RequestState::ReadyToDownloadContent; state = RequestState::ReceivingBody;
} }
} }
@ -696,6 +696,7 @@ void HTTP_C::ReceiveDataImpl(Kernel::HLERequestContext& ctx, bool timeout) {
http_context.current_copied_data, http_context.current_copied_data,
0, remaining_data); 0, remaining_data);
http_context.current_copied_data += remaining_data; http_context.current_copied_data += remaining_data;
http_context.state = RequestState::Completed;
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} else { } else {
async_data->buffer->Write(http_context.response.body.data() + async_data->buffer->Write(http_context.response.body.data() +

View file

@ -48,12 +48,29 @@ enum class RequestMethod : u8 {
constexpr u32 TotalRequestMethods = 8; constexpr u32 TotalRequestMethods = 8;
enum class RequestState : u8 { enum class RequestState : u8 {
NotStarted = 0x1, // Request has not started yet. /// Request has not started yet.
ConnectingToServer = 0x5, // Request in progress, connecting to server. NotStarted = 0x1,
SendingRequest = 0x6, // Request in progress, sending HTTP request.
ReceivingResponse = 0x7, // Request in progress, receiving HTTP response. /// Request in progress, connecting to server.
ReadyToDownloadContent = 0x8, // Ready to download the content. ConnectingToServer = 0x5,
TimedOut = 0xA, // Request timed out?
/// Request in progress, sending HTTP request.
SendingRequest = 0x6,
// Request in progress, receiving HTTP response and headers.
ReceivingResponse = 0x7,
/// Request in progress, receiving HTTP body. The HTTP module may
/// get stuck in this state if the internal receive buffer gets full.
/// Once the user calls ReceiveData it will get unstuck.
ReceivingBody = 0x8,
/// Request is finished and all data has been received. HTTP transitions
/// to the Completed state shortly afterwards after some cleanup.
Received = 0x9,
/// Request is completed.
Completed = 0xA,
}; };
enum class PostDataEncoding : u8 { enum class PostDataEncoding : u8 {