11#include <netinet/in.h>
16#define PARSE_BYTE_SLICE 8192
19 std::string
trim(
const std::string& s);
20 std::string
ipv4ToString(
const struct ::sockaddr_in& addr);
75 const std::string&
getURL()
const;
78 const std::map<std::string, std::string>&
getHeaders()
const;
79 const std::map<std::string, std::string>&
getCookies()
const;
84 std::string
getHeader(
const std::string& key)
const;
89 std::string
getCookie(
const std::string& key)
const;
HTTPMethod
Represents the HTTP methods supported by the server as a bitmask.
A DataStore is a flexible data structure, it is either a RAM buffer or a file on disk,...
ReqState
Represents the current network-reading phase of the HTTP request.
size_t _chunkDecodeOffset
bool isChunkedDone(const std::string &newData) const
Checks if the incoming chunked data contains the terminal "\r\n\r\n". Used to transition from REQ_CHU...
DataStore & getBodyStore()
Returns a reference to the DataStore to allow direct writing from recv().
const std::string & getQuery() const
void _parseRequestLine(const std::string &line)
void _parseHeaderLine(const std::string &line)
HTTPMethod getMethod() const
std::string getHeader(const std::string &key) const
Gets a specific header value.
ReqState getReqState() const
std::string getStatusCode() const
size_t parseHeaders(const std::string &rawBuffer)
Parses the raw buffer containing the HTTP Request-Line and Headers. Transitions state to REQ_BODY,...
void _extractQueryFromURL()
long long getContentLength() const
void _parseCookies(const std::string &cookieHeader)
size_t getMaxBytesToRead() const
const std::string & getURL() const
std::map< std::string, std::string > _headers
const std::map< std::string, std::string > & getHeaders() const
Request & operator=(const Request &other)
const std::map< std::string, std::string > & getCookies() const
std::string getCookie(const std::string &key) const
Gets a specific cookie value.
size_t getTotalBytesRead() const
bool processBodySlice()
Unified method to prepare the body for the Response/CGI phase. For Content-Length bodies,...
std::map< std::string, std::string > _cookies
const std::string & getProtocol() const
std::string ipv4ToString(const struct ::sockaddr_in &addr)
std::string trim(const std::string &s)