Webserv
|
A data container for an HTTP response. More...
#include <HttpResponse.hpp>
Public Member Functions | |
HttpResponse () | |
HttpResponse (Status code, std::string const &httpVersion) | |
HttpResponse (HttpResponse const &) | |
HttpResponse const & | operator= (HttpResponse const &) |
~HttpResponse () | |
void | setStatus (Status s) |
void | setNoBody () |
void | setBodyInMemory (std::vector< char > const &, std::string const &mimeType) |
void | setBodyFromFile (int fd, size_t size) |
void | setBodyFromFile (int fd, size_t size, std::string const &mimeType) |
void | setBodyFromCgi (int pipe_fd) |
Status | getStatus () const |
char const * | getResponsePhrase () const |
HeaderMap & | getHeaders () |
HeaderMap const & | getHeaders () const |
std::string const & | getVersion () const |
BodySourceType | getBodyType () const |
std::string | buildHeaders () const |
Public Attributes | |
union { | |
struct { | |
std::vector< char > * data | |
size_t sent | |
} inMemoryBody | |
Details for in-memory bodies. More... | |
struct { | |
int fd | |
size_t totalSize | |
size_t sent | |
} fileBody | |
Details for file-based bodies. More... | |
struct { | |
int pipe_fd | |
} cgiBody | |
Details for CGI-based bodies. More... | |
}; |
Private Member Functions | |
void | cleanupBody () |
Private Attributes | |
std::string | httpVersion_ |
Status | statusCode_ |
HeaderMap | headers_ |
BodySourceType | bodyType_ |
A data container for an HTTP response.
This object is populated by a handler and then serialized into a raw HTTP response string by the ResponseBuilder.
http::HttpResponse::HttpResponse | ( | ) |
http::HttpResponse::HttpResponse | ( | Status | code, |
std::string const & | httpVersion ) |
http::HttpResponse::HttpResponse | ( | HttpResponse const & | rhs | ) |
http::HttpResponse::~HttpResponse | ( | ) |
std::string http::HttpResponse::buildHeaders | ( | ) | const |
|
private |
BodySourceType http::HttpResponse::getBodyType | ( | ) | const |
HeaderMap & http::HttpResponse::getHeaders | ( | ) |
HeaderMap const & http::HttpResponse::getHeaders | ( | ) | const |
char const * http::HttpResponse::getResponsePhrase | ( | ) | const |
Status http::HttpResponse::getStatus | ( | ) | const |
std::string const & http::HttpResponse::getVersion | ( | ) | const |
HttpResponse const & http::HttpResponse::operator= | ( | HttpResponse const & | rhs | ) |
void http::HttpResponse::setBodyFromCgi | ( | int | pipe_fd | ) |
void http::HttpResponse::setBodyFromFile | ( | int | fd, |
size_t | size ) |
void http::HttpResponse::setBodyFromFile | ( | int | fd, |
size_t | size, | ||
std::string const & | mimeType ) |
void http::HttpResponse::setBodyInMemory | ( | std::vector< char > const & | body, |
std::string const & | mimeType ) |
void http::HttpResponse::setNoBody | ( | ) |
void http::HttpResponse::setStatus | ( | Status | s | ) |
union { ... } http::HttpResponse |
|
private |
struct { ... } http::HttpResponse::cgiBody |
Details for CGI-based bodies.
std::vector<char>* http::HttpResponse::data |
Pointer to the internal buffer holding the body.
int http::HttpResponse::fd |
File descriptor to read from.
struct { ... } http::HttpResponse::fileBody |
Details for file-based bodies.
|
private |
|
private |
struct { ... } http::HttpResponse::inMemoryBody |
Details for in-memory bodies.
int http::HttpResponse::pipe_fd |
Pipe descriptor to read from.
size_t http::HttpResponse::sent |
Tracks bytes sent by the Reactor.
|
private |
size_t http::HttpResponse::totalSize |
Total size of the file.