Wt
4.11.0
|
An HTTP client message (request or response). More...
#include <Wt/Http/Message.h>
Classes | |
class | Header |
An HTTP message header. More... | |
Public Member Functions | |
Message () | |
Constructor. | |
Message (std::vector< Header > headers) | |
Constructor. | |
Message (const Message &message) | |
Copy constructor. | |
~Message ()=default | |
Destructor. | |
Message & | operator= (const Message &other) |
Copy assignment operator. | |
void | setStatus (int status) |
Sets the status code. | |
int | status () const |
Returns the status code. | |
void | setHeader (const std::string &name, const std::string &value) |
Sets a header value. | |
void | addHeader (const std::string &name, const std::string &value) |
Adds a header value. | |
const std::vector< Header > & | headers () const |
Returns the headers. | |
const std::string * | getHeader (const std::string &name) const |
Returns a header value. | |
void | addBodyText (const std::string &text) |
Concatenates body text. | |
std::string | body () const |
Returns the body text. | |
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.
Concatenates body text.
Adds the text
to the message body.
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.
Returns a header value.
Returns 0 if no header with that name is found.
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.
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).