diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index 5a700f3fbf..f2e77f2a76 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -2,7 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include +#include #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/ipc.h" #include "core/hle/service/http_c.h" @@ -10,6 +12,24 @@ namespace Service { namespace HTTP { +enum class RequestMethod : u8 { + Get = 0x1, + Post = 0x2, + Head = 0x3, + Put = 0x4, + Delete = 0x5, + PostEmpty = 0x6, + PutEmpty = 0x7, +}; + +enum class RequestState : u8 { + NotStarted = 0x1, // Request has not started yet. + InProgress = 0x5, // Request in progress, sending request over the network. + ReadyToDownloadContent = 0x7, // Ready to download the content. (needs verification) + ReadyToDownload = 0x8, // Ready to download? + TimedOut = 0xA, // Request timed out? +}; + /// Represents a client certificate along with its private key, stored as a byte array of DER data. /// There can only be at most one client certificate context attached to an HTTP context at any /// given time. @@ -32,6 +52,49 @@ struct RootCertChain { std::vector certificates; }; +/// Represents an HTTP context. +struct Context { + struct Proxy { + std::string url; + std::string username; + std::string password; + u16 port; + }; + + struct BasicAuth { + std::string username; + std::string password; + }; + + struct RequestHeader { + std::string name; + std::string value; + }; + + struct PostData { + // TODO(Subv): Support Binary and Raw POST elements. + std::string name; + std::string value; + }; + + struct SSLConfig { + u32 options; + std::weak_ptr client_cert_ctx; + std::weak_ptr root_ca_chain; + }; + + u32 handle; + std::string url; + RequestMethod method; + RequestState state = RequestState::NotStarted; + boost::optional proxy; + boost::optional basic_auth; + SSLConfig ssl_config{}; + u32 socket_buffer_size; + std::vector headers; + std::vector post_data; +}; + void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x1, 1, 4); const u32 shmem_size = rp.Pop(); diff --git a/src/core/hle/service/http_c.h b/src/core/hle/service/http_c.h index 34b0aa54ff..14d8693361 100644 --- a/src/core/hle/service/http_c.h +++ b/src/core/hle/service/http_c.h @@ -4,12 +4,16 @@ #pragma once +#include #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/service.h" namespace Service { namespace HTTP { +struct Context; +struct ClientCertContext; + class HTTP_C final : public ServiceFramework { public: HTTP_C(); @@ -29,6 +33,12 @@ private: void Initialize(Kernel::HLERequestContext& ctx); Kernel::SharedPtr shared_memory = nullptr; + + std::unordered_map contexts; + u32 context_counter = 0; + + std::unordered_map client_certs; + u32 client_certs_counter = 0; }; void InstallInterfaces(SM::ServiceManager& service_manager);