Wt
3.3.8
|
An HTTP client message (request or response). More...
#include <Wt/Http/Message>
Classes | |
class | Header |
An HTTP message header. More... | |
Public Member Functions | |
Message () | |
Constructor. More... | |
Message (std::vector< Header > headers) | |
Constructor. More... | |
Message (const Message &message) | |
Copy constructor. | |
void | setStatus (int status) |
Sets the status code. More... | |
int | status () const |
Returns the status code. More... | |
void | setHeader (const std::string &name, const std::string &value) |
Sets a header value. More... | |
void | addHeader (const std::string &name, const std::string &value) |
Adds a header value. More... | |
const std::vector< Header > & | headers () const |
Returns the headers. | |
const std::string * | getHeader (const std::string &name) const |
Returns a header value. More... | |
void | addBodyText (const std::string &text) |
Concatenates body text. More... | |
std::string | body () const |
Returns the body text. More... | |
An HTTP client message (request or response).
This class implements a message that is sent or received by the HTTP Client.
It is not to be confused with Request and Response, which are involved in the web application server handling.
Wt::Http::Message::Message | ( | ) |
Constructor.
This creates an empty message, with an invalid status (-1), no headers and an empty body.
Wt::Http::Message::Message | ( | std::vector< Header > | headers | ) |
Constructor.
This creates an empty message, with an invalid status (-1), an empty body and the given headers.
void Wt::Http::Message::addBodyText | ( | const std::string & | text | ) |
Concatenates body text.
Adds the text
to the message body.
void Wt::Http::Message::addHeader | ( | const std::string & | name, |
const std::string & | value | ||
) |
Adds a header value.
A header is added, even if a header with the same name already was present. This is allowed by HTTP only for certain headers (e.g. Set-Cookie).
std::string Wt::Http::Message::body | ( | ) | const |
Returns the body text.
Returns the body text.
const std::string * Wt::Http::Message::getHeader | ( | const std::string & | name | ) | const |
Returns a header value.
Returns 0 if no header with that name is found.
void Wt::Http::Message::setHeader | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets a header value.
If a header with that value was already defined, it is replaced with the new value. Otherwise, the header is added.
void Wt::Http::Message::setStatus | ( | int | status | ) |
Sets the status code.
int Wt::Http::Message::status | ( | ) | const |
Returns the status code.
This returns the HTTP status code of a response message. Typical values are 200 (OK) or 404 (Not found).