111 void addHeader(
const std::string& key,
const std::string& value);
156 void _splitCgiOutput(
const std::string& raw, std::string& headers, std::string& body);
157 bool _parseCgiHeaders(
const std::string& headerBlock, std::string& contentType);
Declares the CGIManager class responsible for executing CGI scripts and redirecting their input/outpu...
A DataStore is a flexible data structure, it is either a RAM buffer or a file on disk,...
Parses and stores the entire HTTP request entity (headers, body). Utilizes a State Machine to handle ...
ResponseState
Tracks the progress of sending the response to the client.
BuildPhase
Tracks the incremental construction of the response body. exclusivly for POST.
Stores per-server configuration directives. This class encapsulates the configuration for a specific ...
CGIManager * _cgiInstance
BuildPhase getBuildPhase() const
std::map< std::string, std::string > _headers
bool _sendBodyDataStore(int fd)
std::vector< char > _streamBuf
const std::string & getVersion() const
void setResponsePhrase(const std::string &phrase)
void _finalizeSuccess(const std::string &contentType)
void buildErrorPage(const std::string &code, const ServerConf &config)
Fast-tracks the response to an error state. Loads the appropriate error page from config or default H...
void addCookie(const Request &req)
const std::vector< std::string > & getSetCookies() const
bool buildResponse(Request &req, const ServerConf &config)
Analyzes the Request and Location settings to prepare the response. Sets the status code,...
std::string _generateHeaderString()
bool _sendBodyChunked(int fd)
std::string _drainDataStore()
DataStore _responseDataStore
bool _sendBodyFile(int fd)
Response & operator=(const Response &other)
CGIManager * getCgiInstance() const
const ServerConf * _cachedConfig
int getCgiOutputFd() const
Returns the CGI output pipe fd for epoll registration.
bool sendSlice(int fd)
Sends a slice of the response to the client socket. To be called during a POLLOUT event.
void addHeader(const std::string &key, const std::string &value)
Adds a header to the response (e.g., "Content-Type", "text/html").
ResponseState getResponseState() const
void finalizeCgiResponse()
Finalizes the CGI response after all output has been read. Parses CGI output headers,...
std::string _lookupReasonPhrase(const std::string &code)
bool readCgiOutput()
Called by ServerManager when the CGI pipe is readable. Reads available data into _responseDataStore.
std::vector< std::string > _setCookies
void _serveFile(const std::string &path, const ServerConf &config)
bool _parseCgiHeaders(const std::string &headerBlock, std::string &contentType)
void _handleGet(const Request &req, const LocationConf &loc, const ServerConf &config)
const std::string & getResponsePhrase() const
std::string _headerBuffer
void _splitCgiOutput(const std::string &raw, std::string &headers, std::string &body)
ResponseState _responseState
std::string _response_phrase
const std::string & getStatusCode() const
void cgiTimeout(const ServerConf &config)
Called by ServerManager when the CGI process times out. Kills the process and builds a 504 error page...
bool _handlePost(Request &req, const LocationConf &loc, const ServerConf &config)
std::string _postFilename
bool _handleCGI(Request &req, const LocationConf &loc, const ServerConf &config)
void _handleDelete(const Request &req, const LocationConf &loc, const ServerConf &config)
void setStatusCode(const std::string &code)
bool _continuePostWrite(Request &req)
bool _sendBodyStatic(int fd)