diff --git a/src/core/hle/service/http/http_c.cpp b/src/core/hle/service/http/http_c.cpp index b1f47373b..59cc47b3a 100644 --- a/src/core/hle/service/http/http_c.cpp +++ b/src/core/hle/service/http/http_c.cpp @@ -281,7 +281,7 @@ std::string Context::ParseMultipartFormData() { void Context::MakeRequest() { ASSERT(state == RequestState::NotStarted); - state = RequestState::ConnectingToServer; + state = RequestState::SendingRequest; static const std::unordered_map request_method_strings{ {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); 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); rb.Push(ResultSuccess); - rb.PushEnum(http_context.state); + rb.PushEnum(state); } void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/http/http_c.h b/src/core/hle/service/http/http_c.h index 28f7c4795..972a1b22f 100644 --- a/src/core/hle/service/http/http_c.h +++ b/src/core/hle/service/http/http_c.h @@ -55,6 +55,8 @@ enum class RequestState : u8 { ConnectingToServer = 0x5, /// Request in progress, sending HTTP request. + /// HTTPC stays in this state when there is POST + /// data pending. SendingRequest = 0x6, // Request in progress, receiving HTTP response and headers.