// Copyright 2017 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. #pragma once #include #include #include #include #include #include #include #include "Common/CommonTypes.h" namespace Common { class HttpRequest final { public: // Return false to abort the request using ProgressCallback = std::function; explicit HttpRequest(std::chrono::milliseconds timeout_ms = std::chrono::milliseconds{3000}, ProgressCallback callback = nullptr); ~HttpRequest(); bool IsValid() const; using Response = std::optional>; using Headers = std::map>; void SetCookies(const std::string& cookies); void UseIPv4(); void FollowRedirects(long max = 1); Response Get(const std::string& url, const Headers& headers = {}); Response Post(const std::string& url, const std::vector& payload, const Headers& headers = {}); Response Post(const std::string& url, const std::string& payload, const Headers& headers = {}); private: class Impl; std::unique_ptr m_impl; }; } // namespace Common