ASL
HttpResponse Class Reference

Detailed Description

An HTTP response that clients can read and servers write.

See also
HttpServer
Http

#include <Http.h>

Inheritance diagram for HttpResponse:
HttpMessage

Public Types

enum  StatusType { OK = 2 , REDIRECT = 3 , CLIENT_ERROR = 4 , SERVER_ERROR = 5 }
 Types of status codes. More...
 

Public Member Functions

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.
 
- Public Member Functions inherited from HttpMessage
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 Stringprotocol () 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 ByteArraybody () 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.
 

Member Enumeration Documentation

◆ StatusType

enum StatusType

Types of status codes.

Enumerator
OK 

Status 2xx OK.

REDIRECT 

Status 3xx Redirection.

CLIENT_ERROR 

Status 4xx Client Error.

SERVER_ERROR 

Status 5xx Server Error.


The documentation for this class was generated from the following file: