mirror of
https://github.com/citra-emu/citra-canary.git
synced 2024-12-23 19:55:34 +00:00
Service/HTTP: Moved declarations to the header file
This commit is contained in:
parent
0606e7010c
commit
65c7ed8445
|
@ -2,9 +2,6 @@
|
|||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/ipc.h"
|
||||
#include "core/hle/service/http_c.h"
|
||||
|
@ -23,93 +20,6 @@ const ResultCode ERROR_CONTEXT_ERROR = // 0xD8A0A066
|
|||
ResultCode(ErrCodes::InvalidContext, ErrorModule::HTTP, ErrorSummary::InvalidState,
|
||||
ErrorLevel::Permanent);
|
||||
|
||||
enum class RequestMethod : u8 {
|
||||
None = 0x0,
|
||||
Get = 0x1,
|
||||
Post = 0x2,
|
||||
Head = 0x3,
|
||||
Put = 0x4,
|
||||
Delete = 0x5,
|
||||
PostEmpty = 0x6,
|
||||
PutEmpty = 0x7,
|
||||
};
|
||||
|
||||
/// The number of request methods, any valid method must be less than this.
|
||||
constexpr u32 TotalRequestMethods = 8;
|
||||
|
||||
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.
|
||||
struct ClientCertContext {
|
||||
u32 handle;
|
||||
std::vector<u8> certificate;
|
||||
std::vector<u8> private_key;
|
||||
};
|
||||
|
||||
/// Represents a root certificate chain, it contains a list of DER-encoded certificates for
|
||||
/// verifying HTTP requests. An HTTP context can have at most one root certificate chain attached to
|
||||
/// it, but the chain may contain an arbitrary number of certificates in it.
|
||||
struct RootCertChain {
|
||||
struct RootCACert {
|
||||
u32 handle;
|
||||
std::vector<u8> certificate;
|
||||
};
|
||||
|
||||
u32 handle;
|
||||
std::vector<RootCACert> 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<ClientCertContext> client_cert_ctx;
|
||||
std::weak_ptr<RootCertChain> root_ca_chain;
|
||||
};
|
||||
|
||||
u32 handle;
|
||||
std::string url;
|
||||
RequestMethod method;
|
||||
RequestState state = RequestState::NotStarted;
|
||||
boost::optional<Proxy> proxy;
|
||||
boost::optional<BasicAuth> basic_auth;
|
||||
SSLConfig ssl_config{};
|
||||
u32 socket_buffer_size;
|
||||
std::vector<RequestHeader> headers;
|
||||
std::vector<PostData> post_data;
|
||||
};
|
||||
|
||||
void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x1, 1, 4);
|
||||
const u32 shmem_size = rp.Pop<u32>();
|
||||
|
|
|
@ -4,15 +4,102 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <boost/optional.hpp>
|
||||
#include "core/hle/kernel/shared_memory.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service {
|
||||
namespace HTTP {
|
||||
|
||||
struct Context;
|
||||
struct ClientCertContext;
|
||||
enum class RequestMethod : u8 {
|
||||
None = 0x0,
|
||||
Get = 0x1,
|
||||
Post = 0x2,
|
||||
Head = 0x3,
|
||||
Put = 0x4,
|
||||
Delete = 0x5,
|
||||
PostEmpty = 0x6,
|
||||
PutEmpty = 0x7,
|
||||
};
|
||||
|
||||
/// The number of request methods, any valid method must be less than this.
|
||||
constexpr u32 TotalRequestMethods = 8;
|
||||
|
||||
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.
|
||||
struct ClientCertContext {
|
||||
u32 handle;
|
||||
std::vector<u8> certificate;
|
||||
std::vector<u8> private_key;
|
||||
};
|
||||
|
||||
/// Represents a root certificate chain, it contains a list of DER-encoded certificates for
|
||||
/// verifying HTTP requests. An HTTP context can have at most one root certificate chain attached to
|
||||
/// it, but the chain may contain an arbitrary number of certificates in it.
|
||||
struct RootCertChain {
|
||||
struct RootCACert {
|
||||
u32 handle;
|
||||
std::vector<u8> certificate;
|
||||
};
|
||||
|
||||
u32 handle;
|
||||
std::vector<RootCACert> 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<ClientCertContext> client_cert_ctx;
|
||||
std::weak_ptr<RootCertChain> root_ca_chain;
|
||||
};
|
||||
|
||||
u32 handle;
|
||||
std::string url;
|
||||
RequestMethod method;
|
||||
RequestState state = RequestState::NotStarted;
|
||||
boost::optional<Proxy> proxy;
|
||||
boost::optional<BasicAuth> basic_auth;
|
||||
SSLConfig ssl_config{};
|
||||
u32 socket_buffer_size;
|
||||
std::vector<RequestHeader> headers;
|
||||
std::vector<PostData> post_data;
|
||||
};
|
||||
|
||||
class HTTP_C final : public ServiceFramework<HTTP_C> {
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue