1 #include <evhtp-config.h>
7 #ifndef EVHTP_DISABLE_EVTHR
13 #ifndef EVHTP_DISABLE_REGEX
14 #include <onigposix.h>
17 #include <sys/queue.h>
18 #include <event2/event.h>
19 #include <event2/listener.h>
20 #include <event2/buffer.h>
21 #include <event2/bufferevent.h>
23 #ifndef EVHTP_DISABLE_SSL
24 #include <event2/bufferevent_ssl.h>
25 #include <openssl/ssl.h>
26 #include <openssl/err.h>
27 #include <openssl/rand.h>
35 #define __QUOTE(x) # x
36 #define _QUOTE(x) __QUOTE(x)
37 #define htp_debug_strlen(x) strlen(x)
39 #define htp_log_debug(fmt, ...) do { \
40 time_t t = time(NULL); \
41 struct tm * dm = localtime(&t); \
43 fprintf(stdout, "[%02d:%02d:%02d] evhtp.c:[" _QUOTE(__LINE__) "]\t %-26s: " \
44 fmt "\n", dm->tm_hour, dm->tm_min, dm->tm_sec, __func__, ## __VA_ARGS__); \
49 #define htp_debug_strlen(x) 0
50 #define htp_log_debug(fmt, ...) do {} while (0)
54 #ifndef EVHTP_DISABLE_SSL
73 #ifdef EVHTP_DISABLE_EVTHR
74 typedef struct event_base evbase_t;
76 typedef void evthr_pool_t;
101 #define evhtp_header_s evhtp_kv_s
102 #define evhtp_headers_s evhtp_kvs_s
103 #define evhtp_query_s evhtp_kvs_s
105 #define evhtp_header_t evhtp_kv_t
106 #define evhtp_headers_t evhtp_kvs_t
107 #define evhtp_query_t evhtp_kvs_t
141 #ifndef EVHTP_DISABLE_REGEX
165 typedef void (*
evhtp_hook_err_cb)(evhtp_request_t * req, evhtp_error_flags errtype,
void * arg);
190 #ifndef EVHTP_DISABLE_SSL
194 typedef int (*
evhtp_ssl_scache_add)(evhtp_connection_t * connection,
unsigned char * sid,
int sid_len, evhtp_ssl_sess_t * sess);
196 typedef evhtp_ssl_sess_t * (* evhtp_ssl_scache_get)(evhtp_connection_t * connection,
unsigned char * sid,
int sid_len);
197 typedef void * (* evhtp_ssl_scache_init)(evhtp_t *);
200 #define EVHTP_VERSION "1.2.11"
201 #define EVHTP_VERSION_MAJOR 1
202 #define EVHTP_VERSION_MINOR 2
203 #define EVHTP_VERSION_PATCH 11
205 #define evhtp_headers_iterator evhtp_kvs_iterator
207 #define EVHTP_RES_ERROR 0
208 #define EVHTP_RES_PAUSE 1
209 #define EVHTP_RES_FATAL 2
210 #define EVHTP_RES_USER 3
211 #define EVHTP_RES_DATA_TOO_LONG 4
212 #define EVHTP_RES_OK 200
214 #ifndef DOXYGEN_SHOULD_SKIP_THIS
215 #define EVHTP_RES_100 100
216 #define EVHTP_RES_CONTINUE 100
217 #define EVHTP_RES_SWITCH_PROTO 101
218 #define EVHTP_RES_PROCESSING 102
219 #define EVHTP_RES_URI_TOOLONG 122
221 #define EVHTP_RES_200 200
222 #define EVHTP_RES_CREATED 201
223 #define EVHTP_RES_ACCEPTED 202
224 #define EVHTP_RES_NAUTHINFO 203
225 #define EVHTP_RES_NOCONTENT 204
226 #define EVHTP_RES_RSTCONTENT 205
227 #define EVHTP_RES_PARTIAL 206
228 #define EVHTP_RES_MSTATUS 207
229 #define EVHTP_RES_IMUSED 226
231 #define EVHTP_RES_300 300
232 #define EVHTP_RES_MCHOICE 300
233 #define EVHTP_RES_MOVEDPERM 301
234 #define EVHTP_RES_FOUND 302
235 #define EVHTP_RES_SEEOTHER 303
236 #define EVHTP_RES_NOTMOD 304
237 #define EVHTP_RES_USEPROXY 305
238 #define EVHTP_RES_SWITCHPROXY 306
239 #define EVHTP_RES_TMPREDIR 307
241 #define EVHTP_RES_400 400
242 #define EVHTP_RES_BADREQ 400
243 #define EVHTP_RES_UNAUTH 401
244 #define EVHTP_RES_PAYREQ 402
245 #define EVHTP_RES_FORBIDDEN 403
246 #define EVHTP_RES_NOTFOUND 404
247 #define EVHTP_RES_METHNALLOWED 405
248 #define EVHTP_RES_NACCEPTABLE 406
249 #define EVHTP_RES_PROXYAUTHREQ 407
250 #define EVHTP_RES_TIMEOUT 408
251 #define EVHTP_RES_CONFLICT 409
252 #define EVHTP_RES_GONE 410
253 #define EVHTP_RES_LENREQ 411
254 #define EVHTP_RES_PRECONDFAIL 412
255 #define EVHTP_RES_ENTOOLARGE 413
256 #define EVHTP_RES_URITOOLARGE 414
257 #define EVHTP_RES_UNSUPPORTED 415
258 #define EVHTP_RES_RANGENOTSC 416
259 #define EVHTP_RES_EXPECTFAIL 417
260 #define EVHTP_RES_IAMATEAPOT 418
262 #define EVHTP_RES_500 500
263 #define EVHTP_RES_SERVERR 500
264 #define EVHTP_RES_NOTIMPL 501
265 #define EVHTP_RES_BADGATEWAY 502
266 #define EVHTP_RES_SERVUNAVAIL 503
267 #define EVHTP_RES_GWTIMEOUT 504
268 #define EVHTP_RES_VERNSUPPORT 505
269 #define EVHTP_RES_BWEXEED 509
299 uint8_t disable_100_cont : 1,
300 enable_reuseport : 1,
302 enable_defer_accept : 1,
307 #ifndef EVHTP_DISABLE_SSL
312 #ifndef EVHTP_DISABLE_EVTHR
316 #ifndef EVHTP_DISABLE_EVTHR
324 struct timeval recv_timeo;
325 struct timeval send_timeo;
356 #ifndef EVHTP_DISABLE_REGEX
364 TAILQ_HEAD(evhtp_callbacks_s, evhtp_callback_s);
443 uint8_t keepalive : 1,
455 #define evhtp_request_content_len(r) htparser_get_content_length(r->conn->parser)
461 #ifndef EVHTP_DISABLE_EVTHR
464 #ifndef EVHTP_DISABLE_SSL
471 struct timeval recv_timeo;
472 struct timeval send_timeo;
489 #ifdef EVHTP_FUTURE_USE
528 #ifndef EVHTP_DISABLE_SSL
563 EVHTP_EXPORT evhtp_t *
evhtp_new(evbase_t * evbase,
void * arg);
564 EVHTP_EXPORT
void evhtp_free(evhtp_t * evhtp);
576 EVHTP_EXPORT
void evhtp_set_timeouts(evhtp_t * htp,
const struct timeval * r,
const struct timeval * w);
602 #ifndef EVHTP_DISABLE_SSL
604 EVHTP_EXPORT
int evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
669 EVHTP_EXPORT evhtp_callback_t *
evhtp_set_cb(evhtp_t * htp,
const char * path,
683 #ifndef EVHTP_DISABLE_REGEX
684 EVHTP_EXPORT evhtp_callback_t *
evhtp_set_regex_cb(evhtp_t * htp,
const char * pattern,
702 EVHTP_EXPORT evhtp_callback_t *
evhtp_set_glob_cb(evhtp_t * htp,
const char * pattern,
731 EVHTP_EXPORT evhtp_callback_t *
evhtp_get_cb(evhtp_t * htp,
const char * needle);
772 EVHTP_EXPORT
int evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type,
784 EVHTP_EXPORT
int evhtp_unset_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type);
811 EVHTP_EXPORT
int evhtp_bind_socket(evhtp_t * htp,
const char * addr, uint16_t port,
int backlog);
832 size_t sin_len,
int backlog);
857 EVHTP_EXPORT
void evhtp_send_reply(evhtp_request_t * request, evhtp_res code);
920 EVHTP_EXPORT evhtp_callback_t *
955 EVHTP_EXPORT
int evhtp_add_vhost(evhtp_t * evhtp,
const char * name, evhtp_t * vhost);
980 EVHTP_EXPORT evhtp_kv_t *
evhtp_kv_new(
const char * key,
const char * val,
char kalloc,
char valloc);
1064 #define EVHTP_PARSE_QUERY_FLAG_STRICT 0
1065 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX (1 << 0)
1066 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS (1 << 1)
1067 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS (1 << 2)
1068 #define EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP (1 << 3)
1069 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_FRAGMENTS (1 << 4)
1070 #define EVHTP_PARSE_QUERY_FLAG_LENIENT \
1071 EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX \
1072 | EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS \
1073 | EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS \
1074 | EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP
1124 char kalloc,
char valloc);
1137 const char * key,
char kalloc);
1150 const char * val,
char valloc);
1171 #define evhtp_header_find evhtp_kv_find
1172 #define evhtp_headers_find_header evhtp_kvs_find_kv
1173 #define evhtp_headers_for_each evhtp_kvs_for_each
1174 #define evhtp_header_new evhtp_kv_new
1175 #define evhtp_header_free evhtp_kv_free
1176 #define evhtp_headers_new evhtp_kvs_new
1177 #define evhtp_headers_free evhtp_kvs_free
1178 #define evhtp_header_rm_and_free evhtp_kv_rm_and_free
1179 #define evhtp_headers_add_header evhtp_kvs_add_kv
1180 #define evhtp_headers_add_headers evhtp_kvs_add_kvs
1181 #define evhtp_query_new evhtp_kvs_new
1182 #define evhtp_query_free evhtp_kvs_free
1247 const struct timeval * r,
1248 const struct timeval * w);
1328 struct evdns_base * dns_base,
1329 const char * addr, uint16_t port);
1334 EVHTP_EXPORT evhtp_connection_t *
1337 #ifndef EVHTP_DISABLE_SSL
1338 EVHTP_EXPORT evhtp_connection_t *
evhtp_connection_ssl_new(evbase_t * evbase,
const char * addr, uint16_t port, evhtp_ssl_ctx_t * ctx);
1351 evhtp_request_t * r, htp_method meth,
const char * uri);
EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t *r)
evhtp_hook_chunk_new_cb on_new_chunk
int(* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t *ctx, evhtp_x509_t *x, evhtp_x509_t *issuer)
evhtp_query_t * query
list of k/v for query arguments
EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t *connection)
type which defines to hook whenever a connection error occurs
EVHTP_EXPORT void evhtp_kv_rm_and_free(evhtp_kvs_t *kvs, evhtp_kv_t *kv)
free's resources associated with 'kv' if ONLY found within the key/value list
evhtp_res(* evhtp_hook_request_fini_cb)(evhtp_request_t *req, void *arg)
EVHTP_EXPORT void evhtp_send_reply_chunk_end(evhtp_request_t *request)
call when all chunks have been sent and you wish to send the last bits.
void * cbarg
argument which is passed to the cb function
EVHTP_EXPORT void evhtp_kvs_add_kvs(evhtp_kvs_t *dst, evhtp_kvs_t *src)
appends all key/val structures from src tailq onto dst tailq
evhtp_uri_t * uri
request URI information
int parser_flags
default query flags to alter 'strictness' (see EVHTP_PARSE_QUERY_FLAG_*)
EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t **hooks)
removes all hooks.
EVHTP_EXPORT void evhtp_connection_set_timeouts(evhtp_connection_t *conn, const struct timeval *r, const struct timeval *w)
sets a connection-specific read/write timeout which overrides the global read/write settings...
evhtp_hook_hostname_cb on_hostname
evserv_t * server
the libevent listener struct
type which defines to hook after all headers have been parsed
evhtp_type type
server or client
void *(* evhtp_ssl_scache_init)(evhtp_t *)
evhtp_res(* evhtp_post_accept_cb)(evhtp_connection_t *conn, void *arg)
unsigned char * query_raw
the unparsed query arguments
void * on_headers_start_arg
evhtp_connection_t * conn
the associated connection
type which defines to hook whenever an error occurs
EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *)
char * hostname
hostname if present in URI
EVHTP_EXPORT void evhtp_request_free(evhtp_request_t *request)
EVHTP_EXPORT evhtp_callback_t * evhtp_set_glob_cb(evhtp_t *htp, const char *pattern, evhtp_callback_cb cb, void *arg)
sets a callback to to be executed on simple glob/wildcard patterns this is useful if the app does not...
evhtp_ssl_scache_add scache_add
htp_method method
HTTP method used.
EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char *key, const char *val, char kalloc, char valloc)
Allocates a new key/value structure.
evhtp_hook_read_cb on_read
EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t *request, evhtp_res code)
start a chunked response.
EVHTP_EXPORT int evhtp_ssl_use_threads(void)
EVHTP_EXPORT int evhtp_use_callback_locks(evhtp_t *htp)
creates a lock around callbacks and hooks, allowing for threaded applications to add/remove/modify ho...
evhtp_res(* evhtp_hook_header_cb)(evhtp_request_t *req, evhtp_header_t *hdr, void *arg)
evhtp_post_accept_cb post_accept
evhtp_ssl_scache_del scache_del
EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t *request)
returns the underlying evhtp_connection_t structure from a request
type which defines to hook once a path has been parsed
void * on_connection_fini_arg
EVHTP_EXPORT evbev_t * evhtp_connection_get_bev(evhtp_connection_t *conn)
returns the underlying connections bufferevent
char * file
the filename if present (c.html)
main structure containing all configuration information
char k_heaped
set to 1 if the key can be free()'d
evhtp_res(* evhtp_hook_chunk_fini_cb)(evhtp_request_t *r, void *arg)
evhtp_res(* evhtp_hook_headers_cb)(evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
evhtp_hook_chunk_fini_cb on_chunk_fini
EVHTP_EXPORT evhtp_query_t * evhtp_parse_query_wflags(const char *query, size_t len, int flags)
Parses the query portion of the uri into a set of key/values.
#define evhtp_headers_iterator
EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t *htp)
stops the listening socket.
evhtp_res status
The HTTP response code or other error conditions.
EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t *conn, evbev_t *bev)
Sets the connections underlying bufferevent.
EVHTP_EXPORT int evhtp_callbacks_add_callback(evhtp_callbacks_t *cbs, evhtp_callback_t *cb)
Adds a evhtp_callback_t to the evhtp_callbacks_t list.
type which defines to hook whenever the parser recieves data in a body
EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t *kvs)
frees a the list of key/values, and all underlying entries
htp_scheme scheme
set if a scheme is found
evhtp_hooks_t * hooks
per-callback hooks
evhtp_ssl_scache_type scache_type
struct evbuffer * scratch_buf
always zero'd out after used
pthread_mutex_t * lock
parent lock for add/del cbs in threads
struct evhtp_callbacks_s evhtp_callbacks_t
void(* evhtp_callback_cb)(evhtp_request_t *req, void *arg)
evhtp_hook_header_cb on_header
unsigned int hash
the full hash generated integer
SSL_SESSION evhtp_ssl_sess_t
evhtp_hook_path_cb on_path
EVHTP_EXPORT int evhtp_bind_socket(evhtp_t *htp, const char *addr, uint16_t port, int backlog)
bind to a socket, optionally with specific protocol support formatting.
evbase_t * evbase
the initialized event_base
char * username
the username in URI (scheme://USER:.
EVHTP_EXPORT void evhtp_connection_free(evhtp_connection_t *connection)
free's all connection related resources, this will also call your request fini hook and request fini ...
EVHTP_EXPORT const char * evhtp_kv_find(evhtp_kvs_t *kvs, const char *key)
find the string value of 'key' from the key/value list 'kvs'
EVHTP_EXPORT evhtp_kv_t * evhtp_kvs_find_kv(evhtp_kvs_t *kvs, const char *key)
find the evhtp_kv_t reference 'key' from the k/val list 'kvs'
evhtp_headers_t * headers_in
headers from client
#define evhtp_header_find
struct evhtp_kvs_s evhtp_kvs_t
evhtp_hook_err_cb on_error
uint8_t evhtp_error_flags
X509_STORE_CTX evhtp_x509_store_ctx_t
EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t *request)
EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t *request, evbev_t *bev)
sets the underlying bufferevent for a evhtp_request
evhtp_t * parent
only when this is a vhost
EVHTP_EXPORT evhtp_query_t * evhtp_parse_query(const char *query, size_t len)
Parses the query portion of the uri into a set of key/values in a strict manner.
evhtp_hooks_t * hooks
request specific hooks
evhtp_callbacks_t * callbacks
a generic key/value structure
unsigned int matched_eoff
offset of where the uri ends mainly used for regex matching
a structure containing all information for a http request.
evthr_pool_t * thr_pool
connection threadpool
EVHTP_EXPORT void evhtp_set_parser_flags(evhtp_t *htp, int flags)
during the request processing cycle, these flags will be used to for query argument parsing...
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(evbase_t *evbase, struct evdns_base *dns_base, const char *addr, uint16_t port)
allocate a new connection
type which defines to hook before the request is free'd
EVHTP_EXPORT void evhtp_set_max_body_size(evhtp_t *htp, uint64_t len)
set a max body size to accept for an incoming request, this will default to unlimited.
EVHTP_EXPORT void evhtp_set_gencb(evhtp_t *htp, evhtp_callback_cb cb, void *arg)
sets a callback which is called if no other callbacks are matched
EVHTP_EXPORT evhtp_header_t * evhtp_header_val_add(evhtp_headers_t *headers, const char *val, char valloc)
finds the last header in the headers tailq and adds the value
evhtp_hook_type
types associated with where a developer can hook into during the request processing cycle...
evhtp_res(* evhtp_hook_headers_start_cb)(evhtp_request_t *r, void *arg)
evhtp_callback_type type
the type of callback (regex|path)
EVHTP_EXPORT evhtp_callback_t * evhtp_set_regex_cb(evhtp_t *htp, const char *pattern, evhtp_callback_cb cb, void *arg)
sets a callback to be executed based on a regex pattern
evhtp_hook_connection_fini_cb on_connection_fini
void * on_chunks_fini_arg
evhtp_res(* evhtp_hook_read_cb)(evhtp_request_t *req, evbuf_t *buf, void *arg)
evhtp_hook_conn_err_cb on_connection_error
EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t *r)
returns the htp_method enum version of the request method.
structure containing a single callback and configuration
EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t *htp, struct sockaddr *, size_t sin_len, int backlog)
bind to an already allocated sockaddr.
evhtp_callback_cb cb
the function to call when fully processed
evhtp_res(* evhtp_hook_conn_err_cb)(evhtp_connection_t *connection, evhtp_error_flags errtype, void *arg)
EVHTP_EXPORT int evhtp_use_threads(evhtp_t *htp, evhtp_thread_init_cb init_cb, int nthreads, void *arg)
Enable thread-pool support for an evhtp_t context.
evhtp_res(* evhtp_hook_path_cb)(evhtp_request_t *req, evhtp_path_t *path, void *arg)
EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method)
Determine if a response should have a body.
EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t *request, evhtp_res code)
EVHTP_EXPORT void evhtp_kvs_add_kv(evhtp_kvs_t *kvs, evhtp_kv_t *kv)
appends a key/val structure to a evhtp_kvs_t tailq
evhtp_hook_chunks_fini_cb on_chunks_fini
EVHTP_EXPORT evbev_t * evhtp_connection_take_ownership(evhtp_connection_t *connection)
let a user take ownership of the underlying bufferevent and free all other underlying resources...
char * server_name
the name included in Host: responses
EVHTP_EXPORT void evhtp_set_timeouts(evhtp_t *htp, const struct timeval *r, const struct timeval *w)
set a read/write timeout on all things evhtp_t.
evhtp_hook_write_cb on_write
evbuf_t * buffer_in
buffer containing data from client
evhtp_request_t * request
the request currently being processed
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new(evbase_t *evbase, const char *addr, uint16_t port)
allocate a new connection
EVHTP_EXPORT int evhtp_unset_hook(evhtp_hooks_t **hooks, evhtp_hook_type type)
remove a specific hook from being called.
evhtp_res(* evhtp_hook_hostname_cb)(evhtp_request_t *r, const char *hostname, void *arg)
evhtp_hook_headers_start_cb on_headers_start
a generic container representing an entire URI strucutre
struct evconnlistener evserv_t
EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t *kv)
frees resources allocated for a single key/value
EVHTP_EXPORT void evhtp_request_set_max_body_size(evhtp_request_t *request, uint64_t len)
just calls evhtp_connection_set_max_body_size for the request.
char * path
the path (/a/b/)
void * cbarg
user-defind arguments passed to the cb
EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t *callback)
frees information associated with a ainflwx callback.
EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t *htp, const char *needle)
attempts to find the callback matching the exact string 'needle'.
char v_heaped
set to 1 if the val can be free()'d
evhtp_callback_cb cb
the actual callback function
EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t *request, evbuf_t *buf)
send a chunk reply.
evhtp_pre_accept_cb pre_accept
type which defines to hook after one header has been parsed
EVHTP_EXPORT void evhtp_set_pre_accept_cb(evhtp_t *htp, evhtp_pre_accept_cb, void *arg)
call a user-defined function before the connection is accepted.
EVHTP_EXPORT void evhtp_set_max_keepalive_requests(evhtp_t *htp, uint64_t num)
sets a maximum number of requests that a single connection can make.
evhtp_res(* evhtp_hook)()
pthread_mutex_t evhtp_mutex_t
evhtp_authority_t * authority
char * full
the full path+file (/a/b/c.html)
TAILQ_HEAD(evhtp_callbacks_s, evhtp_callback_s)
struct bufferevent evbev_t
EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t *connection)
int(* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t *ctx)
void * arg
user-defined evhtp_t specific arguments
EVHTP_EXPORT evhtp_header_t * evhtp_header_key_add(evhtp_headers_t *headers, const char *key, char kalloc)
creates a new evhtp_header_t, sets only the key, and adds to the evhtp_headers TAILQ ...
void(* evhtp_ssl_scache_del)(evhtp_t *htp, unsigned char *sid, int sid_len)
EVHTP_EXPORT evhtp_t * evhtp_new(evbase_t *evbase, void *arg)
creates a new evhtp_t instance
EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void *arg)
allocate a new request
evhtp_proto proto
HTTP protocol used.
evhtp_res(* evhtp_pre_accept_cb)(evhtp_connection_t *conn, void *arg)
EVHTP_EXPORT evbev_t * evhtp_request_get_bev(evhtp_request_t *request)
returns the underlying requests bufferevent
evhtp_ssl_cfg_t * ssl_cfg
char * password
the password in URI (scheme://...:PASS.
evhtp_res(* evhtp_hook_chunk_new_cb)(evhtp_request_t *r, uint64_t len, void *arg)
EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t *htp)
when a client sends an Expect: 100-continue, if this is function is called, evhtp will not send a HTT...
EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t *request, int val)
evhtp_res(* evhtp_hook_write_cb)(evhtp_connection_t *conn, void *arg)
EVHTP_EXPORT int evhtp_unescape_string(unsigned char **out, unsigned char *str, size_t str_len)
Unescapes strings like '%7B1,%202,%203%7D' would become '{1, 2, 3}'.
EVHTP_EXPORT void evhtp_send_reply(evhtp_request_t *request, evhtp_res code)
generates all the right information for a reply to be sent to the client
EVHTP_EXPORT int evhtp_add_vhost(evhtp_t *evhtp, const char *name, evhtp_t *vhost)
add an evhtp_t structure (with its own callbacks) to a base evhtp_t structure for virtual hosts...
evhtp_hook_request_fini_cb on_request_fini
EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t *htp, int flags)
bufferevent flags which will be used for bev sockets.
EVHTP_EXPORT int evhtp_set_hook(evhtp_hooks_t **hooks, evhtp_hook_type type, evhtp_hook cb, void *arg)
sets a callback hook for either a connection or a path/regex .
EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t *request, evbuf_t *buf)
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(evbase_t *evbase, const char *addr, uint16_t port, evhtp_ssl_ctx_t *ctx)
evhtp_ssl_ctx_t * ssl_ctx
if ssl enabled, this is the servers CTX
evhtp_t * htp
the parent evhtp_t structure
evhtp_hook_headers_cb on_headers
evhtp_ssl_scache_init scache_init
EVHTP_EXPORT evhtp_callback_t * evhtp_set_cb(evhtp_t *htp, const char *path, evhtp_callback_cb cb, void *arg)
sets a callback to be executed on a specific path
evhtp_ssl_chk_issued_cb x509_chk_issued_cb
EVHTP_EXPORT void evhtp_connection_set_max_body_size(evhtp_connection_t *conn, uint64_t len)
set a max body size for a specific connection, this will default to the size set by evhtp_set_max_bod...
evhtp_res(* evhtp_hook_connection_fini_cb)(evhtp_connection_t *connection, void *arg)
EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t *c, evhtp_request_t *r, htp_method meth, const char *uri)
make a client request
void * on_connection_error_arg
void(* evhtp_hook_err_cb)(evhtp_request_t *req, evhtp_error_flags errtype, void *arg)
EVHTP_EXPORT int evhtp_add_alias(evhtp_t *evhtp, const char *name)
Add an alias hostname for a virtual-host specific evhtp_t.
uint16_t port
port if present in URI
EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void)
creates an empty list of key/values
int bev_flags
bufferevent flags to use on bufferevent_*_socket_new()
EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t *request)
unsigned int matched_soff
offset of where the uri starts mainly used for regex matching
evhtp_ssl_sess_t *(* evhtp_ssl_scache_get)(evhtp_connection_t *connection, unsigned char *sid, int sid_len)
evhtp_ssl_verify_cb x509_verify_cb
EVHTP_EXPORT int evhtp_ssl_init(evhtp_t *htp, evhtp_ssl_cfg_t *ssl_cfg)
evhtp_defaults_t defaults
evhtp_res(* evhtp_hook_chunks_fini_cb)(evhtp_request_t *r, void *arg)
TAILQ_ENTRY(evhtp_alias_s) next
EVHTP_EXPORT void evhtp_set_post_accept_cb(evhtp_t *htp, evhtp_post_accept_cb, void *arg)
call a user-defined function right after a connection is accepted.
evhtp_hook_event_cb on_event
void(* evhtp_hook_event_cb)(evhtp_connection_t *conn, short events, void *arg)
evhtp_thread_init_cb thread_init_cb
evhtp_ssl_scache_get scache_get
unsigned char * fragment
data after '#' in uri
EVHTP_EXPORT int evhtp_kvs_for_each(evhtp_kvs_t *kvs, evhtp_kvs_iterator cb, void *arg)
callback iterator which executes 'cb' for every entry in 'kvs'
structure which represents a URI path and or file
evbuf_t * buffer_out
buffer containing data to client
int(* evhtp_kvs_iterator)(evhtp_kv_t *kv, void *arg)
int(* evhtp_ssl_scache_add)(evhtp_connection_t *connection, unsigned char *sid, int sid_len, evhtp_ssl_sess_t *sess)
uint64_t max_keepalive_requests
EVHTP_EXPORT evhtp_callback_t * evhtp_callback_new(const char *path, evhtp_callback_type type, evhtp_callback_cb cb, void *arg)
creates a new evhtp_callback_t structure.
#define evhtp_headers_add_header
EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t *request)
structure which represents authority information in a URI
void(* evhtp_thread_init_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
evhtp_headers_t * headers_out
headers to client
void * on_request_fini_arg
EVHTP_EXPORT void evhtp_free(evhtp_t *evhtp)