Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

response_t - response handling


Functions

int response_set_content_encoding (response_t *rs, const char *encoding)
 Set response content encoding field.
int response_disable_caching (response_t *rs)
 Add all header field that enable page caching (i.e. disable caching).
int response_enable_caching (response_t *rs)
 Remove all headers that inhibit page caching.
int response_set_cookie (response_t *rs, const char *name, const char *value, time_t expire, const char *path, const char *domain, int secure)
 Set the value of a cookie.
void response_set_method (response_t *rs, int method)
 Set the response method.
int response_get_method (response_t *rs)
 Get the response method.
void response_set_cgi (response_t *rs, int cgi)
size_t response_get_max_header_size (response_t *rs)
int response_print_header_to_io (response_t *rs, io_t *io)
int response_print_header (response_t *rs)
 Print a response header.
int response_set_field (response_t *rs, const char *name, const char *value)
 Set an header field of a response object.
int response_del_field (response_t *rs, const char *name)
 Remove an header field of a response object.
int response_set_content_type (response_t *rs, const char *mime_type)
 Set the content type of a response to a mime type.
int response_set_date (response_t *rs, time_t date)
 Set the date field in a response header.
int response_set_last_modified (response_t *rs, time_t mtime)
 Set the last modified field in a response header.
int response_set_content_length (response_t *rs, size_t sz)
 Set the content length field of a response header.
int response_get_status (response_t *rs)
 Get the status of a response.
header_tresponse_get_header (response_t *rs)
 Get the header of a response.
io_tresponse_io (response_t *rs)
 Get the I/O object of a response.
int response_redirect (response_t *rs, const char *url)
 Redirect to a given url.
int response_set_status (response_t *rs, int status)
 Set the status of a response.
int response_bind (response_t *rs, io_t *out)
int response_create (http_t *http, response_t **prs)
int response_free (response_t *rs)

Detailed Description

Basic knowledge of the HTTP protocol is assumed. Hence only the essential information is given. Some useful references are:

Function Documentation

int response_bind response_t rs,
io_t out
 

Definition at line 626 of file response.c.

References io_t, and response_t.

int response_create http_t http,
response_t **  prs
 

Definition at line 643 of file response.c.

References header_create(), header_free(), http_t, response_free(), and response_t.

int response_del_field response_t rs,
const char *  name
 

Remove the header field whose name is name

Parameters:
rs response object
name field name
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 404 of file response.c.

References field_free(), field_t, header_del_field(), header_get_field(), and response_t.

Referenced by response_enable_caching().

int response_disable_caching response_t rs  ) 
 

Adds all relevant Header fields to the current HTTP response to avoid browser caching.

The function will set/modify the following fields:

Cache-Control: no-cache, must-revalidate Expires: Mon, 1 Jan 1990 05:00:00 GMT Pragma: no-cache

Parameters:
rs response object
Returns:
  • 0 if successful
  • ~0 if successful

Definition at line 86 of file response.c.

References response_set_field(), and response_t.

int response_enable_caching response_t rs  ) 
 

Remove all HTTP Header fields that (should) prevent browsers caching. This should enable caching on specs-compliant browsers.

Those fields are:

Cache-Control: Expires: Pragma:

Parameters:
rs response object
Returns:
  • 0 if successful
  • ~0 if successful

Definition at line 119 of file response.c.

References response_del_field(), and response_t.

int response_free response_t rs  ) 
 

Definition at line 673 of file response.c.

References header_free(), io_free(), and response_t.

Referenced by response_create().

header_t* response_get_header response_t rs  ) 
 

Get the header of a response rs.

Parameters:
rs response object
Returns:
  • the child header object of the given rs

Definition at line 548 of file response.c.

References response_t.

size_t response_get_max_header_size response_t rs  ) 
 

Definition at line 296 of file response.c.

References field_get_name(), field_get_value(), field_t, header_field_count(), header_get_fieldn(), http_get_status_desc(), and response_t.

int response_get_method response_t rs  ) 
 

Get the response method of rs. For possibile values of method, refer to http.h.

Parameters:
rs response object
Returns:
  • the method of the given rs

Definition at line 281 of file response.c.

References response_t.

int response_get_status response_t rs  ) 
 

Get the status of a response rs. For possible values of status refer to response.h.

Parameters:
rs response object
Returns:
  • the status of the given rs

Definition at line 533 of file response.c.

References response_t.

Referenced by broker_serve().

io_t* response_io response_t rs  ) 
 

Get the I/O object of reponse rs.

Parameters:
rs response object
Returns:
  • the I/O child object of the given rs

Definition at line 563 of file response.c.

References io_t, and response_t.

int response_print_header response_t rs  ) 
 

Print the header of rs

Parameters:
rs parameter rs description
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 367 of file response.c.

References response_print_header_to_io(), and response_t.

Referenced by broker_serve().

int response_print_header_to_io response_t rs,
io_t io
 

Definition at line 333 of file response.c.

References header_field_count(), header_get_fieldn(), io_printf(), io_t, and response_t.

Referenced by response_print_header().

int response_redirect response_t rs,
const char *  url
 

Redirect to url by setting the Location field in response rs.

Parameters:
rs parameter rs description
url parameter url description
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 580 of file response.c.

References field_create(), field_t, header_add_field(), HTTP_STATUS_MOVED_TEMPORARILY, response_set_status(), and response_t.

void response_set_cgi response_t rs,
int  cgi
 

Definition at line 288 of file response.c.

References response_t.

int response_set_content_encoding response_t rs,
const char *  encoding
 

Set the Content-Encoding field in a response object rs to encoding.

Parameters:
rs response object
encoding encoding type
Returns:
  • 0 if successful
  • ~0 if successful

Definition at line 57 of file response.c.

References header_set_field(), and response_t.

int response_set_content_length response_t rs,
size_t  sz
 

Set the Content-Length field of rs to sz.

Parameters:
rs response object
sz number of bytes in content
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 508 of file response.c.

References header_set_field(), and response_t.

int response_set_content_type response_t rs,
const char *  mime_type
 

Set the Content-Type field of response rs to mime_type.

Parameters:
rs response object
mime_type mime type
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 433 of file response.c.

References header_set_field(), and response_t.

int response_set_cookie response_t rs,
const char *  name,
const char *  value,
time_t  expire,
const char *  path,
const char *  domain,
int  secure
 

Set the value of a cookie named name to value in response object rs. Other fields that can be set are expire, path, domain, and secure.

Parameters:
rs response object
name cookie name
value cookie value
expire cookie expiration date
path cookie path
domain cookie domain
secure cookie secure flag
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 150 of file response.c.

References field_create(), field_free(), field_t, header_add_field(), response_t, u_tt_to_rfc822(), u_urlncpy(), and URLCPY_ENCODE.

int response_set_date response_t rs,
time_t  date
 

Set the Date field of rs to date.

Parameters:
rs response object
date date value
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 456 of file response.c.

References header_set_field(), response_t, and u_tt_to_rfc822().

int response_set_field response_t rs,
const char *  name,
const char *  value
 

Set field name to value in reponse object rs.

Parameters:
rs response object
name field name
value field value
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 386 of file response.c.

References header_set_field(), and response_t.

Referenced by response_disable_caching().

int response_set_last_modified response_t rs,
time_t  mtime
 

Set the Last-Modified field of rs to mtime.

Parameters:
rs response object
mtime last modified date value
Returns:
  • 0 if successful
  • ~0 on error

Definition at line 482 of file response.c.

References header_set_field(), response_t, and u_tt_to_rfc822().

void response_set_method response_t rs,
int  method
 

Set the response method of rs to method. For possible values of method, refer to http.h.

Parameters:
rs response object
method response method
Returns:
  • nothing

Definition at line 265 of file response.c.

References response_t.

int response_set_status response_t rs,
int  status
 

Set the status of response rs. For possible values of status refer to response.h.

Parameters:
rs parameter rs description
status parameter status description
Returns:
  • 0 always

Definition at line 608 of file response.c.

References response_t.

Referenced by broker_serve(), and response_redirect().


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved