mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-07-09 17:24:49 -06:00
core: Fix HTTPC behaviour when post data is pending
This commit is contained in:
parent
9293767e1d
commit
1d59c9a0fc
@ -281,7 +281,7 @@ std::string Context::ParseMultipartFormData() {
|
|||||||
void Context::MakeRequest() {
|
void Context::MakeRequest() {
|
||||||
ASSERT(state == RequestState::NotStarted);
|
ASSERT(state == RequestState::NotStarted);
|
||||||
|
|
||||||
state = RequestState::ConnectingToServer;
|
state = RequestState::SendingRequest;
|
||||||
|
|
||||||
static const std::unordered_map<RequestMethod, std::string> request_method_strings{
|
static const std::unordered_map<RequestMethod, std::string> request_method_strings{
|
||||||
{RequestMethod::Get, "GET"}, {RequestMethod::Post, "POST"},
|
{RequestMethod::Get, "GET"}, {RequestMethod::Post, "POST"},
|
||||||
@ -861,10 +861,24 @@ void HTTP_C::GetRequestState(Kernel::HLERequestContext& ctx) {
|
|||||||
LOG_DEBUG(Service_HTTP, "called, context_handle={}", context_handle);
|
LOG_DEBUG(Service_HTTP, "called, context_handle={}", context_handle);
|
||||||
|
|
||||||
Context& http_context = GetContext(context_handle);
|
Context& http_context = GetContext(context_handle);
|
||||||
|
RequestState state = http_context.state;
|
||||||
|
|
||||||
|
// When POST data is pending to be set, HTTPC stays in the SendingRequest
|
||||||
|
// state until NotifyFinishSendPostData is called. Most likely HTTPC
|
||||||
|
// already started the HTTP request at this point, has send the headers
|
||||||
|
// and is waiting for the client to set the post body to send.
|
||||||
|
// We cannot do that with httplib so instead fake the state to SendingRequest
|
||||||
|
// if post data is pending. TODO(PabloMK7): Fix if we get a more
|
||||||
|
// flexible HTTP library.
|
||||||
|
if (state == RequestState::NotStarted && http_context.post_pending_request) {
|
||||||
|
state = RequestState::SendingRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(Service_HTTP, "called, context_handle={} state={}", context_handle, state);
|
||||||
|
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.PushEnum<RequestState>(http_context.state);
|
rb.PushEnum<RequestState>(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) {
|
||||||
|
|||||||
@ -55,6 +55,8 @@ enum class RequestState : u8 {
|
|||||||
ConnectingToServer = 0x5,
|
ConnectingToServer = 0x5,
|
||||||
|
|
||||||
/// Request in progress, sending HTTP request.
|
/// Request in progress, sending HTTP request.
|
||||||
|
/// HTTPC stays in this state when there is POST
|
||||||
|
/// data pending.
|
||||||
SendingRequest = 0x6,
|
SendingRequest = 0x6,
|
||||||
|
|
||||||
// Request in progress, receiving HTTP response and headers.
|
// Request in progress, receiving HTTP response and headers.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user