#pragma once #if !defined(MIJIN_NET_HTTP_HPP_INCLUDED) #define MIJIN_NET_HTTP_HPP_INCLUDED 1 #include #include #include #include "../io/stream.hpp" namespace mijin { struct HTTPVersion { unsigned major; unsigned minor; }; struct HTTPRequest { std::string address; std::string method = "GET"; std::multimap headers; std::string body; explicit HTTPRequest(std::string address_) noexcept : address(std::move(address_)) {} }; struct HTTPResponse { HTTPVersion version; unsigned status; std::string statusMessage; std::multimap headers; std::string content; }; class HTTPStream { private: Stream* base_; public: HTTPStream(Stream& base) noexcept : base_(&base) { MIJIN_ASSERT(base_ != nullptr, "Invalid parameter for base."); } Task> c_request(HTTPRequest request) noexcept; private: Task c_writeRequest(const HTTPRequest& request) noexcept; Task> c_readResponse() noexcept; }; } #endif // !defined(MIJIN_NET_HTTP_HPP_INCLUDED)