Rudiments

Public Member Functions | List of all members
httpresponse Class Reference

Inherits output.

## Public Member Functions
| httpresponse (httpserverapi *sapi)
void | textHtml ()
void | textPlain ()
void | contentType (const char *type, const char *subtype)
void | contentType (const char *type, const char *subtype, const char *charset)
void | contentType (const char *type, const char *subtype, const char *charset, const char *boundary)
void | cr ()
void | status (const char *protocol, const char *protocolversion, const char *code)
void | setCookie (const char *name, const char *value, const char *domain, const char *path, const char *expires, bool secure)
const char * | boundaryString ()
void | multiPartBoundary (output *out)
void | multiPartEnd (output *out)
httpresponse * | status (const char *status)
httpresponse * | header (const char *header)
httpresponse * | header (const char *header, const char *value)
ssize_t | write (const unsigned char *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 (int16_t number)
ssize_t | write (int32_t number)
ssize_t | write (int64_t number)
ssize_t | write (unsigned char 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
virtual ssize_t | write (const unsigned char *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 (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 (unsigned char 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)

## Detailed Description

The httpresponse class provides methods for generating http responses.

## Member Function Documentation

## ◆ boundaryString()

const char* httpresponse::boundaryString | ( |  | ) |

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

## ◆ contentType() [1/3]

void httpresponse::contentType | ( | const char * | type,
|  | const char * | subtype
| ) |  |

Send HTTP header: Content-type: "type"/"subtype"

Does not send carriage-returns.

## ◆ contentType() [2/3]

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

Send HTTP header: Content-type: "type"/"subtype"; charset="charset"

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

Does not send carriage-returns.

## ◆ contentType() [3/3]

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

Send HTTP header: Content-type: "type"/"subtype"; charset="charset"; boundary="boundary"

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

Does not send carriage-returns.

## ◆ cr()

void httpresponse::cr | ( |  | ) |

Send carriage-return.

## ◆ header() [1/2]

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

Sends an http header.

## ◆ header() [2/2]

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

Sends an http header.

## ◆ multiPartBoundary()

void httpresponse::multiPartBoundary | ( | output * | out | ) |

Sends a starting boundary string.

## ◆ multiPartEnd()

void httpresponse::multiPartEnd | ( | output * | out | ) |

Sends a ending boundary string.

## ◆ setCookie()

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

Send Set-Cookie header.

## ◆ status() [1/2]

void httpresponse::status | ( | const char * | protocol,
|  | const char * | protocolversion,
|  | const char * | code
| ) |  |

Send status header.

## ◆ status() [2/2]

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

Sends an http status header.

## ◆ textHtml()

void httpresponse::textHtml | ( |  | ) |

Send HTTP header: Content-type: text/html followed by two carriage-returns.

## ◆ textPlain()

void httpresponse::textPlain | ( |  | ) |

Send HTTP header: Content-type: text/plain followed by two carriage-returns.

## ◆ write()

ssize_t httpresponse::write | ( | file * | filebuffer | ) |

Writes "filebuffer" to the browser.