Libevhtp 1.2.13
evhtp/evhtp.h
Go to the documentation of this file.
1
5#include <evhtp/config.h>
6
7#ifndef __EVHTP__H__
8#define __EVHTP__H__
9
11#ifndef EVHTP_DISABLE_EVTHR
12#include <evhtp/thread.h>
13#endif
14
15#include <evhtp/parser.h>
16
17#ifndef EVHTP_DISABLE_REGEX
18#include <onigposix.h>
19#endif
20
21#include <sys/queue.h>
22#include <event2/event.h>
23#include <event2/listener.h>
24#include <event2/buffer.h>
25#include <event2/bufferevent.h>
26
27#ifndef EVHTP_DISABLE_SSL
28#include <event2/bufferevent_ssl.h>
29#include <openssl/dh.h>
30#include <openssl/ssl.h>
31#include <openssl/err.h>
32#include <openssl/rand.h>
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39struct evhtp_callback;
40struct evhtp_callbacks;
41struct evhtp_kvs;
42
43#ifndef EVHTP_DISABLE_SSL
44typedef SSL_SESSION evhtp_ssl_sess_t;
45typedef SSL evhtp_ssl_t;
46typedef SSL_CTX evhtp_ssl_ctx_t;
47typedef X509 evhtp_x509_t;
48typedef X509_STORE_CTX evhtp_x509_store_ctx_t;
49#if OPENSSL_VERSION_NUMBER < 0x10100000L
50typedef unsigned char evhtp_ssl_data_t;
51#else
52typedef const unsigned char evhtp_ssl_data_t;
53#endif
54#else
55typedef void evhtp_ssl_sess_t;
56typedef void evhtp_ssl_t;
57typedef void evhtp_ssl_ctx_t;
58typedef void evhtp_x509_t;
59typedef void evhtp_x509_store_ctx_t;
60#endif
61
62typedef struct evbuffer evbuf_t;
63typedef struct event event_t;
64typedef struct evconnlistener evserv_t;
65typedef struct bufferevent evbev_t;
66
67#ifdef EVHTP_DISABLE_EVTHR
68typedef struct event_base evbase_t;
69typedef void evthr_t;
70typedef void evthr_pool_t;
71typedef void evhtp_mutex_t;
72#else
73typedef pthread_mutex_t evhtp_mutex_t;
74#endif
75
76typedef struct evhtp evhtp_t;
77typedef struct evhtp_defaults evhtp_defaults_t;
78typedef struct evhtp_callbacks evhtp_callbacks_t;
79typedef struct evhtp_callback evhtp_callback_t;
80typedef struct evhtp_kv evhtp_kv_t;
81typedef struct evhtp_kvs evhtp_kvs_t;
82typedef struct evhtp_uri evhtp_uri_t;
83typedef struct evhtp_path evhtp_path_t;
84typedef struct evhtp_authority evhtp_authority_t;
85typedef struct evhtp_request evhtp_request_t;
86typedef struct evhtp_hooks evhtp_hooks_t;
87typedef struct evhtp_connection evhtp_connection_t;
88typedef struct evhtp_ssl_cfg evhtp_ssl_cfg_t;
89typedef struct evhtp_alias evhtp_alias_t;
90typedef uint16_t evhtp_res;
91typedef uint8_t evhtp_error_flags;
92
93typedef struct evhtp_kv evhtp_header_t;
94typedef struct evhtp_kvs evhtp_headers_t;
95typedef struct evhtp_kvs evhtp_query_t;
96
103
126
134
140
145
151
152typedef void (* evhtp_thread_init_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
153typedef void (* evhtp_thread_exit_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
154typedef void (* evhtp_callback_cb)(evhtp_request_t * req, void * arg);
155typedef void (* evhtp_hook_err_cb)(evhtp_request_t * req, evhtp_error_flags errtype, void * arg);
156typedef void (* evhtp_hook_event_cb)(evhtp_connection_t * conn, short events, void * arg);
157
158/* Generic hook for passing ISO tests */
159typedef evhtp_res (* evhtp_hook)();
160
161typedef evhtp_res (* evhtp_hook_conn_err_cb)(evhtp_connection_t * connection, evhtp_error_flags errtype, void * arg);
162typedef evhtp_res (* evhtp_pre_accept_cb)(evhtp_connection_t * conn, void * arg);
163typedef evhtp_res (* evhtp_post_accept_cb)(evhtp_connection_t * conn, void * arg);
164typedef evhtp_res (* evhtp_hook_header_cb)(evhtp_request_t * req, evhtp_header_t * hdr, void * arg);
165typedef evhtp_res (* evhtp_hook_headers_cb)(evhtp_request_t * req, evhtp_headers_t * hdr, void * arg);
166typedef evhtp_res (* evhtp_hook_path_cb)(evhtp_request_t * req, evhtp_path_t * path, void * arg);
167typedef evhtp_res (* evhtp_hook_read_cb)(evhtp_request_t * req, struct evbuffer * buf, void * arg);
168typedef evhtp_res (* evhtp_hook_request_fini_cb)(evhtp_request_t * req, void * arg);
169typedef evhtp_res (* evhtp_hook_connection_fini_cb)(evhtp_connection_t * connection, void * arg);
170typedef evhtp_res (* evhtp_hook_chunk_new_cb)(evhtp_request_t * r, uint64_t len, void * arg);
171typedef evhtp_res (* evhtp_hook_chunk_fini_cb)(evhtp_request_t * r, void * arg);
172typedef evhtp_res (* evhtp_hook_chunks_fini_cb)(evhtp_request_t * r, void * arg);
173typedef evhtp_res (* evhtp_hook_headers_start_cb)(evhtp_request_t * r, void * arg);
174typedef evhtp_res (* evhtp_hook_hostname_cb)(evhtp_request_t * r, const char * hostname, void * arg);
175typedef evhtp_res (* evhtp_hook_write_cb)(evhtp_connection_t * conn, void * arg);
176
177typedef int (* evhtp_kvs_iterator)(evhtp_kv_t * kv, void * arg);
178typedef int (* evhtp_headers_iterator)(evhtp_header_t * header, void * arg);
179
180#ifndef EVHTP_DISABLE_SSL
181typedef int (* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t * ctx);
183typedef EVP_PKEY * (* evhtp_ssl_decrypt_cb)(char * privfile);
184
185typedef int (* evhtp_ssl_scache_add)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len, evhtp_ssl_sess_t * sess);
186typedef void (* evhtp_ssl_scache_del)(evhtp_t * htp, evhtp_ssl_data_t * sid, int sid_len);
187typedef evhtp_ssl_sess_t * (* evhtp_ssl_scache_get)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len);
188
189typedef void * (* evhtp_ssl_scache_init)(evhtp_t *);
190#endif
191
192#define EVHTP_VERSION "1.2.18"
193#define EVHTP_VERSION_MAJOR 1
194#define EVHTP_VERSION_MINOR 2
195#define EVHTP_VERSION_PATCH 18
196
197#define evhtp_headers_iterator evhtp_kvs_iterator
198
199#define EVHTP_RES_ERROR 0
200#define EVHTP_RES_PAUSE 1
201#define EVHTP_RES_FATAL 2
202#define EVHTP_RES_USER 3
203#define EVHTP_RES_DATA_TOO_LONG 4
204#define EVHTP_RES_OK 200
205
206#ifndef DOXYGEN_SHOULD_SKIP_THIS
207#define EVHTP_RES_100 100
208#define EVHTP_RES_CONTINUE 100
209#define EVHTP_RES_SWITCH_PROTO 101
210#define EVHTP_RES_PROCESSING 102
211#define EVHTP_RES_URI_TOOLONG 122
212
213#define EVHTP_RES_200 200
214#define EVHTP_RES_CREATED 201
215#define EVHTP_RES_ACCEPTED 202
216#define EVHTP_RES_NAUTHINFO 203
217#define EVHTP_RES_NOCONTENT 204
218#define EVHTP_RES_RSTCONTENT 205
219#define EVHTP_RES_PARTIAL 206
220#define EVHTP_RES_MSTATUS 207
221#define EVHTP_RES_IMUSED 226
222
223#define EVHTP_RES_300 300
224#define EVHTP_RES_MCHOICE 300
225#define EVHTP_RES_MOVEDPERM 301
226#define EVHTP_RES_FOUND 302
227#define EVHTP_RES_SEEOTHER 303
228#define EVHTP_RES_NOTMOD 304
229#define EVHTP_RES_USEPROXY 305
230#define EVHTP_RES_SWITCHPROXY 306
231#define EVHTP_RES_TMPREDIR 307
232
233#define EVHTP_RES_400 400
234#define EVHTP_RES_BADREQ 400
235#define EVHTP_RES_UNAUTH 401
236#define EVHTP_RES_PAYREQ 402
237#define EVHTP_RES_FORBIDDEN 403
238#define EVHTP_RES_NOTFOUND 404
239#define EVHTP_RES_METHNALLOWED 405
240#define EVHTP_RES_NACCEPTABLE 406
241#define EVHTP_RES_PROXYAUTHREQ 407
242#define EVHTP_RES_TIMEOUT 408
243#define EVHTP_RES_CONFLICT 409
244#define EVHTP_RES_GONE 410
245#define EVHTP_RES_LENREQ 411
246#define EVHTP_RES_PRECONDFAIL 412
247#define EVHTP_RES_ENTOOLARGE 413
248#define EVHTP_RES_URITOOLARGE 414
249#define EVHTP_RES_UNSUPPORTED 415
250#define EVHTP_RES_RANGENOTSC 416
251#define EVHTP_RES_EXPECTFAIL 417
252#define EVHTP_RES_IAMATEAPOT 418
253
254#define EVHTP_RES_500 500
255#define EVHTP_RES_SERVERR 500
256#define EVHTP_RES_NOTIMPL 501
257#define EVHTP_RES_BADGATEWAY 502
258#define EVHTP_RES_SERVUNAVAIL 503
259#define EVHTP_RES_GWTIMEOUT 504
260#define EVHTP_RES_VERNSUPPORT 505
261#define EVHTP_RES_BWEXEED 509
262#endif
263
272
274 char * alias;
275
277};
278
283struct evhtp {
284 evhtp_t * parent;
285 struct event_base * evbase;
286 struct evconnlistener * server;
287 char * server_name;
288 void * arg;
292
293 #define EVHTP_FLAG_ENABLE_100_CONT (1 << 1)
294 #define EVHTP_FLAG_ENABLE_REUSEPORT (1 << 2)
295 #define EVHTP_FLAG_ENABLE_NODELAY (1 << 3)
296 #define EVHTP_FLAG_ENABLE_DEFER_ACCEPT (1 << 4)
297 #define EVHTP_FLAG_DEFAULTS EVHTP_FLAG_ENABLE_100_CONT
298 #define EVHTP_FLAG_ENABLE_ALL EVHTP_FLAG_ENABLE_100_CONT \
299 | EVHTP_FLAG_ENABLE_REUSEPORT \
300 | EVHTP_FLAG_ENABLE_NODELAY \
301 | EVHTP_FLAG_ENABLE_DEFER_ACCEPT
302
303 uint16_t flags;
304 uint16_t parser_flags;
306#ifndef EVHTP_DISABLE_SSL
308 evhtp_ssl_cfg_t * ssl_cfg;
309#endif
310
311#ifndef EVHTP_DISABLE_EVTHR
312 evthr_pool_t * thr_pool;
313 pthread_mutex_t * lock;
317
318 /* keep backwards compat because I'm dumb and didn't
319 * make these structs private
320 */
321 #define thread_init_cbarg thread_cbarg
323#endif
325 evhtp_defaults_t defaults;
326
327 struct timeval recv_timeo;
328 struct timeval send_timeo;
329
331 TAILQ_HEAD(, evhtp) vhosts;
332 TAILQ_ENTRY(evhtp) next_vhost;
333};
334
335
339struct evhtp_kv {
340 char * key;
341 char * val;
342
343 size_t klen;
344 size_t vlen;
345
346 char k_heaped;
347 char v_heaped;
350};
351
353
354
355
359struct evhtp_uri {
360 evhtp_authority_t * authority;
361 evhtp_path_t * path;
362 unsigned char * fragment;
363 unsigned char * query_raw;
365 htp_scheme scheme;
366};
367
368
373 char * username;
374 char * password;
375 char * hostname;
376 uint16_t port;
377};
378
379
384 char * full;
385 char * path;
386 char * file;
388 char * match_end;
389 unsigned int matched_soff;
392 unsigned int matched_eoff;
395};
396
397
402 evhtp_t * htp;
403 evhtp_connection_t * conn;
404 evhtp_hooks_t * hooks;
405 evhtp_uri_t * uri;
406 struct evbuffer * buffer_in;
407 struct evbuffer * buffer_out;
411 htp_method method;
413 #define EVHTP_REQ_FLAG_KEEPALIVE (1 << 1)
414 #define EVHTP_REQ_FLAG_FINISHED (1 << 2)
415 #define EVHTP_REQ_FLAG_CHUNKED (1 << 3)
416 #define EVHTP_REQ_FLAG_ERROR (1 << 4)
417 uint16_t flags;
418
420 void * cbarg;
423};
424
425#define evhtp_request_content_len(r) htparser_get_content_length(r->conn->parser)
426
428 evhtp_t * htp;
429 struct event_base * evbase;
430 struct bufferevent * bev;
431#ifndef EVHTP_DISABLE_EVTHR
432 evthr_t * thread;
433#endif
434#ifndef EVHTP_DISABLE_SSL
436#endif
437 evhtp_hooks_t * hooks;
439 struct event * resume_ev;
440 struct sockaddr * saddr;
441 struct timeval recv_timeo;
442 struct timeval send_timeo;
443 evutil_socket_t sock;
444 evhtp_request_t * request;
447 uint64_t num_requests;
449 #define EVHTP_CONN_FLAG_ERROR (1 << 1)
450 #define EVHTP_CONN_FLAG_OWNER (1 << 2)
451 #define EVHTP_CONN_FLAG_VHOST_VIA_SNI (1 << 3)
452 #define EVHTP_CONN_FLAG_PAUSED (1 << 4)
453 #define EVHTP_CONN_FLAG_CONNECTED (1 << 5)
454 #define EVHTP_CONN_FLAG_WAITING (1 << 6)
455 #define EVHTP_CONN_FLAG_FREE_CONN (1 << 7)
456 #define EVHTP_CONN_FLAG_KEEPALIVE (1 << 8)
457 uint16_t flags;
458
459 struct evbuffer * scratch_buf;
461#ifdef EVHTP_FUTURE_USE
462 TAILQ_HEAD(, evhtp_request) pending;
463#endif
464};
465
499
500#ifndef EVHTP_DISABLE_SSL
526#endif
527
528
529EVHTP_EXPORT void evhtp_set_mem_functions(void *(*malloc_)(size_t),
530 void *(*realloc_)(void *, size_t),
531 void (* free_)(void *));
532
541EVHTP_EXPORT evhtp_t * evhtp_new(struct event_base * evbase, void * arg);
542
543EVHTP_EXPORT void evhtp_enable_flag(evhtp_t *, int);
544EVHTP_EXPORT void evhtp_connection_enable_flag(evhtp_connection_t *, int);
545EVHTP_EXPORT void evhtp_request_enable_flag(evhtp_request_t *, int);
546EVHTP_EXPORT int evhtp_get_flags(evhtp_t *);
547EVHTP_EXPORT int evhtp_connection_get_flags(evhtp_connection_t *);
548EVHTP_EXPORT int evhtp_request_get_flags(evhtp_request_t *);
549EVHTP_EXPORT void evhtp_disable_flag(evhtp_t *, int);
550EVHTP_EXPORT void evhtp_connection_disable_flag(evhtp_connection_t *, int);
551EVHTP_EXPORT void evhtp_request_disable_flag(evhtp_request_t *, int);
552
560EVHTP_EXPORT void evhtp_free(evhtp_t * evhtp);
561
571EVHTP_EXPORT void evhtp_set_timeouts(evhtp_t * htp, const struct timeval * r, const struct timeval * w);
572
573
574
588EVHTP_EXPORT void evhtp_set_parser_flags(evhtp_t * htp, int flags);
589
596EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t * htp, int flags);
597
598#ifndef EVHTP_DISABLE_SSL
599EVHTP_EXPORT int evhtp_ssl_use_threads(void);
600EVHTP_EXPORT int evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
601#endif
602
603
610EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t * htp)
611DEPRECATED("evhtp_disable_100 will soon be deprecated, use htp->flags instead");
612
621EVHTP_EXPORT int evhtp_use_callback_locks(evhtp_t * htp);
622
630EVHTP_EXPORT void evhtp_set_gencb(evhtp_t * htp, evhtp_callback_cb cb, void * arg);
631
632
642EVHTP_EXPORT void evhtp_set_pre_accept_cb(evhtp_t * htp, evhtp_pre_accept_cb, void * arg);
643
644
654EVHTP_EXPORT void evhtp_set_post_accept_cb(evhtp_t * htp, evhtp_post_accept_cb, void * arg);
655
666EVHTP_EXPORT evhtp_callback_t * evhtp_set_cb(evhtp_t * htp, const char * path,
667 evhtp_callback_cb cb, void * arg);
668
669
680#ifndef EVHTP_DISABLE_REGEX
681EVHTP_EXPORT evhtp_callback_t * evhtp_set_regex_cb(evhtp_t * htp, const char * pattern,
682 evhtp_callback_cb cb, void * arg);
683#endif
684
685
686
699EVHTP_EXPORT evhtp_callback_t * evhtp_set_glob_cb(evhtp_t * htp, const char * pattern,
700 evhtp_callback_cb cb, void * arg);
701
702
728EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t * htp, const char * needle);
729
769EVHTP_EXPORT int evhtp_connection_set_hook(evhtp_connection_t * c, evhtp_hook_type type, evhtp_hook cb, void * arg);
770EVHTP_EXPORT int evhtp_request_set_hook(evhtp_request_t * r, evhtp_hook_type type, evhtp_hook cb, void * arg);
771EVHTP_EXPORT int evhtp_callback_set_hook(evhtp_callback_t * cb, evhtp_hook_type type, evhtp_hook hookcb, void * arg);
772
773EVHTP_EXPORT evhtp_hooks_t * evhtp_connection_get_hooks(evhtp_connection_t * c);
774EVHTP_EXPORT evhtp_hooks_t * evhtp_request_get_hooks(evhtp_request_t * r);
775EVHTP_EXPORT evhtp_hooks_t * evhtp_callback_get_hooks(evhtp_callback_t * cb);
776
784EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t ** hooks);
785
786EVHTP_EXPORT int evhtp_request_unset_hook(evhtp_request_t * req, evhtp_hook_type type);
787EVHTP_EXPORT int evhtp_connection_unset_hook(evhtp_connection_t * conn, evhtp_hook_type type);
788EVHTP_EXPORT int evhtp_callback_unset_hook(evhtp_callback_t * callback, evhtp_hook_type type);
789
790
806EVHTP_EXPORT int evhtp_bind_socket(evhtp_t * htp, const char * addr, uint16_t port, int backlog);
807
808
814EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t * htp);
815
816
830EVHTP_EXPORT int evhtp_accept_socket(evhtp_t * htp, evutil_socket_t sock, int backlog);
831
843EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t * htp, struct sockaddr *,
844 size_t sin_len, int backlog);
845
846
861EVHTP_EXPORT int evhtp_use_threads(evhtp_t *, evhtp_thread_init_cb, int nthreads, void *)
862DEPRECATED("will take on the syntax of evhtp_use_threads_wexit");
863
868EVHTP_EXPORT int evhtp_use_threads_wexit(evhtp_t *,
871 int nthreads, void * arg);
872
879EVHTP_EXPORT void evhtp_send_reply(evhtp_request_t * request, evhtp_res code);
880
881
882/* The following three functions allow for the user to do what evhtp_send_reply does at its core
883 * but for the weak of heart.
884 */
885EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t * request, evhtp_res code);
886EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t * request, struct evbuffer * buf);
887EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t * request);
888
895EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method);
896
904EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t * request, evhtp_res code);
905
906
913EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t * request, struct evbuffer * buf);
914
921EVHTP_EXPORT void evhtp_send_reply_chunk_end(evhtp_request_t * request);
922
942EVHTP_EXPORT evhtp_callback_t *
943evhtp_callback_new(const char * path, evhtp_callback_type type, evhtp_callback_cb cb, void * arg);
944
954EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t * callback);
955
956
965EVHTP_EXPORT int evhtp_callbacks_add_callback(evhtp_callbacks_t * cbs, evhtp_callback_t * cb);
966
967
980EVHTP_EXPORT int evhtp_add_vhost(evhtp_t * evhtp, const char * name, evhtp_t * vhost);
981
982
993EVHTP_EXPORT int evhtp_add_alias(evhtp_t * evhtp, const char * name);
994
995
1007EVHTP_EXPORT int evhtp_add_aliases(evhtp_t * evhtp, const char * name, ...);
1008
1019EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char * key, const char * val, char kalloc, char valloc);
1020
1021
1027EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void);
1028
1029
1035EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t * kv);
1036
1037
1043EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t * kvs);
1044
1051EVHTP_EXPORT void evhtp_kv_rm_and_free(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1052
1061EVHTP_EXPORT const char * evhtp_kv_find(evhtp_kvs_t * kvs, const char * key);
1062
1063
1072EVHTP_EXPORT evhtp_kv_t * evhtp_kvs_find_kv(evhtp_kvs_t * kvs, const char * key);
1073
1074
1081EVHTP_EXPORT void evhtp_kvs_add_kv(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1082
1089EVHTP_EXPORT void evhtp_kvs_add_kvs(evhtp_kvs_t * dst, evhtp_kvs_t * src);
1090
1091
1101EVHTP_EXPORT int evhtp_kvs_for_each(evhtp_kvs_t * kvs, evhtp_kvs_iterator cb, void * arg);
1102
1103#define EVHTP_PARSE_QUERY_FLAG_STRICT 0
1104#define EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX (1 << 0)
1105#define EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS (1 << 1)
1106#define EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS (1 << 2)
1107#define EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP (1 << 3)
1108#define EVHTP_PARSE_QUERY_FLAG_IGNORE_FRAGMENTS (1 << 4)
1109#define EVHTP_PARSE_QUERY_FLAG_LENIENT \
1110 EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX \
1111 | EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS \
1112 | EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS \
1113 | EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP
1114
1115#define EVHTP_PARSE_QUERY_FLAG_DEFAULT EVHTP_PARSE_QUERY_FLAG_LENIENT
1116
1128EVHTP_EXPORT evhtp_query_t * evhtp_parse_query_wflags(const char * query, size_t len, int flags);
1129
1141EVHTP_EXPORT evhtp_query_t * evhtp_parse_query(const char * query, size_t len);
1142
1152EVHTP_EXPORT int evhtp_unescape_string(unsigned char ** out, unsigned char * str, size_t str_len);
1153
1164EVHTP_EXPORT evhtp_header_t * evhtp_header_new(const char * key, const char * val,
1165 char kalloc, char valloc);
1166
1177EVHTP_EXPORT evhtp_header_t * evhtp_header_key_add(evhtp_headers_t * headers,
1178 const char * key, char kalloc);
1179
1180
1190EVHTP_EXPORT evhtp_header_t * evhtp_header_val_add(evhtp_headers_t * headers,
1191 const char * val, char valloc);
1192
1193
1200EVHTP_EXPORT void evhtp_headers_add_header(evhtp_headers_t * headers, evhtp_header_t * header);
1201
1210EVHTP_EXPORT const char * evhtp_header_find(evhtp_headers_t * headers, const char * key);
1211
1212#define evhtp_headers_find_header evhtp_kvs_find_kv
1213#define evhtp_headers_for_each evhtp_kvs_for_each
1214#define evhtp_header_free evhtp_kv_free
1215#define evhtp_headers_new evhtp_kvs_new
1216#define evhtp_headers_free evhtp_kvs_free
1217#define evhtp_header_rm_and_free evhtp_kv_rm_and_free
1218#define evhtp_headers_add_headers evhtp_kvs_add_kvs
1219#define evhtp_query_new evhtp_kvs_new
1220#define evhtp_query_free evhtp_kvs_free
1221
1222
1230EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t * r);
1231EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t * r);
1232
1233
1241EVHTP_EXPORT evhtp_res evhtp_request_get_status_code(evhtp_request_t * r);
1242
1243
1252EVHTP_EXPORT const char * evhtp_request_get_status_code_str(evhtp_request_t * r);
1253
1254/* the following functions all do the same thing, pause and the processing */
1255
1261EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t * connection);
1262
1268EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t * connection);
1269
1277EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t * request);
1278
1286EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t * request);
1287
1288
1296EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t * request);
1297
1304EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t * conn, struct bufferevent * bev);
1305
1312EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t * request, struct bufferevent * bev);
1313
1314
1322EVHTP_EXPORT struct bufferevent * evhtp_connection_get_bev(evhtp_connection_t * conn);
1323
1332EVHTP_EXPORT void
1333evhtp_connection_set_timeouts(evhtp_connection_t * conn,
1334 const struct timeval * r,
1335 const struct timeval * w);
1336
1344EVHTP_EXPORT struct bufferevent * evhtp_request_get_bev(evhtp_request_t * request);
1345
1346
1359EVHTP_EXPORT struct bufferevent * evhtp_connection_take_ownership(evhtp_connection_t * connection);
1360
1361
1368EVHTP_EXPORT void evhtp_connection_free(evhtp_connection_t * connection);
1369EVHTP_EXPORT void evhtp_request_free(evhtp_request_t * request);
1370
1378EVHTP_EXPORT void evhtp_set_max_body_size(evhtp_t * htp, uint64_t len);
1379
1387EVHTP_EXPORT void evhtp_connection_set_max_body_size(evhtp_connection_t * conn, uint64_t len);
1388
1395EVHTP_EXPORT void evhtp_request_set_max_body_size(evhtp_request_t * request, uint64_t len);
1396EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t * request, int val);
1397
1404EVHTP_EXPORT void evhtp_set_max_keepalive_requests(evhtp_t * htp, uint64_t num);
1405
1406
1407/*****************************************************************
1408* client request functions *
1409*****************************************************************/
1410
1414EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(
1415 struct event_base * evbase,
1416 struct evdns_base * dns_base,
1417 const char * addr, uint16_t port);
1418
1422EVHTP_EXPORT evhtp_connection_t *
1423evhtp_connection_new(struct event_base * evbase, const char * addr, uint16_t port);
1424
1425#ifndef EVHTP_DISABLE_SSL
1426EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(
1427 struct event_base * evbase,
1428 const char * addr, uint16_t port, evhtp_ssl_ctx_t * ctx);
1429#endif
1430
1431
1435EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void * arg);
1436
1440EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t * c,
1441 evhtp_request_t * r, htp_method meth, const char * uri);
1442
1443EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *);
1444
1445#define evhtp_safe_free(_var, _freefn) do { \
1446 _freefn((_var)); \
1447 (_var) = NULL; \
1448} while (0)
1449
1450
1451#ifdef __cplusplus
1452}
1453#endif
1454
1455#endif /* __EVHTP__H__ */
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
Definition evhtp.c:3785
pthread_mutex_t evhtp_mutex_t
Definition evhtp/evhtp.h:73
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.
Definition evhtp.c:5232
EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t *c, evhtp_request_t *r, htp_method meth, const char *uri)
make a client request
Definition evhtp.c:5541
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
Definition evhtp.c:3237
unsigned char evhtp_ssl_data_t
Definition evhtp/evhtp.h:50
evhtp_res(* evhtp_hook_headers_start_cb)(evhtp_request_t *r, void *arg)
EVP_PKEY *(* evhtp_ssl_decrypt_cb)(char *privfile)
EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method)
Determine if a response should have a body.
Definition evhtp.c:3811
evhtp_res(* evhtp_hook_chunk_new_cb)(evhtp_request_t *r, uint64_t len, void *arg)
EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t *request)
Definition evhtp.c:3779
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
Definition evhtp.c:3106
EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t *callback)
safely frees callback structure memory and internals
Definition evhtp.c:4253
EVHTP_EXPORT int evhtp_use_threads(evhtp_t *, evhtp_thread_init_cb, int nthreads, void *) DEPRECATED("will take on the syntax of evhtp_use_threads_wexit")
Enable thread-pool support for an evhtp_t context.
Definition evhtp.c:4594
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.
Definition evhtp.c:3486
EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void *arg)
allocate a new request
Definition evhtp.c:5526
EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void)
creates an empty list of key/values
Definition evhtp.c:3140
EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t *request, int val)
Definition evhtp.c:5006
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.
Definition evhtp.c:5149
evhtp_res(* evhtp_hook_hostname_cb)(evhtp_request_t *r, const char *hostname, void *arg)
EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t *r)
Definition evhtp.c:5020
EVHTP_EXPORT void evhtp_connection_enable_flag(evhtp_connection_t *, int)
EVHTP_EXPORT void evhtp_request_free(evhtp_request_t *request)
Definition evhtp.c:5103
evhtp_res(* evhtp_hook_connection_fini_cb)(evhtp_connection_t *connection, void *arg)
EVHTP_EXPORT void evhtp_set_mem_functions(void *(*malloc_)(size_t), void *(*realloc_)(void *, size_t), void(*free_)(void *))
EVHTP_EXPORT evhtp_hooks_t * evhtp_callback_get_hooks(evhtp_callback_t *cb)
returns callback hooks
Definition evhtp.c:4483
EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t *conn, struct bufferevent *bev)
Sets the connections underlying bufferevent.
Definition evhtp.c:4994
struct evhtp_kvs evhtp_headers_t
Definition evhtp/evhtp.h:94
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.
Definition evhtp.c:4719
SSL_CTX evhtp_ssl_ctx_t
Definition evhtp/evhtp.h:46
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'
Definition evhtp.c:3329
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.
Definition evhtp.c:5060
EVHTP_EXPORT const char * evhtp_request_get_status_code_str(evhtp_request_t *r)
wrapper around get_status_code that returns the string version of the last status code set for a requ...
Definition evhtp.c:5032
evhtp_res(* evhtp_hook_conn_err_cb)(evhtp_connection_t *connection, evhtp_error_flags errtype, void *arg)
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
Definition evhtp.c:4630
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...
Definition evhtp.c:5050
evhtp_res(* evhtp_hook_request_fini_cb)(evhtp_request_t *req, void *arg)
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 ...
Definition evhtp.c:5066
EVHTP_EXPORT void evhtp_headers_add_header(evhtp_headers_t *headers, evhtp_header_t *header)
adds an evhtp_header_t to the end of the evhtp_headers_t tailq
Definition evhtp.c:3317
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.
Definition evhtp.c:3745
EVHTP_EXPORT struct bufferevent * evhtp_connection_take_ownership(evhtp_connection_t *connection)
let a user take ownership of the underlying bufferevent and free all other underlying resources.
Definition evhtp.c:4956
EVHTP_EXPORT int evhtp_add_aliases(evhtp_t *evhtp, const char *name,...)
set a variable number of aliases in one call @reference evhtp_add_alias
Definition evhtp.c:5205
int(* evhtp_ssl_scache_add)(evhtp_connection_t *connection, evhtp_ssl_data_t *sid, int sid_len, evhtp_ssl_sess_t *sess)
SSL_SESSION evhtp_ssl_sess_t
Definition evhtp/evhtp.h:44
void(* evhtp_ssl_scache_del)(evhtp_t *htp, evhtp_ssl_data_t *sid, int sid_len)
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(struct event_base *evbase, const char *addr, uint16_t port, evhtp_ssl_ctx_t *ctx)
Definition evhtp.c:5455
EVHTP_EXPORT int evhtp_request_unset_hook(evhtp_request_t *req, evhtp_hook_type type)
Definition evhtp.c:4380
EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t *request)
Wrapper around evhtp_connection_pause.
Definition evhtp.c:3075
evhtp_res(* evhtp_hook_path_cb)(evhtp_request_t *req, evhtp_path_t *path, void *arg)
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.
Definition evhtp.c:4712
EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t *request, struct evbuffer *buf)
send a chunk reply.
Definition evhtp.c:3888
void(* evhtp_callback_cb)(evhtp_request_t *req, void *arg)
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.
Definition evhtp.c:4186
EVHTP_EXPORT void evhtp_connection_disable_flag(evhtp_connection_t *, int)
EVHTP_EXPORT evhtp_t * evhtp_new(struct event_base *evbase, void *arg)
creates a new evhtp_t instance
Definition evhtp.c:5318
EVHTP_EXPORT void evhtp_enable_flag(evhtp_t *, int)
EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t *request, evhtp_res code)
Definition evhtp.c:3752
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
Definition evhtp.c:3092
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.
Definition evhtp.c:5125
evhtp_res(* evhtp_post_accept_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}'.
Definition evhtp.c:3413
evhtp_callback_type
@ evhtp_callback_type_glob
@ evhtp_callback_type_hash
@ evhtp_callback_type_regex
EVHTP_EXPORT void evhtp_request_enable_flag(evhtp_request_t *, int)
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.
Definition evhtp.c:4114
EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t *connection)
resumes a connection (enables reading) and activates resume event.
Definition evhtp.c:3056
EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t *r)
returns the htp_method enum version of the request method.
Definition evhtp.c:3024
EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t *htp, const char *needle)
attempts to find the callback matching the exact string 'needle'.
Definition evhtp.c:4524
evhtp_res(* evhtp_hook_chunks_fini_cb)(evhtp_request_t *r, void *arg)
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new(struct event_base *evbase, const char *addr, uint16_t port)
allocate a new connection
Definition evhtp.c:5378
EVHTP_EXPORT evhtp_hooks_t * evhtp_connection_get_hooks(evhtp_connection_t *c)
Definition evhtp.c:4451
EVHTP_EXPORT void use htp flags instead
struct evbuffer evbuf_t
Definition evhtp/evhtp.h:62
EVHTP_EXPORT int evhtp_callback_set_hook(evhtp_callback_t *cb, evhtp_hook_type type, evhtp_hook hookcb, void *arg)
Definition evhtp.c:4392
EVHTP_EXPORT int evhtp_add_alias(evhtp_t *evhtp, const char *name)
Add an alias hostname for a virtual-host specific evhtp_t.
Definition evhtp.c:5177
EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t *request)
Wrapper around evhtp_connection_resume.
Definition evhtp.c:3084
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'
Definition evhtp.c:3293
EVHTP_EXPORT void evhtp_free(evhtp_t *evhtp)
Frees evhtp_t structure; will stop and free threads associated with the structure,...
Definition evhtp.c:5330
evhtp_hook_type
types associated with where a developer can hook into during the request processing cycle.
@ evhtp_hook_on_error
type which defines to hook whenever an error occurs
@ evhtp_hook_on_header
type which defines to hook after one header has been parsed
@ evhtp_hook_on_read
type which defines to hook whenever the parser recieves data in a body
@ evhtp_hook_on_new_chunk
@ evhtp_hook_on_chunk_complete
@ evhtp_hook_on_write
@ evhtp_hook_on_request_fini
type which defines to hook before the request is free'd
@ evhtp_hook_on_hostname
@ evhtp_hook_on_chunks_complete
@ evhtp_hook_on_event
@ evhtp_hook_on_conn_error
type which defines to hook whenever a connection error occurs
@ evhtp_hook_on_headers_start
@ evhtp_hook_on_path
type which defines to hook once a path has been parsed
@ evhtp_hook_on_connection_fini
@ evhtp_hook_on_headers
type which defines to hook after all headers have been parsed
@ evhtp_hook__max
SSL evhtp_ssl_t
Definition evhtp/evhtp.h:45
EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t *connection)
pauses a connection (disables reading)
Definition evhtp.c:3034
evhtp_res(* evhtp_hook_read_cb)(evhtp_request_t *req, struct evbuffer *buf, void *arg)
EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t *htp, int flags)
bufferevent flags which will be used for bev sockets.
Definition evhtp.c:5131
EVHTP_EXPORT int evhtp_accept_socket(evhtp_t *htp, evutil_socket_t sock, int backlog)
create the listener plus setup various options with an already-bound socket.
Definition evhtp.c:3997
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.
Definition evhtp.c:5113
EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t *request)
returns the underlying evhtp_connection_t structure from a request
Definition evhtp.c:5014
EVHTP_EXPORT evhtp_hooks_t * evhtp_request_get_hooks(evhtp_request_t *r)
returns request hooks
Definition evhtp.c:4467
TAILQ_HEAD(evhtp_kvs, evhtp_kv)
void *(* evhtp_ssl_scache_init)(evhtp_t *)
EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t *kv)
frees resources allocated for a single key/value
Definition evhtp.c:3219
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
Definition evhtp.c:4489
EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t *htp)
stops the listening socket.
Definition evhtp.c:3924
evhtp_res(* evhtp_hook_header_cb)(evhtp_request_t *req, evhtp_header_t *hdr, void *arg)
int(* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t *ctx, evhtp_x509_t *x, evhtp_x509_t *issuer)
uint8_t evhtp_error_flags
Definition evhtp/evhtp.h:91
EVHTP_EXPORT evhtp_res evhtp_request_get_status_code(evhtp_request_t *r)
Returns the last status code set for a request (request/response)
Definition evhtp.c:5026
EVHTP_EXPORT int evhtp_connection_unset_hook(evhtp_connection_t *conn, evhtp_hook_type type)
Definition evhtp.c:4386
EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t *htp, struct sockaddr *, size_t sin_len, int backlog)
bind to an already allocated sockaddr.
Definition evhtp.c:4047
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.
Definition evhtp.c:5038
X509_STORE_CTX evhtp_x509_store_ctx_t
Definition evhtp/evhtp.h:48
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...
Definition evhtp.c:4613
EVHTP_EXPORT void evhtp_request_disable_flag(evhtp_request_t *, int)
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'
Definition evhtp.c:3273
EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char *key, const char *val, char kalloc, char valloc)
Allocates a new key/value structure.
Definition evhtp.c:3156
evhtp_res(* evhtp_hook)()
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
Definition evhtp.c:3357
EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t *kvs)
frees a the list of key/values, and all underlying entries
Definition evhtp.c:3249
EVHTP_EXPORT int evhtp_request_set_hook(evhtp_request_t *r, evhtp_hook_type type, evhtp_hook cb, void *arg)
Definition evhtp.c:4399
int(* evhtp_kvs_iterator)(evhtp_kv_t *kv, void *arg)
evhtp_ssl_scache_type
Definition evhtp/evhtp.h:97
@ evhtp_ssl_scache_type_user
@ evhtp_ssl_scache_type_builtin
@ evhtp_ssl_scache_type_internal
Definition evhtp/evhtp.h:99
@ evhtp_ssl_scache_type_disabled
Definition evhtp/evhtp.h:98
evhtp_res(* evhtp_hook_chunk_fini_cb)(evhtp_request_t *r, void *arg)
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
Definition evhtp.c:3347
EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t *htp) DEPRECATED("evhtp_disable_100 will soon be deprecated
when a client sends an Expect: 100-continue, if this is function is called, evhtp will not send a HTT...
int(* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t *ctx)
evhtp_res(* evhtp_hook_headers_cb)(evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
evhtp_res(* evhtp_pre_accept_cb)(evhtp_connection_t *conn, void *arg)
void(* evhtp_hook_err_cb)(evhtp_request_t *req, evhtp_error_flags errtype, void *arg)
void(* evhtp_thread_exit_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
struct evhtp_kvs evhtp_kvs_t
Definition evhtp/evhtp.h:81
EVHTP_EXPORT const char * evhtp_header_find(evhtp_headers_t *headers, const char *key)
finds the value of a key in a evhtp_headers_t structure
Definition evhtp.c:3311
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
Definition evhtp.c:4705
EVHTP_EXPORT int evhtp_request_get_flags(evhtp_request_t *)
evhtp_proto
@ EVHTP_PROTO_10
@ EVHTP_PROTO_INVALID
@ EVHTP_PROTO_11
EVHTP_EXPORT int evhtp_connection_get_flags(evhtp_connection_t *)
EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t **hooks)
removes all hooks.
Definition evhtp.c:4412
EVHTP_EXPORT int evhtp_use_threads_wexit(evhtp_t *, evhtp_thread_init_cb, evhtp_thread_exit_cb, int nthreads, void *arg)
Temporary function which will be renamed evhtp_use_threads in the future.
Definition evhtp.c:4601
EVHTP_EXPORT int evhtp_callback_unset_hook(evhtp_callback_t *callback, evhtp_hook_type type)
Definition evhtp.c:4374
EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t *request, struct evbuffer *buf)
Definition evhtp.c:3769
uint16_t evhtp_res
Definition evhtp/evhtp.h:90
evhtp_res(* evhtp_hook_write_cb)(evhtp_connection_t *conn, void *arg)
EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t *request, struct bufferevent *bev)
sets the underlying bufferevent for a evhtp_request
Definition evhtp.c:5000
#define evhtp_headers_iterator
struct evconnlistener evserv_t
Definition evhtp/evhtp.h:64
EVHTP_EXPORT int evhtp_ssl_init(evhtp_t *htp, evhtp_ssl_cfg_t *ssl_cfg)
Definition evhtp.c:4762
X509 evhtp_x509_t
Definition evhtp/evhtp.h:47
EVHTP_EXPORT int evhtp_get_flags(evhtp_t *)
struct event event_t
Definition evhtp/evhtp.h:63
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...
Definition evhtp.c:4670
EVHTP_EXPORT int evhtp_connection_set_hook(evhtp_connection_t *c, evhtp_hook_type type, evhtp_hook cb, void *arg)
sets a callback hook for either a connection or a path/regex .
Definition evhtp.c:4405
EVHTP_EXPORT int evhtp_ssl_use_threads(void)
Definition evhtp.c:4728
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.
Definition evhtp.c:3913
EVHTP_EXPORT void evhtp_disable_flag(evhtp_t *, int)
void(* evhtp_thread_init_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *)
Definition evhtp.c:5589
struct evhtp_kvs evhtp_query_t
Definition evhtp/evhtp.h:95
EVHTP_EXPORT struct bufferevent * evhtp_connection_get_bev(evhtp_connection_t *conn)
returns the underlying connections bufferevent
Definition evhtp.c:4950
EVHTP_EXPORT struct bufferevent * evhtp_request_get_bev(evhtp_request_t *request)
returns the underlying requests bufferevent
Definition evhtp.c:4982
evhtp_ssl_sess_t *(* evhtp_ssl_scache_get)(evhtp_connection_t *connection, evhtp_ssl_data_t *sid, int sid_len)
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.
Definition evhtp.c:4283
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(struct event_base *evbase, struct evdns_base *dns_base, const char *addr, uint16_t port)
allocate a new connection
Definition evhtp.c:5384
evhtp_type
@ evhtp_type_server
@ evhtp_type_client
void(* evhtp_hook_event_cb)(evhtp_connection_t *conn, short events, void *arg)
struct evhtp_callbacks evhtp_callbacks_t
Definition evhtp/evhtp.h:78
struct bufferevent evbev_t
Definition evhtp/evhtp.h:65
EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t *request, evhtp_res code)
start a chunked response.
Definition evhtp.c:3820
EVHTP_EXPORT evhtp_header_t * evhtp_header_new(const char *key, const char *val, char kalloc, char valloc)
creates a new evhtp_header_t key/val structure
Definition evhtp.c:3323
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.
Definition evhtp.c:5137
static void(* free_)(void *d)
Definition evhtp.c:168
static void *(* realloc_)(void *d, size_t sz)
Definition evhtp.c:167
static void *(* malloc_)(size_t sz)
Definition evhtp.c:166
TAILQ_ENTRY(evhtp_alias) next
structure which represents authority information in a URI
char * password
the password in URI (scheme://...:PASS.
uint16_t port
port if present in URI
char * hostname
hostname if present in URI
char * username
the username in URI (scheme://USER:.
structure containing a single callback and configuration
Definition evhtp.c:51
uint64_t num_requests
uint64_t max_body_size
struct sockaddr * saddr
struct timeval send_timeo
conn write timeouts (overrides global)
struct event * resume_ev
evhtp_ssl_t * ssl
struct timeval recv_timeo
conn read timeouts (overrides global)
evhtp_type type
server or client
evhtp_request_t * request
the request currently being processed
evutil_socket_t sock
htparser * parser
uint64_t body_bytes_read
evhtp_hooks_t * hooks
struct bufferevent * bev
struct event_base * evbase
struct evbuffer * scratch_buf
always zero'd out after used
void * post_accept_cbarg
evhtp_callback_cb cb
evhtp_post_accept_cb post_accept
evhtp_pre_accept_cb pre_accept
void * pre_accept_cbarg
void * on_new_chunk_arg
void * on_request_fini_arg
evhtp_hook_request_fini_cb on_request_fini
evhtp_hook_conn_err_cb on_connection_error
evhtp_hook_chunks_fini_cb on_chunks_fini
void * on_headers_arg
void * on_chunks_fini_arg
evhtp_hook_connection_fini_cb on_connection_fini
void * on_connection_fini_arg
evhtp_hook_headers_cb on_headers
evhtp_hook_write_cb on_write
void * on_hostname_arg
void * on_headers_start_arg
void * on_path_arg
evhtp_hook_path_cb on_path
void * on_write_arg
evhtp_hook_err_cb on_error
evhtp_hook_chunk_fini_cb on_chunk_fini
evhtp_hook_event_cb on_event
evhtp_hook_header_cb on_header
void * on_header_arg
void * on_chunk_fini_arg
evhtp_hook_chunk_new_cb on_new_chunk
void * on_read_arg
void * on_event_arg
evhtp_hook_headers_start_cb on_headers_start
void * on_error_arg
evhtp_hook_hostname_cb on_hostname
void * on_connection_error_arg
evhtp_hook_read_cb on_read
a generic key/value structure
char * key
TAILQ_ENTRY(evhtp_kv) next
char v_heaped
set to 1 if the val can be free()'d
char k_heaped
set to 1 if the key can be free()'d
char * val
size_t vlen
size_t klen
structure which represents a URI path and or file
char * file
the filename if present (c.html)
char * match_start
char * full
the full path+file (/a/b/c.html)
char * match_end
unsigned int matched_eoff
offset of where the uri ends mainly used for regex matching
unsigned int matched_soff
offset of where the uri starts mainly used for regex matching
char * path
the path (/a/b/)
a structure containing all information for a http request.
struct evbuffer * buffer_in
buffer containing data from client
void * cbarg
argument which is passed to the cb function
evhtp_callback_cb cb
the function to call when fully processed
evhtp_uri_t * uri
request URI information
htp_method method
HTTP method used.
TAILQ_ENTRY(evhtp_request) next
struct evbuffer * buffer_out
buffer containing data to client
evhtp_headers_t * headers_out
headers to client
evhtp_headers_t * headers_in
headers from client
evhtp_t * htp
the parent evhtp_t structure
evhtp_hooks_t * hooks
request specific hooks
uint16_t flags
evhtp_res status
The HTTP response code or other error conditions.
evhtp_connection_t * conn
the associated connection
evhtp_proto proto
HTTP protocol used.
evhtp_ssl_scache_get scache_get
evhtp_ssl_verify_cb x509_verify_cb
evhtp_ssl_decrypt_cb decrypt_cb
evhtp_ssl_scache_type scache_type
char * named_curve
evhtp_ssl_scache_del scache_del
evhtp_ssl_scache_add scache_add
evhtp_ssl_chk_issued_cb x509_chk_issued_cb
evhtp_ssl_scache_init scache_init
a generic container representing an entire URI strucutre
unsigned char * fragment
data after '#' in uri
evhtp_path_t * path
unsigned char * query_raw
the unparsed query arguments
htp_scheme scheme
set if a scheme is found
evhtp_authority_t * authority
evhtp_query_t * query
list of k/v for query arguments
main structure containing all configuration information
TAILQ_HEAD(, evhtp) vhosts
evhtp_thread_exit_cb thread_exit_cb
char * server_name
the name included in Host: responses
void * thread_cbarg
struct event_base * evbase
the initialized event_base
evthr_pool_t * thr_pool
connection threadpool
struct timeval send_timeo
uint16_t parser_flags
default query flags to alter 'strictness' (see EVHTP_PARSE_QUERY_FLAG_*)
evhtp_thread_init_cb thread_init_cb
int bev_flags
bufferevent flags to use on bufferevent_*_socket_new()
struct timeval recv_timeo
pthread_mutex_t * lock
parent lock for add/del cbs in threads
struct evconnlistener * server
the libevent listener struct
TAILQ_HEAD(, evhtp_alias) aliases
evhtp_ssl_cfg_t * ssl_cfg
void * arg
user-defined evhtp_t specific arguments
TAILQ_ENTRY(evhtp) next_vhost
evhtp_t * parent
only when this is a vhost
uint16_t flags
the base flags set for this context, see: EVHTP_FLAG_*
evhtp_ssl_ctx_t * ssl_ctx
if ssl enabled, this is the servers CTX
uint64_t max_keepalive_requests
uint64_t max_body_size
evhtp_callbacks_t * callbacks
evhtp_defaults_t defaults
evthr_cb cb
Definition thread.c:2