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. | |
| Message (std::vector< Header > headers) | |
| Constructor. | |
| Message (const Message &message) | |
| Copy constructor. | |
| 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 |
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.
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.
| 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).
1.7.6.1