#pragma once #include "Cookie.h" #include "Http.h" #include "Session.h" #include "Types.h" #include "ParameterValue.h" namespace VWeb { class Response { public: static Ref FromCode(HttpStatusCode code); public: size_t Length{0}; Ref CookieData{nullptr}; Ref SessionData{nullptr}; HttpStatusCode Status{HttpStatusCode::OK}; HttpMethod Method{HttpMethod::GET}; public: std::string GetResponse(); void SetHeader(const std::string &key, ParameterValue &value); void SetHeader(const std::string &key, const std::string &value); void AddHeaders(const std::string &key, const std::vector &values); void AddHeader(const std::string &key, const std::string &value); void SetType(const std::string &type); void AddContent(const std::string &data); void SetStatus(HttpStatusCode); void SetMethod(HttpMethod); void Reset(); Response &operator<<(const std::string &data) { m_Content << data; return *this; } protected: std::string TransformHeaders(const std::string &content); std::string m_Type{"text/html"}; std::stringstream m_Content; std::unordered_map m_Headers; }; } // namespace VWeb