35 lines
965 B
C++
35 lines
965 B
C++
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
#include <unordered_map>
|
||
|
|
|
||
|
|
class HttpRequest
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
HttpRequest() = default;
|
||
|
|
|
||
|
|
void setMethod(const std::string_view method);
|
||
|
|
const std::string getMethod() const;
|
||
|
|
|
||
|
|
void setPath(const std::string_view path);
|
||
|
|
const std::string getPath() const;
|
||
|
|
|
||
|
|
void setVersion(const std::string_view version);
|
||
|
|
const std::string getVersion() const;
|
||
|
|
|
||
|
|
void addHeader(const std::string_view key, const std::string_view value);
|
||
|
|
bool hasHeader(const std::string_view key) const;
|
||
|
|
std::string getHeader(const std::string_view key) const;
|
||
|
|
const std::unordered_map<std::string, std::string> &getHeaders() const;
|
||
|
|
|
||
|
|
void setBody(const std::string_view body);
|
||
|
|
const std::string getBody() const;
|
||
|
|
|
||
|
|
private:
|
||
|
|
std::string method_; // GET, POST
|
||
|
|
std::string path_; // /index.html
|
||
|
|
std::string version_; // HTTP/1.1
|
||
|
|
std::unordered_map<std::string, std::string> headers_;
|
||
|
|
std::string body_;
|
||
|
|
};
|