#include <Response.hpp>
|
| std::string | _generateHeaderString () |
| |
| std::string | _lookupReasonPhrase (const std::string &code) |
| |
| void | _handleGet (const Request &req, const LocationConf &loc, const ServerConf &config) |
| |
| bool | _handlePost (Request &req, const LocationConf &loc, const ServerConf &config) |
| |
| bool | _continuePostWrite (Request &req) |
| |
| void | _handleDelete (const Request &req, const LocationConf &loc, const ServerConf &config) |
| |
| bool | _handleCGI (Request &req, const LocationConf &loc, const ServerConf &config) |
| |
| void | _finalizeSuccess (const std::string &contentType) |
| |
| void | _serveFile (const std::string &path, const ServerConf &config) |
| |
| std::string | _drainDataStore () |
| |
| void | _splitCgiOutput (const std::string &raw, std::string &headers, std::string &body) |
| |
| bool | _parseCgiHeaders (const std::string &headerBlock, std::string &contentType) |
| |
| bool | _sendHeader (int fd) |
| |
| bool | _sendBodyStatic (int fd) |
| |
| bool | _sendBodyFile (int fd) |
| |
| bool | _sendBodyDataStore (int fd) |
| |
| bool | _sendBodyChunked (int fd) |
| |
Definition at line 43 of file Response.hpp.
◆ Response() [1/2]
◆ Response() [2/2]
| Response::Response |
( |
const Response & |
other | ) |
|
◆ ~Response()
◆ operator=()
◆ buildResponse()
Analyzes the Request and Location settings to prepare the response. Sets the status code, phrase, and loads the DataStore with content.
- Returns
- true if the response is finished, false if not.
Definition at line 298 of file Response.cpp.
◆ buildErrorPage()
| void Response::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 HTML.
- Parameters
-
| code | The HTTP status code (e.g., "404", "500"). |
Definition at line 364 of file Response.cpp.
◆ sendSlice()
| bool Response::sendSlice |
( |
int |
fd | ) |
|
Sends a slice of the response to the client socket. To be called during a POLLOUT event.
- Parameters
-
| fd | The client socket file descriptor. |
- Returns
- true if the entire response is finished, false if more data remains.
Definition at line 409 of file Response.cpp.
◆ getStatusCode()
| const std::string & Response::getStatusCode |
( |
| ) |
const |
◆ getVersion()
| const std::string & Response::getVersion |
( |
| ) |
const |
◆ getResponsePhrase()
| const std::string & Response::getResponsePhrase |
( |
| ) |
const |
◆ getResponseState()
◆ getBuildPhase()
◆ getCgiInstance()
◆ getCgiOutputFd()
| int Response::getCgiOutputFd |
( |
| ) |
const |
Returns the CGI output pipe fd for epoll registration.
- Returns
- The fd, or -1 if no CGI is active.
Definition at line 870 of file Response.cpp.
◆ readCgiOutput()
| bool Response::readCgiOutput |
( |
| ) |
|
Called by ServerManager when the CGI pipe is readable. Reads available data into _responseDataStore.
- Returns
- true if CGI output is fully consumed (EOF reached), false if more data expected.
Definition at line 877 of file Response.cpp.
◆ cgiTimeout()
| void Response::cgiTimeout |
( |
const ServerConf & |
config | ) |
|
Called by ServerManager when the CGI process times out. Kills the process and builds a 504 error page.
Definition at line 910 of file Response.cpp.
◆ finalizeCgiResponse()
| void Response::finalizeCgiResponse |
( |
| ) |
|
Finalizes the CGI response after all output has been read. Parses CGI output headers, builds the HTTP response, transitions to sendable state.
Definition at line 930 of file Response.cpp.
◆ setStatusCode()
| void Response::setStatusCode |
( |
const std::string & |
code | ) |
|
◆ setResponsePhrase()
| void Response::setResponsePhrase |
( |
const std::string & |
phrase | ) |
|
◆ addHeader()
| void Response::addHeader |
( |
const std::string & |
key, |
|
|
const std::string & |
value |
|
) |
| |
Adds a header to the response (e.g., "Content-Type", "text/html").
Definition at line 1099 of file Response.cpp.
◆ addCookie()
| void Response::addCookie |
( |
const Request & |
req | ) |
|
if you want accessible by the HTTP server, not by JavaScript. add this V cookie += "; HttpOnly";
Definition at line 1118 of file Response.cpp.
◆ getSetCookies()
| const std::vector< std::string > & Response::getSetCookies |
( |
| ) |
const |
◆ _generateHeaderString()
| std::string Response::_generateHeaderString |
( |
| ) |
|
|
private |
◆ _lookupReasonPhrase()
| std::string Response::_lookupReasonPhrase |
( |
const std::string & |
code | ) |
|
|
private |
◆ _handleGet()
◆ _handlePost()
◆ _continuePostWrite()
| bool Response::_continuePostWrite |
( |
Request & |
req | ) |
|
|
private |
◆ _handleDelete()
◆ _handleCGI()
◆ _finalizeSuccess()
| void Response::_finalizeSuccess |
( |
const std::string & |
contentType | ) |
|
|
private |
◆ _serveFile()
| void Response::_serveFile |
( |
const std::string & |
path, |
|
|
const ServerConf & |
config |
|
) |
| |
|
private |
◆ _drainDataStore()
| std::string Response::_drainDataStore |
( |
| ) |
|
|
private |
◆ _splitCgiOutput()
| void Response::_splitCgiOutput |
( |
const std::string & |
raw, |
|
|
std::string & |
headers, |
|
|
std::string & |
body |
|
) |
| |
|
private |
◆ _parseCgiHeaders()
| bool Response::_parseCgiHeaders |
( |
const std::string & |
headerBlock, |
|
|
std::string & |
contentType |
|
) |
| |
|
private |
◆ _sendHeader()
| bool Response::_sendHeader |
( |
int |
fd | ) |
|
|
private |
◆ _sendBodyStatic()
| bool Response::_sendBodyStatic |
( |
int |
fd | ) |
|
|
private |
◆ _sendBodyFile()
| bool Response::_sendBodyFile |
( |
int |
fd | ) |
|
|
private |
◆ _sendBodyDataStore()
| bool Response::_sendBodyDataStore |
( |
int |
fd | ) |
|
|
private |
◆ _sendBodyChunked()
| bool Response::_sendBodyChunked |
( |
int |
fd | ) |
|
|
private |
◆ _statusCode
| std::string Response::_statusCode |
|
private |
◆ _version
| std::string Response::_version |
|
private |
◆ _response_phrase
| std::string Response::_response_phrase |
|
private |
◆ _writeBufferSize
| size_t Response::_writeBufferSize |
|
private |
◆ _responseDataStore
◆ _totalBytesSent
| size_t Response::_totalBytesSent |
|
private |
◆ _headers
| std::map<std::string, std::string> Response::_headers |
|
private |
◆ _setCookies
| std::vector<std::string> Response::_setCookies |
|
private |
◆ _fileFd
◆ _fileSize
| size_t Response::_fileSize |
|
private |
◆ _streamBuf
| std::vector<char> Response::_streamBuf |
|
private |
◆ _streamBufLen
| size_t Response::_streamBufLen |
|
private |
◆ _streamBufSent
| size_t Response::_streamBufSent |
|
private |
◆ _cgiInstance
◆ _currentChunkSize
| size_t Response::_currentChunkSize |
|
private |
◆ _buildPhase
◆ _cachedConfig
◆ _postOutFd
◆ _postWritePos
| size_t Response::_postWritePos |
|
private |
◆ _postFilename
| std::string Response::_postFilename |
|
private |
◆ _responseState
◆ _headerBuffer
| std::string Response::_headerBuffer |
|
private |
The documentation for this class was generated from the following files: