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/ssl.h>
30 #include <openssl/err.h>
31 #include <openssl/rand.h>
32 #endif
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 struct evhtp_callback_s;
39 struct evhtp_callbacks_s;
40 
41 #ifndef EVHTP_DISABLE_SSL
42 typedef SSL_SESSION evhtp_ssl_sess_t;
43 typedef SSL evhtp_ssl_t;
44 typedef SSL_CTX evhtp_ssl_ctx_t;
45 typedef X509 evhtp_x509_t;
46 typedef X509_STORE_CTX evhtp_x509_store_ctx_t;
47 #if OPENSSL_VERSION_NUMBER < 0x10100000L
48 typedef unsigned char evhtp_ssl_data_t;
49 #else
50 typedef const unsigned char evhtp_ssl_data_t;
51 #endif
52 #else
53 typedef void evhtp_ssl_sess_t;
54 typedef void evhtp_ssl_t;
55 typedef void evhtp_ssl_ctx_t;
56 typedef void evhtp_x509_t;
57 typedef void evhtp_x509_store_ctx_t;
58 #endif
59 
60 typedef struct evbuffer evbuf_t;
61 typedef struct event event_t;
62 typedef struct evconnlistener evserv_t;
63 typedef struct bufferevent evbev_t;
64 
65 #ifdef EVHTP_DISABLE_EVTHR
66 typedef struct event_base evbase_t;
67 typedef void evthr_t;
68 typedef void evthr_pool_t;
69 typedef void evhtp_mutex_t;
70 #else
71 typedef pthread_mutex_t evhtp_mutex_t;
72 #endif
73 
74 typedef struct evhtp_s evhtp_t;
75 typedef struct evhtp_defaults_s evhtp_defaults_t;
76 typedef struct evhtp_callbacks_s evhtp_callbacks_t;
77 typedef struct evhtp_callback_s evhtp_callback_t;
78 typedef struct evhtp_defaults_s evhtp_defaults_5;
79 typedef struct evhtp_kv_s evhtp_kv_t;
80 typedef struct evhtp_kvs_s evhtp_kvs_t;
81 typedef struct evhtp_uri_s evhtp_uri_t;
82 typedef struct evhtp_path_s evhtp_path_t;
83 typedef struct evhtp_authority_s evhtp_authority_t;
84 typedef struct evhtp_request_s evhtp_request_t;
85 typedef struct evhtp_hooks_s evhtp_hooks_t;
86 typedef struct evhtp_connection_s evhtp_connection_t;
87 typedef struct evhtp_ssl_cfg_s evhtp_ssl_cfg_t;
88 typedef struct evhtp_alias_s evhtp_alias_t;
89 typedef uint16_t evhtp_res;
90 typedef uint8_t evhtp_error_flags;
91 
92 
93 #define evhtp_header_s evhtp_kv_s
94 #define evhtp_headers_s evhtp_kvs_s
95 #define evhtp_query_s evhtp_kvs_s
96 
97 #define evhtp_header_t evhtp_kv_t
98 #define evhtp_headers_t evhtp_kvs_t
99 #define evhtp_query_t evhtp_kvs_t
100 
106 };
107 
128 };
129 
133 #ifndef EVHTP_DISABLE_REGEX
135 #endif
136 };
137 
142 };
143 
147 };
148 
153 typedef enum evhtp_type evhtp_type;
154 
155 typedef void (* evhtp_thread_init_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
156 typedef void (* evhtp_thread_exit_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
157 typedef void (* evhtp_callback_cb)(evhtp_request_t * req, void * arg);
158 typedef void (* evhtp_hook_err_cb)(evhtp_request_t * req, evhtp_error_flags errtype, void * arg);
159 typedef void (* evhtp_hook_event_cb)(evhtp_connection_t * conn, short events, void * arg);
160 
161 /* Generic hook for passing ISO tests */
162 typedef evhtp_res (* evhtp_hook)();
163 
164 typedef evhtp_res (* evhtp_hook_conn_err_cb)(evhtp_connection_t * connection, evhtp_error_flags errtype, void * arg);
165 typedef evhtp_res (* evhtp_pre_accept_cb)(evhtp_connection_t * conn, void * arg);
166 typedef evhtp_res (* evhtp_post_accept_cb)(evhtp_connection_t * conn, void * arg);
167 typedef evhtp_res (* evhtp_hook_header_cb)(evhtp_request_t * req, evhtp_header_t * hdr, void * arg);
168 typedef evhtp_res (* evhtp_hook_headers_cb)(evhtp_request_t * req, evhtp_headers_t * hdr, void * arg);
169 typedef evhtp_res (* evhtp_hook_path_cb)(evhtp_request_t * req, evhtp_path_t * path, void * arg);
170 typedef evhtp_res (* evhtp_hook_read_cb)(evhtp_request_t * req, struct evbuffer * buf, void * arg);
171 typedef evhtp_res (* evhtp_hook_request_fini_cb)(evhtp_request_t * req, void * arg);
172 typedef evhtp_res (* evhtp_hook_connection_fini_cb)(evhtp_connection_t * connection, void * arg);
173 typedef evhtp_res (* evhtp_hook_chunk_new_cb)(evhtp_request_t * r, uint64_t len, void * arg);
174 typedef evhtp_res (* evhtp_hook_chunk_fini_cb)(evhtp_request_t * r, void * arg);
175 typedef evhtp_res (* evhtp_hook_chunks_fini_cb)(evhtp_request_t * r, void * arg);
176 typedef evhtp_res (* evhtp_hook_headers_start_cb)(evhtp_request_t * r, void * arg);
177 typedef evhtp_res (* evhtp_hook_hostname_cb)(evhtp_request_t * r, const char * hostname, void * arg);
178 typedef evhtp_res (* evhtp_hook_write_cb)(evhtp_connection_t * conn, void * arg);
179 
180 typedef int (* evhtp_kvs_iterator)(evhtp_kv_t * kv, void * arg);
181 typedef int (* evhtp_headers_iterator)(evhtp_header_t * header, void * arg);
182 
183 #ifndef EVHTP_DISABLE_SSL
184 typedef int (* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t * ctx);
185 typedef int (* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t * ctx, evhtp_x509_t * x, evhtp_x509_t * issuer);
186 typedef EVP_PKEY * (* evhtp_ssl_decrypt_cb)(char * privfile);
187 
188 typedef int (* evhtp_ssl_scache_add)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len, evhtp_ssl_sess_t * sess);
189 typedef void (* evhtp_ssl_scache_del)(evhtp_t * htp, evhtp_ssl_data_t * sid, int sid_len);
190 typedef evhtp_ssl_sess_t * (* evhtp_ssl_scache_get)(evhtp_connection_t * connection, evhtp_ssl_data_t * sid, int sid_len);
191 
192 typedef void * (* evhtp_ssl_scache_init)(evhtp_t *);
193 #endif
194 
195 #define EVHTP_VERSION "1.2.16"
196 #define EVHTP_VERSION_MAJOR 1
197 #define EVHTP_VERSION_MINOR 2
198 #define EVHTP_VERSION_PATCH 15
199 
200 #define evhtp_headers_iterator evhtp_kvs_iterator
201 
202 #define EVHTP_RES_ERROR 0
203 #define EVHTP_RES_PAUSE 1
204 #define EVHTP_RES_FATAL 2
205 #define EVHTP_RES_USER 3
206 #define EVHTP_RES_DATA_TOO_LONG 4
207 #define EVHTP_RES_OK 200
208 
209 #ifndef DOXYGEN_SHOULD_SKIP_THIS
210 #define EVHTP_RES_100 100
211 #define EVHTP_RES_CONTINUE 100
212 #define EVHTP_RES_SWITCH_PROTO 101
213 #define EVHTP_RES_PROCESSING 102
214 #define EVHTP_RES_URI_TOOLONG 122
215 
216 #define EVHTP_RES_200 200
217 #define EVHTP_RES_CREATED 201
218 #define EVHTP_RES_ACCEPTED 202
219 #define EVHTP_RES_NAUTHINFO 203
220 #define EVHTP_RES_NOCONTENT 204
221 #define EVHTP_RES_RSTCONTENT 205
222 #define EVHTP_RES_PARTIAL 206
223 #define EVHTP_RES_MSTATUS 207
224 #define EVHTP_RES_IMUSED 226
225 
226 #define EVHTP_RES_300 300
227 #define EVHTP_RES_MCHOICE 300
228 #define EVHTP_RES_MOVEDPERM 301
229 #define EVHTP_RES_FOUND 302
230 #define EVHTP_RES_SEEOTHER 303
231 #define EVHTP_RES_NOTMOD 304
232 #define EVHTP_RES_USEPROXY 305
233 #define EVHTP_RES_SWITCHPROXY 306
234 #define EVHTP_RES_TMPREDIR 307
235 
236 #define EVHTP_RES_400 400
237 #define EVHTP_RES_BADREQ 400
238 #define EVHTP_RES_UNAUTH 401
239 #define EVHTP_RES_PAYREQ 402
240 #define EVHTP_RES_FORBIDDEN 403
241 #define EVHTP_RES_NOTFOUND 404
242 #define EVHTP_RES_METHNALLOWED 405
243 #define EVHTP_RES_NACCEPTABLE 406
244 #define EVHTP_RES_PROXYAUTHREQ 407
245 #define EVHTP_RES_TIMEOUT 408
246 #define EVHTP_RES_CONFLICT 409
247 #define EVHTP_RES_GONE 410
248 #define EVHTP_RES_LENREQ 411
249 #define EVHTP_RES_PRECONDFAIL 412
250 #define EVHTP_RES_ENTOOLARGE 413
251 #define EVHTP_RES_URITOOLARGE 414
252 #define EVHTP_RES_UNSUPPORTED 415
253 #define EVHTP_RES_RANGENOTSC 416
254 #define EVHTP_RES_EXPECTFAIL 417
255 #define EVHTP_RES_IAMATEAPOT 418
256 
257 #define EVHTP_RES_500 500
258 #define EVHTP_RES_SERVERR 500
259 #define EVHTP_RES_NOTIMPL 501
260 #define EVHTP_RES_BADGATEWAY 502
261 #define EVHTP_RES_SERVUNAVAIL 503
262 #define EVHTP_RES_GWTIMEOUT 504
263 #define EVHTP_RES_VERNSUPPORT 505
264 #define EVHTP_RES_BWEXEED 509
265 #endif
266 
271  void * cbarg;
274 };
275 
277  char * alias;
278 
279  TAILQ_ENTRY(evhtp_alias_s) next;
280 };
281 
286 struct evhtp_s {
287  evhtp_t * parent;
288  struct event_base * evbase;
289  struct evconnlistener * server;
290  char * server_name;
291  void * arg;
292  int bev_flags;
293  uint64_t max_body_size;
295 
296  #define EVHTP_FLAG_ENABLE_100_CONT (1 << 1)
297  #define EVHTP_FLAG_ENABLE_REUSEPORT (1 << 2)
298  #define EVHTP_FLAG_ENABLE_NODELAY (1 << 3)
299  #define EVHTP_FLAG_ENABLE_DEFER_ACCEPT (1 << 4)
300  #define EVHTP_FLAG_DEFAULTS EVHTP_FLAG_ENABLE_100_CONT
301  #define EVHTP_FLAG_ENABLE_ALL EVHTP_FLAG_ENABLE_100_CONT \
302  | EVHTP_FLAG_ENABLE_REUSEPORT \
303  | EVHTP_FLAG_ENABLE_NODELAY \
304  | EVHTP_FLAG_ENABLE_DEFER_ACCEPT
305 
306  uint16_t flags;
307  uint16_t parser_flags;
309 #ifndef EVHTP_DISABLE_SSL
310  evhtp_ssl_ctx_t * ssl_ctx;
311  evhtp_ssl_cfg_t * ssl_cfg;
312 #endif
313 
314 #ifndef EVHTP_DISABLE_EVTHR
315  evthr_pool_t * thr_pool;
316  pthread_mutex_t * lock;
320 
321  /* keep backwards compat because I'm dumb and didn't
322  * make these structs private
323  */
324  #define thread_init_cbarg thread_cbarg
325  void * thread_cbarg;
326 #endif
328  evhtp_defaults_t defaults;
329 
330  struct timeval recv_timeo;
331  struct timeval send_timeo;
332 
333  TAILQ_HEAD(, evhtp_alias_s) aliases;
334  TAILQ_HEAD(, evhtp_s) vhosts;
335  TAILQ_ENTRY(evhtp_s) next_vhost;
336 };
337 
338 
342 struct evhtp_kv_s {
343  char * key;
344  char * val;
345 
346  size_t klen;
347  size_t vlen;
348 
349  char k_heaped;
350  char v_heaped;
352  TAILQ_ENTRY(evhtp_kv_s) next;
353 };
354 
355 TAILQ_HEAD(evhtp_kvs_s, evhtp_kv_s);
356 
357 
358 
362 struct evhtp_uri_s {
363  evhtp_authority_t * authority;
364  evhtp_path_t * path;
365  unsigned char * fragment;
366  unsigned char * query_raw;
368  htp_scheme scheme;
369 };
370 
371 
376  char * username;
377  char * password;
378  char * hostname;
379  uint16_t port;
380 };
381 
382 
386 struct evhtp_path_s {
387  char * full;
388  char * path;
389  char * file;
390  char * match_start;
391  char * match_end;
392  unsigned int matched_soff;
395  unsigned int matched_eoff;
398 };
399 
400 
405  evhtp_t * htp;
406  evhtp_connection_t * conn;
407  evhtp_hooks_t * hooks;
408  evhtp_uri_t * uri;
409  struct evbuffer * buffer_in;
410  struct evbuffer * buffer_out;
413  evhtp_proto proto;
414  htp_method method;
415  evhtp_res status;
416  #define EVHTP_REQ_FLAG_KEEPALIVE (1 << 1)
417  #define EVHTP_REQ_FLAG_FINISHED (1 << 2)
418  #define EVHTP_REQ_FLAG_CHUNKED (1 << 3)
419  #define EVHTP_REQ_FLAG_ERROR (1 << 4)
420  uint16_t flags;
421 
423  void * cbarg;
425  TAILQ_ENTRY(evhtp_request_s) next;
426 };
427 
428 #define evhtp_request_content_len(r) htparser_get_content_length(r->conn->parser)
429 
431  evhtp_t * htp;
432  struct event_base * evbase;
433  struct bufferevent * bev;
434 #ifndef EVHTP_DISABLE_EVTHR
435  evthr_t * thread;
436 #endif
437 #ifndef EVHTP_DISABLE_SSL
438  evhtp_ssl_t * ssl;
439 #endif
440  evhtp_hooks_t * hooks;
442  struct event * resume_ev;
443  struct sockaddr * saddr;
444  struct timeval recv_timeo;
445  struct timeval send_timeo;
446  evutil_socket_t sock;
447  evhtp_request_t * request;
448  uint64_t max_body_size;
449  uint64_t body_bytes_read;
450  uint64_t num_requests;
451  evhtp_type type;
452  #define EVHTP_CONN_FLAG_ERROR (1 << 1)
453  #define EVHTP_CONN_FLAG_OWNER (1 << 2)
454  #define EVHTP_CONN_FLAG_VHOST_VIA_SNI (1 << 3)
455  #define EVHTP_CONN_FLAG_PAUSED (1 << 4)
456  #define EVHTP_CONN_FLAG_CONNECTED (1 << 5)
457  #define EVHTP_CONN_FLAG_WAITING (1 << 6)
458  #define EVHTP_CONN_FLAG_FREE_CONN (1 << 7)
459  #define EVHTP_CONN_FLAG_KEEPALIVE (1 << 8)
460  uint16_t flags;
461 
462  struct evbuffer * scratch_buf;
464 #ifdef EVHTP_FUTURE_USE
465  TAILQ_HEAD(, evhtp_request_s) pending;
466 #endif
467 };
468 
485 
489  void * on_path_arg;
490  void * on_read_arg;
494  void * on_error_arg;
499  void * on_write_arg;
500  void * on_event_arg;
501 };
502 
503 #ifndef EVHTP_DISABLE_SSL
505  char * pemfile;
506  char * privfile;
507  char * cafile;
508  char * capath;
509  char * ciphers;
510  char * named_curve;
511  char * dhparams;
512  long ssl_opts;
520  evhtp_ssl_scache_type scache_type;
527  void * args;
528 };
529 #endif
530 
531 
532 EVHTP_EXPORT void evhtp_set_mem_functions(void *(*malloc_)(size_t),
533  void *(*realloc_)(void *, size_t),
534  void (* free_)(void *));
535 
549 EVHTP_EXPORT evhtp_t * evhtp_new(struct event_base * evbase, void * arg);
550 
551 EVHTP_EXPORT void evhtp_enable_flag(evhtp_t *, int);
552 EVHTP_EXPORT void evhtp_connection_enable_flag(evhtp_connection_t *, int);
553 EVHTP_EXPORT void evhtp_request_enable_flag(evhtp_request_t *, int);
554 EVHTP_EXPORT int evhtp_get_flags(evhtp_t *);
555 EVHTP_EXPORT int evhtp_connection_get_flags(evhtp_connection_t *);
556 EVHTP_EXPORT int evhtp_request_get_flags(evhtp_request_t *);
557 EVHTP_EXPORT void evhtp_disable_flag(evhtp_t *, int);
558 EVHTP_EXPORT void evhtp_connection_disable_flag(evhtp_connection_t *, int);
559 EVHTP_EXPORT void evhtp_request_disable_flag(evhtp_request_t *, int);
560 
568 EVHTP_EXPORT void evhtp_free(evhtp_t * evhtp);
569 
581 EVHTP_EXPORT void evhtp_set_timeouts(evhtp_t * htp, const struct timeval * r, const struct timeval * w);
582 
583 
584 
598 EVHTP_EXPORT void evhtp_set_parser_flags(evhtp_t * htp, int flags);
599 
606 EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t * htp, int flags);
607 
608 #ifndef EVHTP_DISABLE_SSL
609 EVHTP_EXPORT int evhtp_ssl_use_threads(void);
610 EVHTP_EXPORT int evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
611 #endif
612 
613 
620 EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t * htp)
621 DEPRECATED("evhtp_disable_100 will soon be deprecated, use htp->flags instead");
622 
631 EVHTP_EXPORT int evhtp_use_callback_locks(evhtp_t * htp);
632 
640 EVHTP_EXPORT void evhtp_set_gencb(evhtp_t * htp, evhtp_callback_cb cb, void * arg);
641 
642 
652 EVHTP_EXPORT void evhtp_set_pre_accept_cb(evhtp_t * htp, evhtp_pre_accept_cb, void * arg);
653 
654 
664 EVHTP_EXPORT void evhtp_set_post_accept_cb(evhtp_t * htp, evhtp_post_accept_cb, void * arg);
665 
676 EVHTP_EXPORT evhtp_callback_t * evhtp_set_cb(evhtp_t * htp, const char * path,
677  evhtp_callback_cb cb, void * arg);
678 
679 
690 #ifndef EVHTP_DISABLE_REGEX
691 EVHTP_EXPORT evhtp_callback_t * evhtp_set_regex_cb(evhtp_t * htp, const char * pattern,
692  evhtp_callback_cb cb, void * arg);
693 #endif
694 
695 
696 
709 EVHTP_EXPORT evhtp_callback_t * evhtp_set_glob_cb(evhtp_t * htp, const char * pattern,
710  evhtp_callback_cb cb, void * arg);
711 
712 
738 EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t * htp, const char * needle);
739 
779 EVHTP_EXPORT int evhtp_connection_set_hook(evhtp_connection_t * c, evhtp_hook_type type, evhtp_hook cb, void * arg);
780 EVHTP_EXPORT int evhtp_request_set_hook(evhtp_request_t * r, evhtp_hook_type type, evhtp_hook cb, void * arg);
781 EVHTP_EXPORT int evhtp_callback_set_hook(evhtp_callback_t * cb, evhtp_hook_type type, evhtp_hook hookcb, void * arg);
782 
783 EVHTP_EXPORT evhtp_hooks_t * evhtp_connection_get_hooks(evhtp_connection_t * c);
784 EVHTP_EXPORT evhtp_hooks_t * evhtp_request_get_hooks(evhtp_request_t * r);
785 EVHTP_EXPORT evhtp_hooks_t * evhtp_callback_get_hooks(evhtp_callback_t * cb);
786 
794 EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t ** hooks);
795 
796 EVHTP_EXPORT int evhtp_request_unset_hook(evhtp_request_t * req, evhtp_hook_type type);
797 EVHTP_EXPORT int evhtp_connection_unset_hook(evhtp_connection_t * conn, evhtp_hook_type type);
798 EVHTP_EXPORT int evhtp_callback_unset_hook(evhtp_callback_t * callback, evhtp_hook_type type);
799 
800 
816 EVHTP_EXPORT int evhtp_bind_socket(evhtp_t * htp, const char * addr, uint16_t port, int backlog);
817 
818 
824 EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t * htp);
825 
826 
840 EVHTP_EXPORT int evhtp_accept_socket(evhtp_t * htp, evutil_socket_t sock, int backlog);
841 
853 EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t * htp, struct sockaddr *,
854  size_t sin_len, int backlog);
855 
856 
871 EVHTP_EXPORT int evhtp_use_threads(evhtp_t *, evhtp_thread_init_cb, int nthreads, void *)
872 DEPRECATED("will take on the syntax of evhtp_use_threads_wexit");
873 
878 EVHTP_EXPORT int evhtp_use_threads_wexit(evhtp_t *,
881  int nthreads, void * arg);
882 
889 EVHTP_EXPORT void evhtp_send_reply(evhtp_request_t * request, evhtp_res code);
890 
891 
892 /* The following three functions allow for the user to do what evhtp_send_reply does at its core
893  * but for the weak of heart.
894  */
895 EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t * request, evhtp_res code);
896 EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t * request, struct evbuffer * buf);
897 EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t * request);
898 
905 EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method);
906 
914 EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t * request, evhtp_res code);
915 
916 
923 EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t * request, struct evbuffer * buf);
924 
931 EVHTP_EXPORT void evhtp_send_reply_chunk_end(evhtp_request_t * request);
932 
952 EVHTP_EXPORT evhtp_callback_t *
953 evhtp_callback_new(const char * path, evhtp_callback_type type, evhtp_callback_cb cb, void * arg);
954 
964 EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t * callback);
965 
966 
975 EVHTP_EXPORT int evhtp_callbacks_add_callback(evhtp_callbacks_t * cbs, evhtp_callback_t * cb);
976 
977 
990 EVHTP_EXPORT int evhtp_add_vhost(evhtp_t * evhtp, const char * name, evhtp_t * vhost);
991 
992 
1003 EVHTP_EXPORT int evhtp_add_alias(evhtp_t * evhtp, const char * name);
1004 
1005 
1017 EVHTP_EXPORT int evhtp_add_aliases(evhtp_t * evhtp, const char * name, ...);
1018 
1029 EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char * key, const char * val, char kalloc, char valloc);
1030 
1031 
1037 EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void);
1038 
1039 
1045 EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t * kv);
1046 
1047 
1053 EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t * kvs);
1054 
1061 EVHTP_EXPORT void evhtp_kv_rm_and_free(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1062 
1071 EVHTP_EXPORT const char * evhtp_kv_find(evhtp_kvs_t * kvs, const char * key);
1072 
1073 
1082 EVHTP_EXPORT evhtp_kv_t * evhtp_kvs_find_kv(evhtp_kvs_t * kvs, const char * key);
1083 
1084 
1091 EVHTP_EXPORT void evhtp_kvs_add_kv(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1092 
1099 EVHTP_EXPORT void evhtp_kvs_add_kvs(evhtp_kvs_t * dst, evhtp_kvs_t * src);
1100 
1101 
1111 EVHTP_EXPORT int evhtp_kvs_for_each(evhtp_kvs_t * kvs, evhtp_kvs_iterator cb, void * arg);
1112 
1113 #define EVHTP_PARSE_QUERY_FLAG_STRICT 0
1114 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX (1 << 0)
1115 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS (1 << 1)
1116 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS (1 << 2)
1117 #define EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP (1 << 3)
1118 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_FRAGMENTS (1 << 4)
1119 #define EVHTP_PARSE_QUERY_FLAG_LENIENT \
1120  EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX \
1121  | EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS \
1122  | EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS \
1123  | EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP
1124 
1125 #define EVHTP_PARSE_QUERY_FLAG_DEFAULT EVHTP_PARSE_QUERY_FLAG_LENIENT
1126 
1138 EVHTP_EXPORT evhtp_query_t * evhtp_parse_query_wflags(const char * query, size_t len, int flags);
1139 
1151 EVHTP_EXPORT evhtp_query_t * evhtp_parse_query(const char * query, size_t len);
1152 
1162 EVHTP_EXPORT int evhtp_unescape_string(unsigned char ** out, unsigned char * str, size_t str_len);
1163 
1174 EVHTP_EXPORT evhtp_header_t * evhtp_header_new(const char * key, const char * val,
1175  char kalloc, char valloc);
1176 
1187 EVHTP_EXPORT evhtp_header_t * evhtp_header_key_add(evhtp_headers_t * headers,
1188  const char * key, char kalloc);
1189 
1190 
1200 EVHTP_EXPORT evhtp_header_t * evhtp_header_val_add(evhtp_headers_t * headers,
1201  const char * val, char valloc);
1202 
1203 
1210 EVHTP_EXPORT void evhtp_headers_add_header(evhtp_headers_t * headers, evhtp_header_t * header);
1211 
1220 EVHTP_EXPORT const char * evhtp_header_find(evhtp_headers_t * headers, const char * key);
1221 
1222 #define evhtp_header_find evhtp_kv_find
1223 #define evhtp_headers_find_header evhtp_kvs_find_kv
1224 #define evhtp_headers_for_each evhtp_kvs_for_each
1225 #define evhtp_header_new evhtp_kv_new
1226 #define evhtp_header_free evhtp_kv_free
1227 #define evhtp_headers_new evhtp_kvs_new
1228 #define evhtp_headers_free evhtp_kvs_free
1229 #define evhtp_header_rm_and_free evhtp_kv_rm_and_free
1230 #define evhtp_headers_add_header evhtp_kvs_add_kv
1231 #define evhtp_headers_add_headers evhtp_kvs_add_kvs
1232 #define evhtp_query_new evhtp_kvs_new
1233 #define evhtp_query_free evhtp_kvs_free
1234 
1235 
1243 EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t * r);
1244 EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t * r);
1245 
1246 /* the following functions all do the same thing, pause and the processing */
1247 
1253 EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t * connection);
1254 
1260 EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t * connection);
1261 
1269 EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t * request);
1270 
1278 EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t * request);
1279 
1280 
1288 EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t * request);
1289 
1296 EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t * conn, struct bufferevent * bev);
1297 
1304 EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t * request, struct bufferevent * bev);
1305 
1306 
1314 EVHTP_EXPORT struct bufferevent * evhtp_connection_get_bev(evhtp_connection_t * conn);
1315 
1324 EVHTP_EXPORT void
1325 evhtp_connection_set_timeouts(evhtp_connection_t * conn,
1326  const struct timeval * r,
1327  const struct timeval * w);
1328 
1336 EVHTP_EXPORT struct bufferevent * evhtp_request_get_bev(evhtp_request_t * request);
1337 
1338 
1351 EVHTP_EXPORT struct bufferevent * evhtp_connection_take_ownership(evhtp_connection_t * connection);
1352 
1353 
1360 EVHTP_EXPORT void evhtp_connection_free(evhtp_connection_t * connection);
1361 EVHTP_EXPORT void evhtp_request_free(evhtp_request_t * request);
1362 
1370 EVHTP_EXPORT void evhtp_set_max_body_size(evhtp_t * htp, uint64_t len);
1371 
1379 EVHTP_EXPORT void evhtp_connection_set_max_body_size(evhtp_connection_t * conn, uint64_t len);
1380 
1387 EVHTP_EXPORT void evhtp_request_set_max_body_size(evhtp_request_t * request, uint64_t len);
1388 EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t * request, int val);
1389 
1396 EVHTP_EXPORT void evhtp_set_max_keepalive_requests(evhtp_t * htp, uint64_t num);
1397 
1398 
1399 /*****************************************************************
1400 * client request functions *
1401 *****************************************************************/
1402 
1406 EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(
1407  struct event_base * evbase,
1408  struct evdns_base * dns_base,
1409  const char * addr, uint16_t port);
1410 
1414 EVHTP_EXPORT evhtp_connection_t *
1415 evhtp_connection_new(struct event_base * evbase, const char * addr, uint16_t port);
1416 
1417 #ifndef EVHTP_DISABLE_SSL
1418 EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(
1419  struct event_base * evbase,
1420  const char * addr, uint16_t port, evhtp_ssl_ctx_t * ctx);
1421 #endif
1422 
1423 
1427 EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void * arg);
1428 
1432 EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t * c,
1433  evhtp_request_t * r, htp_method meth, const char * uri);
1434 
1435 EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *);
1436 
1437 #ifdef __cplusplus
1438 }
1439 #endif
1440 
1441 #endif /* __EVHTP__H__ */
EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t *conn, struct bufferevent *bev)
Sets the connections underlying bufferevent.
Definition: evhtp.c:5009
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:3081
void(* evhtp_thread_init_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
Definition: evhtp/evhtp.h:155
void * post_accept_cbarg
Definition: evhtp/evhtp.h:273
evhtp_res(* evhtp_hook_write_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp/evhtp.h:178
EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t *r)
Definition: evhtp.c:5036
evhtp_hook_chunk_new_cb on_new_chunk
Definition: evhtp/evhtp.h:479
uint16_t parser_flags
default query flags to alter &#39;strictness&#39; (see EVHTP_PARSE_QUERY_FLAG_*)
Definition: evhtp/evhtp.h:307
evhtp_query_t * query
list of k/v for query arguments
Definition: evhtp/evhtp.h:367
EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *)
Definition: evhtp.c:5597
EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t *kv)
frees resources allocated for a single key/value
Definition: evhtp.c:3206
evhtp_type
Definition: evhtp/evhtp.h:144
void * cbarg
argument which is passed to the cb function
Definition: evhtp/evhtp.h:423
size_t klen
Definition: evhtp/evhtp.h:346
type which defines to hook whenever an error occurs
Definition: evhtp/evhtp.h:123
evhtp_uri_t * uri
request URI information
Definition: evhtp/evhtp.h:408
void * pre_accept_cbarg
Definition: evhtp/evhtp.h:272
evhtp_res(* evhtp_hook_hostname_cb)(evhtp_request_t *r, const char *hostname, void *arg)
Definition: evhtp/evhtp.h:177
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:5145
uint64_t max_body_size
Definition: evhtp/evhtp.h:293
unsigned char evhtp_ssl_data_t
Definition: evhtp/evhtp.h:48
htparser * parser
Definition: evhtp/evhtp.h:441
evhtp_hook_hostname_cb on_hostname
Definition: evhtp/evhtp.h:482
EVHTP_EXPORT void evhtp_connection_enable_flag(evhtp_connection_t *, int)
#define evhtp_header_t
Definition: evhtp/evhtp.h:97
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:4637
evhtp_ssl_decrypt_cb decrypt_cb
Definition: evhtp/evhtp.h:518
evhtp_type type
server or client
Definition: evhtp/evhtp.h:451
struct evhtp_callbacks_s evhtp_callbacks_t
Definition: evhtp/evhtp.h:76
evhtp_path_t * path
Definition: evhtp/evhtp.h:364
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:4399
struct evconnlistener evserv_t
Definition: evhtp/evhtp.h:62
unsigned char * query_raw
the unparsed query arguments
Definition: evhtp/evhtp.h:366
void * on_headers_start_arg
Definition: evhtp/evhtp.h:486
EVHTP_EXPORT int evhtp_request_set_hook(evhtp_request_t *r, evhtp_hook_type type, evhtp_hook cb, void *arg)
Definition: evhtp.c:4393
evhtp_connection_t * conn
the associated connection
Definition: evhtp/evhtp.h:406
EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void *arg)
allocate a new request
Definition: evhtp.c:5547
SSL evhtp_ssl_t
Definition: evhtp/evhtp.h:43
EVHTP_EXPORT void evhtp_disable_flag(evhtp_t *, int)
char * hostname
hostname if present in URI
Definition: evhtp/evhtp.h:378
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:3030
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:4045
evhtp_ssl_scache_add scache_add
Definition: evhtp/evhtp.h:524
htp_method method
HTTP method used.
Definition: evhtp/evhtp.h:414
EVHTP_EXPORT evhtp_kv_t * evhtp_kvs_find_kv(evhtp_kvs_t *kvs, const char *key)
find the evhtp_kv_t reference &#39;key&#39; from the k/val list &#39;kvs&#39;
Definition: evhtp.c:3308
evhtp_hook_read_cb on_read
Definition: evhtp/evhtp.h:474
EVHTP_EXPORT int evhtp_request_get_flags(evhtp_request_t *)
EVHTP_EXPORT void use htp flags instead
Definition: evhtp/evhtp.h:621
EVHTP_EXPORT void evhtp_request_free(evhtp_request_t *request)
Definition: evhtp.c:5113
EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t *request, int val)
Definition: evhtp.c:5021
evhtp_post_accept_cb post_accept
Definition: evhtp/evhtp.h:270
evhtp_ssl_scache_del scache_del
Definition: evhtp/evhtp.h:526
type which defines to hook once a path has been parsed
Definition: evhtp/evhtp.h:115
void(* evhtp_ssl_scache_del)(evhtp_t *htp, evhtp_ssl_data_t *sid, int sid_len)
Definition: evhtp/evhtp.h:189
EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t *request)
Definition: evhtp.c:3784
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:4199
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:4618
void * on_connection_fini_arg
Definition: evhtp/evhtp.h:492
int(* evhtp_ssl_scache_add)(evhtp_connection_t *connection, evhtp_ssl_data_t *sid, int sid_len, evhtp_ssl_sess_t *sess)
Definition: evhtp/evhtp.h:188
char * key
Definition: evhtp/evhtp.h:343
X509 evhtp_x509_t
Definition: evhtp/evhtp.h:45
EVHTP_EXPORT int evhtp_callback_set_hook(evhtp_callback_t *cb, evhtp_hook_type type, evhtp_hook hookcb, void *arg)
Definition: evhtp.c:4387
char * file
the filename if present (c.html)
Definition: evhtp/evhtp.h:389
main structure containing all configuration information
Definition: evhtp/evhtp.h:286
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:3328
EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t *connection)
resumes a connection (enables reading) and activates resume event.
Definition: evhtp.c:3052
char k_heaped
set to 1 if the key can be free()&#39;d
Definition: evhtp/evhtp.h:349
struct event_base * evbase
the initialized event_base
Definition: evhtp/evhtp.h:288
evhtp_res(* evhtp_hook_conn_err_cb)(evhtp_connection_t *connection, evhtp_error_flags errtype, void *arg)
Definition: evhtp/evhtp.h:164
evhtp_hook_chunk_fini_cb on_chunk_fini
Definition: evhtp/evhtp.h:480
SSL_CTX evhtp_ssl_ctx_t
Definition: evhtp/evhtp.h:44
evhtp_res status
The HTTP response code or other error conditions.
Definition: evhtp/evhtp.h:415
void *(* evhtp_ssl_scache_init)(evhtp_t *)
Definition: evhtp/evhtp.h:192
struct evbuffer * buffer_in
buffer containing data from client
Definition: evhtp/evhtp.h:409
#define evhtp_query_t
Definition: evhtp/evhtp.h:99
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:4599
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:5015
htp_scheme scheme
set if a scheme is found
Definition: evhtp/evhtp.h:368
EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t *connection)
pauses a connection (disables reading)
Definition: evhtp.c:3040
evhtp_callback_type
Definition: evhtp/evhtp.h:130
pthread_mutex_t evhtp_mutex_t
Definition: evhtp/evhtp.h:71
evhtp_ssl_scache_type scache_type
Definition: evhtp/evhtp.h:520
struct evbuffer * scratch_buf
always zero&#39;d out after used
Definition: evhtp/evhtp.h:462
pthread_mutex_t * lock
parent lock for add/del cbs in threads
Definition: evhtp/evhtp.h:316
EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t *htp, const char *needle)
attempts to find the callback matching the exact string &#39;needle&#39;.
Definition: evhtp.c:4523
EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t *request)
Wrapper around evhtp_connection_resume.
Definition: evhtp.c:3073
struct bufferevent * bev
Definition: evhtp/evhtp.h:433
evhtp_hook_type
types associated with where a developer can hook into during the request processing cycle...
Definition: evhtp/evhtp.h:112
char * named_curve
Definition: evhtp/evhtp.h:510
evhtp_res(* evhtp_hook_path_cb)(evhtp_request_t *req, evhtp_path_t *path, void *arg)
Definition: evhtp/evhtp.h:169
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:5562
evhtp_hook_header_cb on_header
Definition: evhtp/evhtp.h:471
EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t **hooks)
removes all hooks.
Definition: evhtp.c:4405
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:4717
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:3482
static void(* free_)(void *d)
Definition: evhtp.c:166
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:5056
evhtp_res(* evhtp_hook_request_fini_cb)(evhtp_request_t *req, void *arg)
Definition: evhtp/evhtp.h:171
EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t *callback)
safely frees callback structure memory and internals
Definition: evhtp.c:4244
evhtp_hook_path_cb on_path
Definition: evhtp/evhtp.h:473
void * thread_cbarg
Definition: evhtp/evhtp.h:325
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:5391
char * username
the username in URI (scheme://USER:.
Definition: evhtp/evhtp.h:376
void * on_event_arg
Definition: evhtp/evhtp.h:500
X509_STORE_CTX evhtp_x509_store_ctx_t
Definition: evhtp/evhtp.h:46
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:4731
EVHTP_EXPORT int evhtp_connection_get_flags(evhtp_connection_t *)
EVHTP_EXPORT void evhtp_connection_free(evhtp_connection_t *connection)
free&#39;s all connection related resources, this will also call your request fini hook and request fini ...
Definition: evhtp.c:5073
type which defines to hook before the request is free&#39;d
Definition: evhtp/evhtp.h:117
evhtp_headers_t * headers_in
headers from client
Definition: evhtp/evhtp.h:411
uint16_t evhtp_res
Definition: evhtp/evhtp.h:89
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:3819
evhtp_hook_err_cb on_error
Definition: evhtp/evhtp.h:478
EVHTP_EXPORT int evhtp_unescape_string(unsigned char **out, unsigned char *str, size_t str_len)
Unescapes strings like &#39;%7B1,%202,%203%7D&#39; would become &#39;{1, 2, 3}&#39;.
Definition: evhtp.c:3403
EVHTP_EXPORT int evhtp_get_flags(evhtp_t *)
uint64_t max_body_size
Definition: evhtp/evhtp.h:448
evhtp_res(* evhtp_hook_chunk_fini_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp/evhtp.h:174
EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void)
creates an empty list of key/values
Definition: evhtp.c:3134
void(* evhtp_hook_err_cb)(evhtp_request_t *req, evhtp_error_flags errtype, void *arg)
Definition: evhtp/evhtp.h:158
evhtp_t * parent
only when this is a vhost
Definition: evhtp/evhtp.h:287
evhtp_res(* evhtp_hook_header_cb)(evhtp_request_t *req, evhtp_header_t *hdr, void *arg)
Definition: evhtp/evhtp.h:167
void(* evhtp_thread_exit_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
Definition: evhtp/evhtp.h:156
uint8_t evhtp_error_flags
Definition: evhtp/evhtp.h:90
evhtp_thread_exit_cb thread_exit_cb
Definition: evhtp/evhtp.h:319
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:4724
evhtp_hooks_t * hooks
request specific hooks
Definition: evhtp/evhtp.h:407
evhtp_callbacks_t * callbacks
Definition: evhtp/evhtp.h:327
evhtp_res(* evhtp_hook)()
Definition: evhtp/evhtp.h:162
a generic key/value structure
Definition: evhtp/evhtp.h:342
unsigned int matched_eoff
offset of where the uri ends mainly used for regex matching
Definition: evhtp/evhtp.h:395
EVHTP_EXPORT int evhtp_callback_unset_hook(evhtp_callback_t *callback, evhtp_hook_type type)
Definition: evhtp.c:4369
EVHTP_EXPORT int evhtp_request_unset_hook(evhtp_request_t *req, evhtp_hook_type type)
Definition: evhtp.c:4375
struct event_base * evbase
Definition: evhtp/evhtp.h:432
EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t *request, struct evbuffer *buf)
send a chunk reply.
Definition: evhtp.c:3900
evhtp_res(* evhtp_hook_headers_cb)(evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
Definition: evhtp/evhtp.h:168
a structure containing all information for a http request.
Definition: evhtp/evhtp.h:404
evthr_pool_t * thr_pool
connection threadpool
Definition: evhtp/evhtp.h:315
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...
void * on_path_arg
Definition: evhtp/evhtp.h:489
EVHTP_EXPORT struct bufferevent * evhtp_request_get_bev(evhtp_request_t *request)
returns the underlying requests bufferevent
Definition: evhtp.c:4999
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:4678
TAILQ_HEAD(evhtp_kvs_s, evhtp_kv_s)
evhtp_callback_cb cb
Definition: evhtp/evhtp.h:268
#define evhtp_headers_t
Definition: evhtp/evhtp.h:98
struct event * resume_ev
Definition: evhtp/evhtp.h:442
evhtp_hook_connection_fini_cb on_connection_fini
Definition: evhtp/evhtp.h:476
EVHTP_EXPORT void evhtp_request_enable_flag(evhtp_request_t *, int)
void * on_chunks_fini_arg
Definition: evhtp/evhtp.h:497
evhtp_hook_conn_err_cb on_connection_error
Definition: evhtp/evhtp.h:477
void * on_new_chunk_arg
Definition: evhtp/evhtp.h:495
int(* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t *ctx, evhtp_x509_t *x, evhtp_x509_t *issuer)
Definition: evhtp/evhtp.h:185
structure containing a single callback and configuration
Definition: evhtp.c:51
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:3096
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:5474
evhtp_callback_cb cb
the function to call when fully processed
Definition: evhtp/evhtp.h:422
int(* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t *ctx)
Definition: evhtp/evhtp.h:184
struct evconnlistener * server
the libevent listener struct
Definition: evhtp/evhtp.h:289
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:5119
evhtp_res(* evhtp_hook_connection_fini_cb)(evhtp_connection_t *connection, void *arg)
Definition: evhtp/evhtp.h:172
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:5042
evhtp_ssl_t * ssl
Definition: evhtp/evhtp.h:438
evhtp_hook_chunks_fini_cb on_chunks_fini
Definition: evhtp/evhtp.h:481
type which defines to hook after all headers have been parsed
Definition: evhtp/evhtp.h:114
char * server_name
the name included in Host: responses
Definition: evhtp/evhtp.h:290
evhtp_hook_write_cb on_write
Definition: evhtp/evhtp.h:483
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:4484
EVHTP_EXPORT evhtp_t * evhtp_new(struct event_base *evbase, void *arg)
creates a new evhtp_t instance
Definition: evhtp.c:5326
evhtp_request_t * request
the request currently being processed
Definition: evhtp/evhtp.h:447
struct evhtp_kvs_s evhtp_kvs_t
Definition: evhtp/evhtp.h:80
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:3790
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:3147
EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t *htp, int flags)
bufferevent flags which will be used for bev sockets.
Definition: evhtp.c:5139
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:5030
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:5397
EVHTP_EXPORT void evhtp_request_disable_flag(evhtp_request_t *, int)
evhtp_hooks_t * hooks
Definition: evhtp/evhtp.h:440
evhtp_hook_headers_start_cb on_headers_start
Definition: evhtp/evhtp.h:470
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:4606
a generic container representing an entire URI strucutre
Definition: evhtp/evhtp.h:362
void * on_hostname_arg
Definition: evhtp/evhtp.h:498
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:5133
char * path
the path (/a/b/)
Definition: evhtp/evhtp.h:388
EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t *htp)
stops the listening socket.
Definition: evhtp.c:3940
char * match_start
Definition: evhtp/evhtp.h:390
char v_heaped
set to 1 if the val can be free()&#39;d
Definition: evhtp/evhtp.h:350
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:4972
EVHTP_EXPORT void evhtp_set_mem_functions(void *(*malloc_)(size_t), void *(*realloc_)(void *, size_t), void(*free_)(void *))
evhtp_res(* evhtp_pre_accept_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp/evhtp.h:165
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:5067
evhtp_pre_accept_cb pre_accept
Definition: evhtp/evhtp.h:269
evhtp_proto
Definition: evhtp/evhtp.h:138
EVHTP_EXPORT int evhtp_ssl_init(evhtp_t *htp, evhtp_ssl_cfg_t *ssl_cfg)
Definition: evhtp.c:4772
int(* evhtp_kvs_iterator)(evhtp_kv_t *kv, void *arg)
Definition: evhtp/evhtp.h:180
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:3928
char * match_end
Definition: evhtp/evhtp.h:391
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:5236
evhtp_authority_t * authority
Definition: evhtp/evhtp.h:363
char * full
the full path+file (/a/b/c.html)
Definition: evhtp/evhtp.h:387
void * on_read_arg
Definition: evhtp/evhtp.h:490
EVHTP_EXPORT int evhtp_kvs_for_each(evhtp_kvs_t *kvs, evhtp_kvs_iterator cb, void *arg)
callback iterator which executes &#39;cb&#39; for every entry in &#39;kvs&#39;
Definition: evhtp.c:3266
EVHTP_EXPORT void evhtp_kv_rm_and_free(evhtp_kvs_t *kvs, evhtp_kv_t *kv)
free&#39;s resources associated with &#39;kv&#39; if ONLY found within the key/value list
Definition: evhtp.c:3227
EVHTP_EXPORT const char * evhtp_kv_find(evhtp_kvs_t *kvs, const char *key)
find the string value of &#39;key&#39; from the key/value list &#39;kvs&#39;
Definition: evhtp.c:3288
EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t *kvs)
frees a the list of key/values, and all underlying entries
Definition: evhtp.c:3240
type which defines to hook whenever the parser recieves data in a body
Definition: evhtp/evhtp.h:116
EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t *request)
Wrapper around evhtp_connection_pause.
Definition: evhtp.c:3064
type which defines to hook whenever a connection error occurs
Definition: evhtp/evhtp.h:127
void * on_chunk_fini_arg
Definition: evhtp/evhtp.h:496
evhtp_res(* evhtp_hook_headers_start_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp/evhtp.h:176
#define evhtp_header_find
Definition: evhtp/evhtp.h:1222
void * arg
user-defined evhtp_t specific arguments
Definition: evhtp/evhtp.h:291
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:5157
EVHTP_EXPORT void evhtp_connection_disable_flag(evhtp_connection_t *, int)
EVHTP_EXPORT evhtp_hooks_t * evhtp_connection_get_hooks(evhtp_connection_t *c)
Definition: evhtp.c:4444
SSL_SESSION evhtp_ssl_sess_t
Definition: evhtp/evhtp.h:39
evhtp_res(* evhtp_post_accept_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp/evhtp.h:166
evhtp_proto proto
HTTP protocol used.
Definition: evhtp/evhtp.h:413
EVHTP_EXPORT evhtp_hooks_t * evhtp_callback_get_hooks(evhtp_callback_t *cb)
returns callback hooks
Definition: evhtp.c:4478
evhtp_ssl_cfg_t * ssl_cfg
Definition: evhtp/evhtp.h:311
struct evbuffer * buffer_out
buffer containing data to client
Definition: evhtp/evhtp.h:410
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:4277
void * on_error_arg
Definition: evhtp/evhtp.h:494
char * password
the password in URI (scheme://...:PASS.
Definition: evhtp/evhtp.h:377
struct evbuffer evbuf_t
Definition: evhtp/evhtp.h:60
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:3748
EVHTP_EXPORT struct bufferevent * evhtp_connection_get_bev(evhtp_connection_t *conn)
returns the underlying connections bufferevent
Definition: evhtp.c:4967
#define evhtp_headers_add_header
Definition: evhtp/evhtp.h:1230
void(* evhtp_hook_event_cb)(evhtp_connection_t *conn, short events, void *arg)
Definition: evhtp/evhtp.h:159
uint16_t flags
the base flags set for this context, see: EVHTP_FLAG_*
Definition: evhtp/evhtp.h:306
EVHTP_EXPORT evhtp_hooks_t * evhtp_request_get_hooks(evhtp_request_t *r)
returns request hooks
Definition: evhtp.c:4461
evutil_socket_t sock
Definition: evhtp/evhtp.h:446
evhtp_hook_request_fini_cb on_request_fini
Definition: evhtp/evhtp.h:475
EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t *request, evhtp_res code)
Definition: evhtp.c:3755
evhtp_ssl_ctx_t * ssl_ctx
if ssl enabled, this is the servers CTX
Definition: evhtp/evhtp.h:310
char * val
Definition: evhtp/evhtp.h:344
evhtp_res(* evhtp_hook_read_cb)(evhtp_request_t *req, struct evbuffer *buf, void *arg)
Definition: evhtp/evhtp.h:170
struct bufferevent evbev_t
Definition: evhtp/evhtp.h:63
#define evhtp_header_new
Definition: evhtp/evhtp.h:1225
evhtp_t * htp
the parent evhtp_t structure
Definition: evhtp/evhtp.h:405
evhtp_hook_headers_cb on_headers
Definition: evhtp/evhtp.h:472
static void *(* malloc_)(size_t sz)
Definition: evhtp.c:164
evhtp_ssl_scache_init scache_init
Definition: evhtp/evhtp.h:523
uint64_t body_bytes_read
Definition: evhtp/evhtp.h:449
evhtp_ssl_chk_issued_cb x509_chk_issued_cb
Definition: evhtp/evhtp.h:517
void(* evhtp_callback_cb)(evhtp_request_t *req, void *arg)
Definition: evhtp/evhtp.h:157
void * on_connection_error_arg
Definition: evhtp/evhtp.h:493
uint16_t port
port if present in URI
Definition: evhtp/evhtp.h:379
EVP_PKEY *(* evhtp_ssl_decrypt_cb)(char *privfile)
Definition: evhtp/evhtp.h:186
int bev_flags
bufferevent flags to use on bufferevent_*_socket_new()
Definition: evhtp/evhtp.h:292
evhtp_res(* evhtp_hook_chunk_new_cb)(evhtp_request_t *r, uint64_t len, void *arg)
Definition: evhtp/evhtp.h:173
struct sockaddr * saddr
Definition: evhtp/evhtp.h:443
EVHTP_EXPORT int evhtp_ssl_use_threads(void)
Definition: evhtp.c:4740
unsigned int matched_soff
offset of where the uri starts mainly used for regex matching
Definition: evhtp/evhtp.h:392
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:5186
EVHTP_EXPORT int evhtp_connection_unset_hook(evhtp_connection_t *conn, evhtp_hook_type type)
Definition: evhtp.c:4381
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:3951
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:3339
evhtp_res(* evhtp_hook_chunks_fini_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp/evhtp.h:175
evhtp_ssl_verify_cb x509_verify_cb
Definition: evhtp/evhtp.h:516
evhtp_defaults_t defaults
Definition: evhtp/evhtp.h:328
size_t vlen
Definition: evhtp/evhtp.h:347
#define evhtp_headers_iterator
Definition: evhtp/evhtp.h:200
evhtp_ssl_sess_t *(* evhtp_ssl_scache_get)(evhtp_connection_t *connection, evhtp_ssl_data_t *sid, int sid_len)
Definition: evhtp/evhtp.h:190
evhtp_hook_event_cb on_event
Definition: evhtp/evhtp.h:484
uint16_t flags
Definition: evhtp/evhtp.h:420
evhtp_thread_init_cb thread_init_cb
Definition: evhtp/evhtp.h:318
evhtp_ssl_scache_get scache_get
Definition: evhtp/evhtp.h:525
static void *(* realloc_)(void *d, size_t sz)
Definition: evhtp.c:165
unsigned char * fragment
data after &#39;#&#39; in uri
Definition: evhtp/evhtp.h:365
type which defines to hook after one header has been parsed
Definition: evhtp/evhtp.h:113
void * on_write_arg
Definition: evhtp/evhtp.h:499
EVHTP_EXPORT int evhtp_add_aliases(evhtp_t *evhtp, const char *name,...)
set a variable number of aliases in one call evhtp_add_alias
Definition: evhtp.c:5211
structure which represents a URI path and or file
Definition: evhtp/evhtp.h:386
EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t *request, evhtp_res code)
start a chunked response.
Definition: evhtp.c:3828
void * on_header_arg
Definition: evhtp/evhtp.h:487
uint64_t max_keepalive_requests
Definition: evhtp/evhtp.h:294
EVHTP_EXPORT void evhtp_free(evhtp_t *evhtp)
Frees evhtp_t structure; will stop and free threads associated with the structure, and free the ssl context as well (if applicable).
Definition: evhtp.c:5339
struct event event_t
Definition: evhtp/evhtp.h:61
EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t *request, struct evbuffer *buf)
Definition: evhtp.c:3774
structure which represents authority information in a URI
Definition: evhtp/evhtp.h:375
EVHTP_EXPORT void evhtp_enable_flag(evhtp_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:4122
evhtp_ssl_scache_type
Definition: evhtp/evhtp.h:101
evhtp_headers_t * headers_out
headers to client
Definition: evhtp/evhtp.h:412
void * on_request_fini_arg
Definition: evhtp/evhtp.h:491
void * on_headers_arg
Definition: evhtp/evhtp.h:488
uint64_t num_requests
Definition: evhtp/evhtp.h:450