Request Handling
[Dynamic page interfaces]

Functions

io_t * request_io (request_t *rq)
 Get the io_t object associated with a request object.
vars_t * request_get_cookies (request_t *rq)
 Get the cookies list.
const char * request_get_cookie (request_t *rq, const char *name)
 Get the value of a cookie named name.
vars_t * request_get_args (request_t *rq)
 Get the list of request variables (using either GET or POST method).
vars_t * request_get_getargs (request_t *rq)
 Get request variables passed using the GET method.
vars_t * request_get_postargs (request_t *rq)
 Get request variables passed using the POST method.
const char * request_get_arg (request_t *rq, const char *name)
 Get a request variable (using either GET or POST variable list).
const char * request_get_getarg (request_t *rq, const char *name)
 Return a GET variable.
const char * request_get_postarg (request_t *rq, const char *name)
 Return a POST variable.
const char * request_get_uri (request_t *rq)
 Get the URI field of a request.
const char * request_get_filename (request_t *rq)
 Get the filename field of a request.
const char * request_get_query_string (request_t *rq)
 Get the query string field of a request.
const char * request_get_path_info (request_t *rq)
 Get the path info field of a request.
time_t request_get_if_modified_since (request_t *rq)
 Get IMS field of a request.
http_t * request_get_http (request_t *rq)
 Get the HTTP server handle of a request.
const char * request_get_client_request (request_t *rq)
 Return the client request line.
ssize_t request_get_content_length (request_t *rq)
 Get the content length of a request.
vars_t * request_get_uploads (request_t *rq)
 Get uploaded files.
int request_get_uploaded_file (request_t *rq, const char *name, size_t idx, char local_filename[U_FILENAME_MAX], char client_filename[U_FILENAME_MAX], char mime_type[MIME_TYPE_BUFSZ], size_t *file_size)
 Get info and handles of an uploaded file.
int request_get_method (request_t *rq)
 Get the method of a request.
const char * request_get_protocol (request_t *rq)
 Get the protocol used by the client request.
const char * request_get_resolved_filename (request_t *rq)
 Get resolved filename of a request.
const char * request_get_resolved_path_info (request_t *rq)
 Get the resolved path info of a request.
const char * request_get_addr (request_t *rq)
 Return the local address.
const char * request_get_peer_addr (request_t *rq)
 Return the peer address.
header_t * request_get_header (request_t *rq)
 Return the header object.
field_t * request_get_field (request_t *rq, const char *name)
 Get an header field.
const char * request_get_field_value (request_t *rq, const char *name)
 Get the value of an header field.

Function Documentation

io_t* request_io ( request_t *  rq  ) 

Return the I/O object (io_t) used by the request object passed as parameter. The io_t object is bound to the socket connected to the client (the web browser).

Parameters:
rq request object
Returns:
child io_t object of the given rq or NULL if no io_t object has been set
See also:
io_t

Definition at line 142 of file request.c.

vars_t* request_get_cookies ( request_t *  rq  ) 

Return a vars_t object containing the list of all cookies sent by the browser.

Parameters:
rq request object
Returns:
the cookie list of the given rq

Definition at line 160 of file request.c.

const char* request_get_cookie ( request_t *  rq,
const char *  name 
)

Return the value of a cookie sent by the browser

Parameters:
rq request object
name cookie name
Returns:
the cookie value or NULL on error

Definition at line 178 of file request.c.

vars_t* request_get_args ( request_t *  rq  ) 

Return get/post arguments of request rq in a vars_t object

Parameters:
rq request object
Returns:
the arguments' list of the given rq

Definition at line 200 of file request.c.

vars_t* request_get_getargs ( request_t *  rq  ) 

Return GET arguments of request rq in a vars_t object

Parameters:
rq request object
Returns:
the arguments' list of the given rq

Definition at line 217 of file request.c.

vars_t* request_get_postargs ( request_t *  rq  ) 

Return POST arguments of request rq in a vars_t object

Parameters:
rq request object
Returns:
the arguments' list of the given rq

Definition at line 234 of file request.c.

const char* request_get_arg ( request_t *  rq,
const char *  name 
)

Return the string value of argument name in request rq.

Parameters:
rq request object
name name of the argument
Returns:
  • the string value corresponding to the supplied name
  • NULL if there's no argument named name

Definition at line 254 of file request.c.

const char* request_get_getarg ( request_t *  rq,
const char *  name 
)

Return the string value of argument name in request rq.

Parameters:
rq request object
name name of the argument
Returns:
  • the string value corresponding to the supplied name
  • NULL if there's no argument named name

Definition at line 279 of file request.c.

const char* request_get_postarg ( request_t *  rq,
const char *  name 
)

Return the string value of argument name in request rq.

Parameters:
rq request object
name name of the argument
Returns:
  • the string value corresponding to the supplied name
  • NULL if there's no argument named name

Definition at line 304 of file request.c.

const char* request_get_uri ( request_t *  rq  ) 

Return the string value of the URI in request rq.

Parameters:
rq request object
Returns:
the URI child object of the given rq

Definition at line 335 of file request.c.

const char* request_get_filename ( request_t *  rq  ) 

Return the string value of the filename field in request rq.

Parameters:
rq request object
Returns:
the file name bound to rq (can be NULL)

Definition at line 352 of file request.c.

const char* request_get_query_string ( request_t *  rq  ) 

Return the query string field of request rq.

Parameters:
rq request object
Returns:
the query string bound to rq (may be NULL)

Definition at line 392 of file request.c.

const char* request_get_path_info ( request_t *  rq  ) 

Return the path info field of request rq.

Parameters:
rq request object
Returns:
the path info of rq (may be NULL)

Definition at line 409 of file request.c.

time_t request_get_if_modified_since ( request_t *  rq  ) 

Return the time_t value of the IMS field of request rq

Parameters:
rq request object
Returns:
a valid time_t value on success, -1 on failure

Definition at line 443 of file request.c.

http_t* request_get_http ( request_t *  rq  ) 

Get the http_t object containing the HTTP server handle of request rq

Parameters:
rq request object
Returns:
the child HTTP object of the given rq (may be NULL)

Definition at line 483 of file request.c.

const char* request_get_client_request ( request_t *  rq  ) 

Return the client request (METHOD URI HTTP/HTTP_VERSION)

Parameters:
rq request object
Returns:
0 if successful, non-zero on error

Definition at line 723 of file request.c.

ssize_t request_get_content_length ( request_t *  rq  ) 

Retrieve a size_t corresponding to the Content-Length field of request rq

Parameters:
rq request object
Returns:
the content length of the given rq

Definition at line 914 of file request.c.

vars_t* request_get_uploads ( request_t *  rq  ) 

Return the list of uploaded files.

Any var_t in the list will contain, within its name/value pair, the name of the HTML form input tag "name" argument and the filename (with full path) of the temporary file where uploaded content has been stored.

This function is only useful to enumerate uploads,

See also:
request_get_uploaded_file is what you'll probably use.
Parameters:
rq request object
Returns:
the arguments' list of the given rq

Definition at line 1211 of file request.c.

int request_get_uploaded_file ( request_t *  rq,
const char *  name,
size_t  idx,
char  local_filename[U_FILENAME_MAX],
char  client_filename[U_FILENAME_MAX],
char  mime_type[MIME_TYPE_BUFSZ],
size_t *  file_size 
)

Return information and handles about an uploaded file

Parameters:
rq request object
name form input tag variable name (<input type=file name="xxx">)
idx if more then one file with the same name param exists idx will be used as an index (use 0 otherwise)
local_filename on successfull exit will get the filename (with full path) of the temporary file where uploaded file content has been saved. Must be at least U_FILENAME_MAX bytes long
client_filename filename as provided by the client Must be at least U_FILENAME_MAX bytes long
mime_type MIME type as stated y the client (may be "") Must be at least MIME_TYPE_BUFSZ bytes long
file_size file size of the uploaded file
Returns:
0 on success, ~0 otherwise

Definition at line 1323 of file request.c.

int request_get_method ( request_t *  rq  ) 

Return the method of request rq. Refer to http.h for possible methods.

Parameters:
rq request object
Returns:
  • the method of the given rq

Definition at line 1736 of file request.c.

References HM_UNKNOWN.

const char* request_get_protocol ( request_t *  rq  ) 

Return the protocol of request rq ("HTTP/1.0", "HTTP/1.1", etc.)

Parameters:
rq request object
Returns:
  • the method of the given rq

Definition at line 1754 of file request.c.

const char* request_get_resolved_filename ( request_t *  rq  ) 

Return a string representing the resolved filename of request rq.

Parameters:
rq request object
Returns:
the resolved file name bound to rq (may be NULL)

Definition at line 1771 of file request.c.

const char* request_get_resolved_path_info ( request_t *  rq  ) 

Return a string representing the resolved path info of request rq.

Parameters:
rq request object
Returns:
the resolved path info of the given rq (may be NULL)

Definition at line 1788 of file request.c.

const char* request_get_addr ( request_t *  rq  ) 

Return a string containing the address of the accepted the socket

Parameters:
rq request object
Returns:
the address string

Definition at line 1971 of file request.c.

const char* request_get_peer_addr ( request_t *  rq  ) 

Return a string containing the address of the connected peer

Parameters:
rq request object
Returns:
the address string

Definition at line 1988 of file request.c.

header_t* request_get_header ( request_t *  rq  ) 

Return the header object

Parameters:
rq request object
Returns:
a pointer to an header_t type
See also:
header_t

Definition at line 2006 of file request.c.

field_t* request_get_field ( request_t *  rq,
const char *  name 
)

Return the header field named name.

Parameters:
rq request object
name the name of the field
Returns:
the header field or NULL if the header is not found

Definition at line 2024 of file request.c.

const char* request_get_field_value ( request_t *  rq,
const char *  name 
)

Return the value of an header field named name.

Parameters:
rq request object
name the name of the field
Returns:
the value of the field or NULL if the field is not found

Definition at line 2043 of file request.c.


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