44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "Cookie.h"
|
|
#include "Http.h"
|
|
#include "ParameterValue.h"
|
|
#include "Session.h"
|
|
#include "Types.h"
|
|
|
|
namespace VWeb {
|
|
class Response {
|
|
public:
|
|
static Ref<Response> FromCode(HttpStatusCode code);
|
|
|
|
public:
|
|
size_t Length{0};
|
|
Ref<Cookies> CookieData{nullptr};
|
|
Ref<Session> 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<std::string> &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<std::string, ParameterValue> m_Headers;
|
|
};
|
|
} // namespace VWeb
|