Functions |
struct evhttp * | evhttp_new (struct event_base *base) |
int | evhttp_bind_socket (struct evhttp *http, const char *address, u_short port) |
int | evhttp_accept_socket (struct evhttp *http, int fd) |
void | evhttp_free (struct evhttp *http) |
void | evhttp_set_cb (struct evhttp *, const char *, void(*)(struct evhttp_request *, void *), void *) |
int | evhttp_del_cb (struct evhttp *, const char *) |
void | evhttp_set_gencb (struct evhttp *, void(*)(struct evhttp_request *, void *), void *) |
void | evhttp_set_timeout (struct evhttp *, int timeout_in_secs) |
void | evhttp_send_error (struct evhttp_request *req, int error, const char *reason) |
void | evhttp_send_reply (struct evhttp_request *req, int code, const char *reason, struct evbuffer *databuf) |
void | evhttp_send_reply_start (struct evhttp_request *, int, const char *) |
void | evhttp_send_reply_chunk (struct evhttp_request *, struct evbuffer *) |
void | evhttp_send_reply_end (struct evhttp_request *) |
struct evhttp * | evhttp_start (const char *address, u_short port) |
struct evhttp_request * | evhttp_request_new (void(*cb)(struct evhttp_request *, void *), void *arg) |
void | evhttp_request_set_chunked_cb (struct evhttp_request *, void(*cb)(struct evhttp_request *, void *)) |
void | evhttp_request_free (struct evhttp_request *req) |
struct evhttp_connection * | evhttp_connection_new (const char *address, unsigned short port) |
void | evhttp_connection_free (struct evhttp_connection *evcon) |
void | evhttp_connection_set_local_address (struct evhttp_connection *evcon, const char *address) |
void | evhttp_connection_set_local_port (struct evhttp_connection *evcon, unsigned short port) |
void | evhttp_connection_set_timeout (struct evhttp_connection *evcon, int timeout_in_secs) |
void | evhttp_connection_set_retries (struct evhttp_connection *evcon, int retry_max) |
void | evhttp_connection_set_closecb (struct evhttp_connection *evcon, void(*)(struct evhttp_connection *, void *), void *) |
void | evhttp_connection_set_base (struct evhttp_connection *evcon, struct event_base *base) |
void | evhttp_connection_get_peer (struct evhttp_connection *evcon, char **address, u_short *port) |
int | evhttp_make_request (struct evhttp_connection *evcon, struct evhttp_request *req, enum evhttp_cmd_type type, const char *uri) |
const char * | evhttp_request_uri (struct evhttp_request *req) |
const char * | evhttp_find_header (const struct evkeyvalq *, const char *) |
int | evhttp_remove_header (struct evkeyvalq *, const char *) |
int | evhttp_add_header (struct evkeyvalq *, const char *, const char *) |
void | evhttp_clear_headers (struct evkeyvalq *) |
char * | evhttp_encode_uri (const char *uri) |
char * | evhttp_decode_uri (const char *uri) |
void | evhttp_parse_query (const char *uri, struct evkeyvalq *headers) |
char * | evhttp_htmlescape (const char *html) |
Basic support for HTTP serving.
As libevent is a library for dealing with event notification and most interesting applications are networked today, I have often found the need to write HTTP code. The following prototypes and definitions provide an application with a minimal interface for making HTTP requests and for creating a very simple HTTP server.
Definition in file evhttp.h.
int evhttp_accept_socket |
( |
struct evhttp * |
http, |
|
|
int |
fd |
|
) |
| |
Makes an HTTP server accept connections on the specified socket
This may be useful to create a socket and then fork multiple instances of an http server, or when a socket has been communicated via file descriptor passing in situations where an http servers does not have permissions to bind to a low-numbered port.
Can be called multiple times to have the http server listen to multiple different sockets.
- Parameters
-
http | a pointer to an evhttp object |
fd | a socket fd that is ready for accepting connections |
- Returns
- 0 on success, -1 on failure.
- See Also
- evhttp_free(), evhttp_bind_socket()
Definition at line 2280 of file http.c.
char* evhttp_htmlescape |
( |
const char * |
html | ) |
|
Escape HTML character entities in a string.
Replaces <, >, ", ' and & with <, >, ", ' and & correspondingly.
The returned string needs to be freed by the caller.
- Parameters
-
html | an unescaped HTML string |
- Returns
- an escaped HTML string
Definition at line 280 of file http.c.
void evhttp_parse_query |
( |
const char * |
uri, |
|
|
struct evkeyvalq * |
headers |
|
) |
| |
Helper function to parse out arguments in a query.
Parsing a uri like
http://foo.com/?q=test&s=some+thing
will result in two entries in the key value queue.
The first entry is: key="q", value="test" The second entry is: key="s", value="some thing"
- Parameters
-
uri | the request URI |
headers | the head of the evkeyval queue |
Definition at line 2119 of file http.c.