An HTTP response that clients can read and servers write.
- See also
- HttpServer
-
Http
|
void | setProto (const String &p) |
| Sets the response status code (such as 200 [default] for OK)
|
|
String | proto () const |
| Returns the protocol of the response (such as HTTP/1.1)
|
|
bool | is (StatusType code) const |
| Returns true if the response status code belongs to the type given (2xx, 3xx, 4xx or 5xx).
|
|
bool | ok () const |
| Returns true if the response is OK (code 2xx)
|
|
int | code () const |
| Returns the status code.
|
|
String | socketError () const |
| Returns a string representation of the last socket error.
|
|
void | setHeader (const String &header, const String &value) |
| Adds a message header with name header and value value
|
|
String | header (const String &name) const |
| Returns the value of the header named.
|
|
bool | hasHeader (const String &name) const |
| Returns true if the message includes the given header name.
|
|
const String & | protocol () const |
| Returns the HTTP protocol (e.g. More...
|
|
void | put (const ByteArray &data) |
| Sets the body of the message as a binary blob.
|
|
void | put (const String &body) |
| Sets the body of the message as a text string.
|
|
void | put (const Var &data) |
| Sets the body of the message as a JSON document.
|
|
void | put (const File &file) |
| Sets the body of the message as a file.
|
|
const ByteArray & | body () const |
| Returns the binary body of the message.
|
|
String | text () const |
| Returns the message body as text.
|
|
Var | json () const |
| Returns the message body interpreted as JSON.
|
|
bool | sendHeaders () |
| Sends the currently set headers and starts the message body.
|
|
void | write (const String &text) |
| Writes the given text string to the message body.
|
|
int | write (const char *buffer, int n) |
| Writes the given buffer to the message body.
|
|
void | writeFile (const String &path, int begin=0, int end=0) |
| Sends the content of the given file in the message body.
|
|
bool | putFile (const String &path, int begin=0, int end=0) |
| Sends the content of the given file as the message body and sets the content-length header.
|
|