Rudiments
Public Member Functions | List of all members
httpresponse Class Reference

Inherits output.

Public Member Functions

 httpresponse (httpserverapi *sapi)
 
virtual ~httpresponse ()
 
void sendTextHtmlHeader ()
 
void sendTextPlainHeader ()
 
void sendContentTypeHeader (const char *type, const char *subtype)
 
void sendContentTypeHeader (const char *type, const char *subtype, const char *charset)
 
void sendContentTypeHeader (const char *type, const char *subtype, const char *charset, const char *boundary)
 
void sendCrLf ()
 
void setCookie (const char *name, const char *value, const char *domain, const char *path, const char *expires, bool secure)
 
const char * getBoundaryString ()
 
void sendMultiPartBoundary (output *out)
 
void sendFinalMultiPartBoundary (output *out)
 
httpresponsesendStatusHeader (const char *status)
 
httpresponsesendHeader (const char *header)
 
httpresponsesendHeader (const char *header, const char *value)
 
ssize_t write (const byte_t *string, size_t size)
 
ssize_t write (const char *string)
 
ssize_t write (const char *string, size_t length)
 
ssize_t write (char character)
 
ssize_t write (const wchar_t *string)
 
ssize_t write (const wchar_t *string, size_t length)
 
ssize_t write (wchar_t character)
 
ssize_t writeUcs2 (const ucs2_t *string)
 
ssize_t writeUcs2 (const ucs2_t *string, size_t length)
 
ssize_t writeUcs2 (ucs2_t character)
 
ssize_t write (int16_t number)
 
ssize_t write (int32_t number)
 
ssize_t write (int64_t number)
 
ssize_t write (byte_t character)
 
ssize_t write (uint16_t number)
 
ssize_t write (uint32_t number)
 
ssize_t write (uint64_t number)
 
ssize_t write (float number)
 
ssize_t write (double number)
 
ssize_t write (file *filebuffer)
 
- Public Member Functions inherited from output
 output ()
 
virtual ~output ()
 
virtual off64_t setPositionRelativeToBeginning (off64_t offset)
 
virtual off64_t setPositionRelativeToCurrent (off64_t offset)
 
virtual off64_t setPositionRelativeToEnd (off64_t offset)
 
virtual off64_t getPosition ()
 
virtual ssize_t write (const byte_t *string, size_t size, int32_t sec, int32_t usec)
 
virtual ssize_t write (const char *string, int32_t sec, int32_t usec)
 
virtual ssize_t write (const char *string, size_t length, int32_t sec, int32_t usec)
 
virtual ssize_t write (char character, int32_t sec, int32_t usec)
 
virtual ssize_t write (const wchar_t *string, int32_t sec, int32_t usec)
 
virtual ssize_t write (const wchar_t *string, size_t length, int32_t sec, int32_t usec)
 
virtual ssize_t write (wchar_t character, int32_t sec, int32_t usec)
 
virtual ssize_t writeUcs2 (const ucs2_t *string, int32_t sec, int32_t usec)
 
virtual ssize_t writeUcs2 (const ucs2_t *string, size_t length, int32_t sec, int32_t usec)
 
virtual ssize_t writeUcs2 (ucs2_t character, int32_t sec, int32_t usec)
 
virtual ssize_t write (int16_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (int32_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (int64_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (byte_t character, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint16_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint32_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (uint64_t number, int32_t sec, int32_t usec)
 
virtual ssize_t write (float number, int32_t sec, int32_t usec)
 
virtual ssize_t write (double number, int32_t sec, int32_t usec)
 
virtual ssize_t printf (const char *format,...)
 
virtual ssize_t printf (const char *format, va_list *argp)
 
virtual ssize_t printf (const wchar_t *format,...)
 
virtual ssize_t printf (const wchar_t *format, va_list *argp)
 
virtual ssize_t printfUcs2 (const ucs2_t *format,...)
 
virtual ssize_t printfUcs2 (const ucs2_t *format, va_list *argp)
 
void safePrint (byte_t c)
 
void safePrint (const byte_t *str)
 
void safePrint (const byte_t *str, int32_t length)
 
void safePrint (char c)
 
void safePrint (const char *str)
 
void safePrint (const char *str, int32_t length)
 
void printBits (byte_t value)
 
void printBits (uint16_t value)
 
void printBits (uint32_t value)
 
void printBits (uint64_t value)
 
void printBits (char value)
 
void printBits (int16_t value)
 
void printBits (int32_t value)
 
void printBits (int64_t value)
 
void printBits (const byte_t *bits, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size)
 
void printHex (const byte_t *data, uint64_t size, uint16_t indent)
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

The httpresponse class provides methods for generating http responses.

Constructor & Destructor Documentation

◆ httpresponse()

httpresponse::httpresponse ( httpserverapi sapi)

Creates an instance of the httpresponse class.

◆ ~httpresponse()

virtual httpresponse::~httpresponse ( )
virtual

Deletes this instance of the httpresponse class.

Member Function Documentation

◆ getBoundaryString()

const char* httpresponse::getBoundaryString ( )

Returns a boundary string that is useful in building multipart responses.

◆ sendContentTypeHeader() [1/3]

void httpresponse::sendContentTypeHeader ( const char *  type,
const char *  subtype 
)

Sends HTTP header: Content-type: "type"/"subtype" to the browser.

Does not send carriage-returns.

◆ sendContentTypeHeader() [2/3]

void httpresponse::sendContentTypeHeader ( const char *  type,
const char *  subtype,
const char *  charset 
)

Sends HTTP header: Content-type: "type"/"subtype"; charset="charset" to the browser.

If charset is NULL or an empty string then it will be omitted.

Does not send carriage-returns.

◆ sendContentTypeHeader() [3/3]

void httpresponse::sendContentTypeHeader ( const char *  type,
const char *  subtype,
const char *  charset,
const char *  boundary 
)

Sends HTTP header: Content-type: "type"/"subtype"; charset="charset"; boundary="boundary" to the browser.

If either of charset or boundary are NULL or empty strings then it will be omitted.

Does not send carriage-returns.

◆ sendCrLf()

void httpresponse::sendCrLf ( )

Sends carriage-return and line-feed (/r/n) to the browser.

◆ sendFinalMultiPartBoundary()

void httpresponse::sendFinalMultiPartBoundary ( output out)

Sends a final multipart boundary string.

◆ sendHeader() [1/2]

httpresponse* httpresponse::sendHeader ( const char *  header)

Sends an http header.

◆ sendHeader() [2/2]

httpresponse* httpresponse::sendHeader ( const char *  header,
const char *  value 
)

Sends an http header.

◆ sendMultiPartBoundary()

void httpresponse::sendMultiPartBoundary ( output out)

Sends a multipart boundary string.

◆ sendStatusHeader()

httpresponse* httpresponse::sendStatusHeader ( const char *  status)

Sends an http status header.

◆ sendTextHtmlHeader()

void httpresponse::sendTextHtmlHeader ( )

Sends HTTP header: Content-type: text/html followed by two carriage-returns to the browser.

◆ sendTextPlainHeader()

void httpresponse::sendTextPlainHeader ( )

Sends HTTP header: Content-type: text/plain followed by two carriage-returns to the browser.

◆ setCookie()

void httpresponse::setCookie ( const char *  name,
const char *  value,
const char *  domain,
const char *  path,
const char *  expires,
bool  secure 
)

Sends Set-Cookie header to the browser.

◆ write() [1/17]

ssize_t httpresponse::write ( byte_t  character)
virtual

Writes "character" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [2/17]

ssize_t httpresponse::write ( char  character)
virtual

Writes "character" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [3/17]

ssize_t httpresponse::write ( const byte_t *  string,
size_t  size 
)
virtual

Writes "size" bytes of "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [4/17]

ssize_t httpresponse::write ( const char *  string)
virtual

Writes NULL-terminated "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [5/17]

ssize_t httpresponse::write ( const char *  string,
size_t  length 
)
virtual

Writes "length" characters of "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ write() [6/17]

ssize_t httpresponse::write ( const wchar_t *  string)
virtual

Writes NULL-terminated "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [7/17]

ssize_t httpresponse::write ( const wchar_t *  string,
size_t  length 
)
virtual

Writes "length" characters of "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ write() [8/17]

ssize_t httpresponse::write ( double  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [9/17]

ssize_t httpresponse::write ( file filebuffer)

Writes "filebuffer" to the browser.

◆ write() [10/17]

ssize_t httpresponse::write ( float  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [11/17]

ssize_t httpresponse::write ( int16_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [12/17]

ssize_t httpresponse::write ( int32_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [13/17]

ssize_t httpresponse::write ( int64_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [14/17]

ssize_t httpresponse::write ( uint16_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [15/17]

ssize_t httpresponse::write ( uint32_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [16/17]

ssize_t httpresponse::write ( uint64_t  number)
virtual

Writes "number" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ write() [17/17]

ssize_t httpresponse::write ( wchar_t  character)
virtual

Writes "character" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ writeUcs2() [1/3]

ssize_t httpresponse::writeUcs2 ( const ucs2_t *  string)
virtual

Writes NULL-terminated "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.

◆ writeUcs2() [2/3]

ssize_t httpresponse::writeUcs2 ( const ucs2_t *  string,
size_t  length 
)
virtual

Writes "length" characters of "string" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred. Note that it is possible to write beyond the string's NULL terminator using this method.

Implements output.

◆ writeUcs2() [3/3]

ssize_t httpresponse::writeUcs2 ( ucs2_t  character)
virtual

Writes "character" to the browser. Returns the number of bytes that were successfully written or RESULT_ERROR if an error occurred.

Implements output.