libasyncd
ad_http_handler.c File Reference

HTTP protocol request/response handler. More...

Go to the source code of this file.

Functions

int ad_http_handler (short event, ad_conn_t *conn, void *userdata)
 HTTP protocol handler hook.
 
enum ad_http_request_status_e ad_http_get_status (ad_conn_t *conn)
 Return the request status.
 
struct evbuffer * ad_http_get_inbuf (ad_conn_t *conn)
 
struct evbuffer * ad_http_get_outbuf (ad_conn_t *conn)
 
const char * ad_http_get_request_header (ad_conn_t *conn, const char *name)
 
off_t ad_http_get_content_length (ad_conn_t *conn)
 
void * ad_http_get_content (ad_conn_t *conn, size_t maxsize, size_t *storedsize)
 
int ad_http_add_response_header (ad_conn_t *conn, const char *name, const char *value)
 
int ad_http_set_response_code (ad_conn_t *conn, int code, const char *reason)
 
int ad_http_set_response_content (ad_conn_t *conn, const char *contenttype, off_t size)
 
size_t ad_http_response (ad_conn_t *conn, int code, const char *contenttype, const void *data, off_t size)
 
size_t ad_http_send_header (ad_conn_t *conn)
 
size_t ad_http_send_data (ad_conn_t *conn, const void *data, size_t size)
 
size_t ad_http_send_chunk (ad_conn_t *conn, const void *data, size_t size)
 
const char * ad_http_get_reason (int code)
 

Detailed Description

HTTP protocol request/response handler.

Definition in file ad_http_handler.c.

Function Documentation

int ad_http_handler ( short  event,
ad_conn_t conn,
void *  userdata 
)

HTTP protocol handler hook.

This hook provides an easy way to handle HTTP request/response.

Note
This hook must be registered at the top of hook chain.

Definition at line 53 of file ad_http_handler.c.

enum ad_http_request_status_e ad_http_get_status ( ad_conn_t conn)

Return the request status.

Definition at line 83 of file ad_http_handler.c.

struct evbuffer* ad_http_get_inbuf ( ad_conn_t conn)
read

Definition at line 89 of file ad_http_handler.c.

struct evbuffer* ad_http_get_outbuf ( ad_conn_t conn)
read

Definition at line 94 of file ad_http_handler.c.

const char* ad_http_get_request_header ( ad_conn_t conn,
const char *  name 
)

Definition at line 99 of file ad_http_handler.c.

off_t ad_http_get_content_length ( ad_conn_t conn)

Definition at line 104 of file ad_http_handler.c.

void* ad_http_get_content ( ad_conn_t conn,
size_t  maxsize,
size_t *  storedsize 
)
Parameters
maxsizemaximum length of data to pull up. 0 to pull up everything.

Definition at line 112 of file ad_http_handler.c.

int ad_http_add_response_header ( ad_conn_t conn,
const char *  name,
const char *  value 
)
Parameters
valuevalue string to set. NULL to remove the header.
Returns
0 on success, -1 if we already sent it out.

Definition at line 132 of file ad_http_handler.c.

int ad_http_set_response_code ( ad_conn_t conn,
int  code,
const char *  reason 
)
Returns
0 on success, -1 if we already sent it out.

Definition at line 151 of file ad_http_handler.c.

int ad_http_set_response_content ( ad_conn_t conn,
const char *  contenttype,
off_t  size 
)
Parameters
sizecontent size. -1 for chunked transfer encoding.
Returns
0 on success, -1 if we already sent it out.

Definition at line 168 of file ad_http_handler.c.

size_t ad_http_response ( ad_conn_t conn,
int  code,
const char *  contenttype,
const void *  data,
off_t  size 
)
Returns
total bytes sent, 0 on error.

Definition at line 192 of file ad_http_handler.c.

size_t ad_http_send_header ( ad_conn_t conn)
Returns
0 total bytes put in out buffer, -1 if we already sent it out.

Definition at line 206 of file ad_http_handler.c.

size_t ad_http_send_data ( ad_conn_t conn,
const void *  data,
size_t  size 
)
Returns
0 on success, -1 if we already sent it out.

Definition at line 237 of file ad_http_handler.c.

size_t ad_http_send_chunk ( ad_conn_t conn,
const void *  data,
size_t  size 
)

Definition at line 263 of file ad_http_handler.c.

const char* ad_http_get_reason ( int  code)

Definition at line 294 of file ad_http_handler.c.