Common: Add HttpRequest to simplify HTTP requests

Too much boilerplate that is duplicated if we use curl directly.
Let's add a simple wrapper class that hides the implementation details
and just allows to simply make HTTP requests and get responses.
This commit is contained in:
Léo Lam
2017-06-12 17:17:05 +02:00
parent 77c0539b5e
commit 18678afa6d
8 changed files with 170 additions and 79 deletions

View File

@ -0,0 +1,32 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
namespace Common
{
class HttpRequest final
{
public:
HttpRequest();
~HttpRequest();
bool IsValid() const;
using Response = std::optional<std::vector<u8>>;
Response Get(const std::string& url);
Response Post(const std::string& url, const std::vector<u8>& payload);
Response Post(const std::string& url, const std::string& payload);
private:
class Impl;
std::unique_ptr<Impl> m_impl;
};
} // namespace Common