diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index 25f9f4e36..eefcf8fcc 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -98,6 +98,29 @@ void HTTP_C::CloseContext(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } +void HTTP_C::InitializeConnectionSession(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x8, 1, 2); + const u32 context_handle = rp.Pop(); + rp.PopPID(); + + auto itr = contexts.find(context_handle); + if (itr == contexts.end()) { + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(ERROR_CONTEXT_ERROR); + LOG_ERROR(Service_HTTP, "called, context {} not found", context_handle); + return; + } + + // TODO(Subv): What happens if you try to initalize a context that's currently being used? + ASSERT(itr->second.state == RequestState::NotStarted); + + // TODO(B3N30): Check what gets initalized + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); + LOG_WARNING(Service_HTTP, "(STUBBED) called, context_id={}", context_handle); +} + void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x11, 3, 4); const u32 context_handle = rp.Pop(); @@ -123,7 +146,7 @@ void HTTP_C::AddRequestHeader(Kernel::HLERequestContext& ctx) { return m.name == name; }) == itr->second.headers.end()); - itr->second.headers.push_back(Context::RequestHeader{name, value}); + itr->second.headers.emplace_back(name, value); IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); @@ -142,7 +165,7 @@ HTTP_C::HTTP_C() : ServiceFramework("http:C", 32) { {0x00050040, nullptr, "GetRequestState"}, {0x00060040, nullptr, "GetDownloadSizeState"}, {0x00070040, nullptr, "GetRequestError"}, - {0x00080042, nullptr, "InitializeConnectionSession"}, + {0x00080042, &HTTP_C::InitializeConnectionSession, "InitializeConnectionSession"}, {0x00090040, nullptr, "BeginRequest"}, {0x000A0040, nullptr, "BeginRequestAsync"}, {0x000B0082, nullptr, "ReceiveData"}, diff --git a/src/core/hle/service/http_c.h b/src/core/hle/service/http_c.h index 3ca56e8e9..eace3ff06 100644 --- a/src/core/hle/service/http_c.h +++ b/src/core/hle/service/http_c.h @@ -141,6 +141,17 @@ private: */ void CloseContext(Kernel::HLERequestContext& ctx); + /** + * HTTP_C::InitializeConnectionSession service function + * Inputs: + * 1 : HTTP context handle + * 2 : 0x20, processID translate-header for the ARM11-kernel + * 3 : processID set by the ARM11-kernel + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void InitializeConnectionSession(Kernel::HLERequestContext& ctx); + /** * HTTP_C::AddRequestHeader service function * Inputs: