104 void buildHeaders(std::vector<char> &buffer,
bool addBodyLine =
true)
const;
124 std::string
const &
protocol()
const;
An abstract interface for all HTTP response body sources.
Definition ResponseBody.hpp:16
A simple data aggregate for the HTTP response status line.
Definition Response.hpp:16
ResponseStartLine()
Definition Response.cpp:8
std::string protocol
The HTTP protocol version (e.g., "HTTP/1.1").
Definition Response.hpp:20
std::string reasonPhrase
The human-readable reason (e.g., "OK", "Not Found").
Definition Response.hpp:22
HttpStatus statusCode
The numerical status code (e.g., 200, 404).
Definition Response.hpp:21
void cleanupBody_()
Internal: safely deletes the current body object.
Headers headers_
Definition Response.hpp:151
Headers & headers()
Gets a mutable reference to the response headers.
Definition Response.cpp:75
Response & clear()
Resets the response to a default state, ready for reuse. Cleans up any existing body and resets heade...
Definition Response.cpp:68
Response & setNoBody(bool removeContentHeaders=true)
Sets the response to have no body. Cleans up any existing body.
Definition Response.cpp:14
~Response()
Definition Response.cpp:11
Response & setBodyFromFile(std::string const &fpath, std::string const &contentType)
Sets the response body to stream from a file. Creates a FileBody object to manage the file descriptor...
Definition Response.cpp:32
static char const * getReasonPhrase_(HttpStatus status)
Internal: maps a Status enum to its standard string.
std::string const & reasonPhrase() const
Gets the current reason phrase (e.g., "Not Found").
Definition Response.cpp:79
HttpStatus status() const
Gets the current status code.
Definition Response.cpp:77
Response const & operator=(Response const &)
Response(Response const &)
ResponseStartLine startLine_
Definition Response.hpp:150
std::string const & customMessage() const
Gets the custom error message, if any.
Definition Response.cpp:80
Response & setBodyInMemory(std::string const &data, std::string const &contentType)
Sets the response body from an in-memory string. This takes ownership of the data (by copying) and se...
Definition Response.cpp:24
IResponseBody * body() const
Gets a pointer to the (read-only) response body.
Definition Response.cpp:13
Response & status(HttpStatus statusCode)
Sets the response status and automatically syncs the reason phrase.
Definition Response.cpp:61
Response & setBodyFromCgi(int pipeFd, bool hasHeaderParsing)
Sets the response body to stream from a CGI pipe.
Definition Response.cpp:40
std::string customError_
Definition Response.hpp:153
void buildHeaders(std::vector< char > &buffer, bool addBodyLine=true) const
Appends the fully formatted start-line and headers to a buffer.
Definition Response.cpp:46
IResponseBody * body_
Definition Response.hpp:152
Response()
Definition Response.cpp:10
std::string const & protocol() const
Gets the current protocol string (e.g., "HTTP/1.1").
Definition Response.cpp:78
Definition IArgument.hpp:5
HttpStatus
Definition HttpStatus.hpp:11