libonion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Data Fields

The response. More...

#include <types.h>

Public Member Functions

onion_responseonion_response_new (onion_request *req)
 Generates a new response object.
onion_connection_status onion_response_free (onion_response *res)
 Frees the memory consumed by this object.
void onion_response_set_header (onion_response *res, const char *key, const char *value)
 Adds a header to the response object.
void onion_response_set_length (onion_response *res, size_t len)
 Sets the header length. Normally it should be through set_header, but as its very common and needs some procesing here is a shortcut.
void onion_response_set_code (onion_response *res, int code)
 Sets the return code.
static void write_header (onion_response *res, const char *key, const char *value, int flags)
 Helper that is called on each header, and writes the header.
int onion_response_write_headers (onion_response *res)
 Writes all the header to the given response.
ssize_t onion_response_write (onion_response *res, const char *data, size_t length)
 Write some response data.
ssize_t onion_response_printf (onion_response *res, const char *fmt,...)
 Writes some data to the response. Using sprintf format strings.
ssize_t onion_response_vprintf (onion_response *res, const char *fmt, va_list args)
 Writes some data to the response. Using sprintf format strings. va_list args version.
const char * onion_response_code_description (int code)
 Returns a const char * string with the code description.

Data Fields

onion_requestrequest
onion_dictheaders
 Original request, so both are related, and get connected to the onion_t structure. Writes through the request connection.
int code
 Headers to write when appropiate.
int flags
 Response code.
unsigned int length
 Flags.
unsigned int sent_bytes
 Length, if known, of the response, to create the Content-Lenght header.
unsigned int sent_bytes_total
 Sent bytes at content.
char buffer [ONION_RESPONSE_BUFFER_SIZE]
 Total sent bytes, including headers.
off_t buffer_pos
 buffer of output data. This way its do not send small chunks all the time, but blocks, so better network use. Also helps to keep alive connections with less than block size bytes.

Detailed Description

The response.

Field Documentation

char onion_response_t::buffer[ONION_RESPONSE_BUFFER_SIZE]
off_t onion_response_t::buffer_pos

buffer of output data. This way its do not send small chunks all the time, but blocks, so better network use. Also helps to keep alive connections with less than block size bytes.

Referenced by onion_empty_output_buffer(), onion_handler_t::onion_handler_handle(), onion_init_destination(), onion_response_flush(), onion_response_free(), onion_response_new(), onion_response_write(), onion_response_write_headers(), and onion_term_destination().

int onion_response_t::code
int onion_response_t::flags
onion_dict* onion_response_t::headers

Original request, so both are related, and get connected to the onion_t structure. Writes through the request connection.

Referenced by onion_response_free(), onion_response_get_headers(), onion_response_new(), onion_response_set_header(), and onion_response_write_headers().

unsigned int onion_response_t::length
onion_request* onion_response_t::request
unsigned int onion_response_t::sent_bytes

Length, if known, of the response, to create the Content-Lenght header.

Referenced by onion_response_flush(), onion_response_free(), onion_response_new(), onion_response_set_length(), onion_response_write_headers(), and onion_shortcut_response_file().

unsigned int onion_response_t::sent_bytes_total

Sent bytes at content.

Referenced by onion_response_flush(), onion_response_new(), and onion_shortcut_response_file().


The documentation for this struct was generated from the following files: