HomePort
Data Structures | Functions
httpd.c File Reference
Include dependency graph for httpd.c:

Go to the source code of this file.

Data Structures

struct  hpd_httpd
 httpd instance struct More...
 

Functions

hpd_error_t hpd_httpd_create (hpd_httpd_t **httpd, hpd_httpd_settings_t *settings, const hpd_module_t *context, hpd_ev_loop_t *loop)
 Create a new httpd instance. More...
 
hpd_error_t hpd_httpd_destroy (hpd_httpd_t *httpd)
 Destroy a httpd instance. More...
 
hpd_error_t hpd_httpd_start (hpd_httpd_t *httpd)
 Start a httpd instance. More...
 
hpd_error_t hpd_httpd_stop (hpd_httpd_t *httpd)
 Stop a httpd instance. More...
 
static hpd_tcpd_return_t httpd_on_connect (hpd_tcpd_t *instance, hpd_tcpd_conn_t *conn, void *ws_ctx, void **conn_ctx)
 Callback for tcpd library. More...
 
static hpd_tcpd_return_t httpd_on_disconnect (hpd_tcpd_t *instance, hpd_tcpd_conn_t *conn, void *ws_ctx, void **conn_ctx)
 Callback for tcpd library. More...
 
static hpd_tcpd_return_t httpd_on_receive (hpd_tcpd_t *instance, hpd_tcpd_conn_t *conn, void *ws_ctx, void **conn_ctx, const char *buf, size_t len)
 Callback for tcpd library. More...
 

Data Structure Documentation

struct hpd_httpd

httpd instance struct

Definition at line 38 of file httpd.c.

Collaboration diagram for hpd_httpd:
Data Fields
const hpd_module_t * context
hpd_httpd_settings_t settings Settings.
hpd_tcpd_t * webserver Webserver instance.

Function Documentation

hpd_error_t hpd_httpd_create ( hpd_httpd_t **  httpd,
hpd_httpd_settings_t settings,
const hpd_module_t context,
hpd_ev_loop_t loop 
)

Create a new httpd instance.

Allocates a new httpd instance, that should be freed with hpd_httpd_destroy()

The settings is copied to the instance and a webserver instance is created for it.

Parameters
settingsThe settings for the httpd.
loopThe event loop to start the server on.
Returns
The newly created instance.

Definition at line 135 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

hpd_error_t hpd_httpd_destroy ( hpd_httpd_t httpd)

Destroy a httpd instance.

Destroy a httpd instance created with hpd_httpd_create(). If the server is started it should be stopped first by hpd_httpd_stop().

Parameters
instanceThe httpd instance to destroy.

Definition at line 178 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

hpd_error_t hpd_httpd_start ( hpd_httpd_t httpd)

Start a httpd instance.

Starts a created httpd.

Parameters
instanceThe instance to start.
Returns
The error code of hpd_tcpd_start()

Definition at line 196 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

hpd_error_t hpd_httpd_stop ( hpd_httpd_t httpd)

Stop a httpd instance.

Stops an already started httpd instance. All open connections will be killed without notifying clients, nor sending remaining data.

Parameters
instanceInstance to stop.

Definition at line 211 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static hpd_tcpd_return_t httpd_on_connect ( hpd_tcpd_t instance,
hpd_tcpd_conn_t conn,
void *  ws_ctx,
void **  conn_ctx 
)
static

Callback for tcpd library.

Handles new connections, by creating a request for them.

Parameters
instanceWebserver instance
connConnection
tcpd_ctxThe http webserver instance
reqThe http request
Returns
0 on success, 1 on error

Definition at line 56 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static hpd_tcpd_return_t httpd_on_disconnect ( hpd_tcpd_t instance,
hpd_tcpd_conn_t conn,
void *  ws_ctx,
void **  conn_ctx 
)
static

Callback for tcpd library.

Handles closure of connections, by creating a destroying the request.

Parameters
instanceWebserver instance
connConnection
tcpd_ctxThe http webserver instance
reqThe http request
Returns
0 on success, 1 on error

Definition at line 107 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static hpd_tcpd_return_t httpd_on_receive ( hpd_tcpd_t instance,
hpd_tcpd_conn_t conn,
void *  ws_ctx,
void **  conn_ctx,
const char *  buf,
size_t  len 
)
static

Callback for tcpd library.

Handles reception of data, by supplying it to the http_parser associated with the request.

Parameters
instanceWebserver instance
connConnection
tcpd_ctxThe http webserver instance
reqThe http request
Returns
0 on success, 1 on error

Definition at line 82 of file httpd.c.

Here is the call graph for this function:

Here is the caller graph for this function: