Libevhtp  1.2.10-dev
evhtp.h
Go to the documentation of this file.
1 #include <evhtp-config.h>
2 
3 #ifndef __EVHTP__H__
4 #define __EVHTP__H__
5 
7 #ifndef EVHTP_DISABLE_EVTHR
8 #include <evthr.h>
9 #endif
10 
11 #include <htparse.h>
12 
13 #ifndef EVHTP_DISABLE_REGEX
14 #include <onigposix.h>
15 #endif
16 
17 #include <sys/queue.h>
18 #include <event2/event.h>
19 #include <event2/listener.h>
20 #include <event2/buffer.h>
21 #include <event2/bufferevent.h>
22 
23 #ifndef EVHTP_DISABLE_SSL
24 #include <event2/bufferevent_ssl.h>
25 #include <openssl/ssl.h>
26 #include <openssl/err.h>
27 #include <openssl/rand.h>
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #ifdef EVHTP_DEBUG
35 #define __QUOTE(x) # x
36 #define _QUOTE(x) __QUOTE(x)
37 #define htp_debug_strlen(x) strlen(x)
38 
39 #define htp_log_debug(fmt, ...) do { \
40  time_t t = time(NULL); \
41  struct tm * dm = localtime(&t); \
42  \
43  fprintf(stdout, "[%02d:%02d:%02d] evhtp.c:[" _QUOTE(__LINE__) "]\t %-26s: " \
44  fmt "\n", dm->tm_hour, dm->tm_min, dm->tm_sec, __func__, ## __VA_ARGS__); \
45  fflush(stdout); \
46 } while (0)
47 
48 #else
49 #define htp_debug_strlen(x) 0
50 #define htp_log_debug(fmt, ...) do {} while (0)
51 #endif
52 
53 
54 #ifndef EVHTP_DISABLE_SSL
55 typedef SSL_SESSION evhtp_ssl_sess_t;
56 typedef SSL evhtp_ssl_t;
57 typedef SSL_CTX evhtp_ssl_ctx_t;
58 typedef X509 evhtp_x509_t;
59 typedef X509_STORE_CTX evhtp_x509_store_ctx_t;
60 #else
61 typedef void evhtp_ssl_sess_t;
62 typedef void evhtp_ssl_t;
63 typedef void evhtp_ssl_ctx_t;
64 typedef void evhtp_x509_t;
65 typedef void evhtp_x509_store_ctx_t;
66 #endif
67 
68 typedef struct evbuffer evbuf_t;
69 typedef struct event event_t;
70 typedef struct evconnlistener evserv_t;
71 typedef struct bufferevent evbev_t;
72 
73 #ifdef EVHTP_DISABLE_EVTHR
74 typedef struct event_base evbase_t;
75 typedef void evthr_t;
76 typedef void evthr_pool_t;
77 typedef void evhtp_mutex_t;
78 #else
79 typedef pthread_mutex_t evhtp_mutex_t;
80 #endif
81 
82 typedef struct evhtp_s evhtp_t;
83 typedef struct evhtp_defaults_s evhtp_defaults_t;
84 typedef struct evhtp_callbacks_s evhtp_callbacks_t;
85 typedef struct evhtp_callback_s evhtp_callback_t;
86 typedef struct evhtp_defaults_s evhtp_defaults_5;
87 typedef struct evhtp_kv_s evhtp_kv_t;
88 typedef struct evhtp_kvs_s evhtp_kvs_t;
89 typedef struct evhtp_uri_s evhtp_uri_t;
90 typedef struct evhtp_path_s evhtp_path_t;
91 typedef struct evhtp_authority_s evhtp_authority_t;
92 typedef struct evhtp_request_s evhtp_request_t;
93 typedef struct evhtp_hooks_s evhtp_hooks_t;
94 typedef struct evhtp_connection_s evhtp_connection_t;
95 typedef struct evhtp_ssl_cfg_s evhtp_ssl_cfg_t;
96 typedef struct evhtp_alias_s evhtp_alias_t;
97 typedef uint16_t evhtp_res;
98 typedef uint8_t evhtp_error_flags;
99 
100 
101 #define evhtp_header_s evhtp_kv_s
102 #define evhtp_headers_s evhtp_kvs_s
103 #define evhtp_query_s evhtp_kvs_s
104 
105 #define evhtp_header_t evhtp_kv_t
106 #define evhtp_headers_t evhtp_kvs_t
107 #define evhtp_query_t evhtp_kvs_t
108 
114 };
115 
136 };
137 
141 #ifndef EVHTP_DISABLE_REGEX
143 #endif
144 };
145 
150 };
151 
155 };
156 
161 typedef enum evhtp_type evhtp_type;
162 
163 typedef void (* evhtp_thread_init_cb)(evhtp_t * htp, evthr_t * thr, void * arg);
164 typedef void (* evhtp_callback_cb)(evhtp_request_t * req, void * arg);
165 typedef void (* evhtp_hook_err_cb)(evhtp_request_t * req, evhtp_error_flags errtype, void * arg);
166 typedef void (* evhtp_hook_event_cb)(evhtp_connection_t * conn, short events, void * arg);
167 
168 /* Generic hook for passing ISO tests */
169 typedef evhtp_res (* evhtp_hook)();
170 
171 typedef evhtp_res (* evhtp_hook_conn_err_cb)(evhtp_connection_t * connection, evhtp_error_flags errtype, void * arg);
172 typedef evhtp_res (* evhtp_pre_accept_cb)(evhtp_connection_t * conn, void * arg);
173 typedef evhtp_res (* evhtp_post_accept_cb)(evhtp_connection_t * conn, void * arg);
174 typedef evhtp_res (* evhtp_hook_header_cb)(evhtp_request_t * req, evhtp_header_t * hdr, void * arg);
175 typedef evhtp_res (* evhtp_hook_headers_cb)(evhtp_request_t * req, evhtp_headers_t * hdr, void * arg);
176 typedef evhtp_res (* evhtp_hook_path_cb)(evhtp_request_t * req, evhtp_path_t * path, void * arg);
177 typedef evhtp_res (* evhtp_hook_read_cb)(evhtp_request_t * req, evbuf_t * buf, void * arg);
178 typedef evhtp_res (* evhtp_hook_request_fini_cb)(evhtp_request_t * req, void * arg);
179 typedef evhtp_res (* evhtp_hook_connection_fini_cb)(evhtp_connection_t * connection, void * arg);
180 typedef evhtp_res (* evhtp_hook_chunk_new_cb)(evhtp_request_t * r, uint64_t len, void * arg);
181 typedef evhtp_res (* evhtp_hook_chunk_fini_cb)(evhtp_request_t * r, void * arg);
182 typedef evhtp_res (* evhtp_hook_chunks_fini_cb)(evhtp_request_t * r, void * arg);
183 typedef evhtp_res (* evhtp_hook_headers_start_cb)(evhtp_request_t * r, void * arg);
184 typedef evhtp_res (* evhtp_hook_hostname_cb)(evhtp_request_t * r, const char * hostname, void * arg);
185 typedef evhtp_res (* evhtp_hook_write_cb)(evhtp_connection_t * conn, void * arg);
186 
187 typedef int (* evhtp_kvs_iterator)(evhtp_kv_t * kv, void * arg);
188 typedef int (* evhtp_headers_iterator)(evhtp_header_t * header, void * arg);
189 
190 #ifndef EVHTP_DISABLE_SSL
191 typedef int (* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t * ctx);
192 typedef int (* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t * ctx, evhtp_x509_t * x, evhtp_x509_t * issuer);
193 
194 typedef int (* evhtp_ssl_scache_add)(evhtp_connection_t * connection, unsigned char * sid, int sid_len, evhtp_ssl_sess_t * sess);
195 typedef void (* evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid_len);
196 typedef evhtp_ssl_sess_t * (* evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
197 typedef void * (* evhtp_ssl_scache_init)(evhtp_t *);
198 #endif
199 
200 #define EVHTP_VERSION "1.2.11"
201 #define EVHTP_VERSION_MAJOR 1
202 #define EVHTP_VERSION_MINOR 2
203 #define EVHTP_VERSION_PATCH 11
204 
205 #define evhtp_headers_iterator evhtp_kvs_iterator
206 
207 #define EVHTP_RES_ERROR 0
208 #define EVHTP_RES_PAUSE 1
209 #define EVHTP_RES_FATAL 2
210 #define EVHTP_RES_USER 3
211 #define EVHTP_RES_DATA_TOO_LONG 4
212 #define EVHTP_RES_OK 200
213 
214 #ifndef DOXYGEN_SHOULD_SKIP_THIS
215 #define EVHTP_RES_100 100
216 #define EVHTP_RES_CONTINUE 100
217 #define EVHTP_RES_SWITCH_PROTO 101
218 #define EVHTP_RES_PROCESSING 102
219 #define EVHTP_RES_URI_TOOLONG 122
220 
221 #define EVHTP_RES_200 200
222 #define EVHTP_RES_CREATED 201
223 #define EVHTP_RES_ACCEPTED 202
224 #define EVHTP_RES_NAUTHINFO 203
225 #define EVHTP_RES_NOCONTENT 204
226 #define EVHTP_RES_RSTCONTENT 205
227 #define EVHTP_RES_PARTIAL 206
228 #define EVHTP_RES_MSTATUS 207
229 #define EVHTP_RES_IMUSED 226
230 
231 #define EVHTP_RES_300 300
232 #define EVHTP_RES_MCHOICE 300
233 #define EVHTP_RES_MOVEDPERM 301
234 #define EVHTP_RES_FOUND 302
235 #define EVHTP_RES_SEEOTHER 303
236 #define EVHTP_RES_NOTMOD 304
237 #define EVHTP_RES_USEPROXY 305
238 #define EVHTP_RES_SWITCHPROXY 306
239 #define EVHTP_RES_TMPREDIR 307
240 
241 #define EVHTP_RES_400 400
242 #define EVHTP_RES_BADREQ 400
243 #define EVHTP_RES_UNAUTH 401
244 #define EVHTP_RES_PAYREQ 402
245 #define EVHTP_RES_FORBIDDEN 403
246 #define EVHTP_RES_NOTFOUND 404
247 #define EVHTP_RES_METHNALLOWED 405
248 #define EVHTP_RES_NACCEPTABLE 406
249 #define EVHTP_RES_PROXYAUTHREQ 407
250 #define EVHTP_RES_TIMEOUT 408
251 #define EVHTP_RES_CONFLICT 409
252 #define EVHTP_RES_GONE 410
253 #define EVHTP_RES_LENREQ 411
254 #define EVHTP_RES_PRECONDFAIL 412
255 #define EVHTP_RES_ENTOOLARGE 413
256 #define EVHTP_RES_URITOOLARGE 414
257 #define EVHTP_RES_UNSUPPORTED 415
258 #define EVHTP_RES_RANGENOTSC 416
259 #define EVHTP_RES_EXPECTFAIL 417
260 #define EVHTP_RES_IAMATEAPOT 418
261 
262 #define EVHTP_RES_500 500
263 #define EVHTP_RES_SERVERR 500
264 #define EVHTP_RES_NOTIMPL 501
265 #define EVHTP_RES_BADGATEWAY 502
266 #define EVHTP_RES_SERVUNAVAIL 503
267 #define EVHTP_RES_GWTIMEOUT 504
268 #define EVHTP_RES_VERNSUPPORT 505
269 #define EVHTP_RES_BWEXEED 509
270 #endif
271 
276  void * cbarg;
279 };
280 
282  char * alias;
283 
284  TAILQ_ENTRY(evhtp_alias_s) next;
285 };
286 
290 struct evhtp_s {
291  evhtp_t * parent;
292  evbase_t * evbase;
294  char * server_name;
295  void * arg;
296  int bev_flags;
297  uint64_t max_body_size;
299  uint8_t disable_100_cont : 1,
300  enable_reuseport : 1,
301  enable_nodelay : 1,
302  enable_defer_accept : 1,
303  pad : 4;
304 
307 #ifndef EVHTP_DISABLE_SSL
308  evhtp_ssl_ctx_t * ssl_ctx;
309  evhtp_ssl_cfg_t * ssl_cfg;
310 #endif
311 
312 #ifndef EVHTP_DISABLE_EVTHR
313  evthr_pool_t * thr_pool;
314 #endif
315 
316 #ifndef EVHTP_DISABLE_EVTHR
317  pthread_mutex_t * lock;
320 #endif
322  evhtp_defaults_t defaults;
323 
324  struct timeval recv_timeo;
325  struct timeval send_timeo;
326 
327  TAILQ_HEAD(, evhtp_alias_s) aliases;
328  TAILQ_HEAD(, evhtp_s) vhosts;
329  TAILQ_ENTRY(evhtp_s) next_vhost;
330 };
331 
347  evhtp_callback_type type;
349  unsigned int hash;
350  void * cbarg;
351  evhtp_hooks_t * hooks;
353  union {
354  char * path;
355  char * glob;
356 #ifndef EVHTP_DISABLE_REGEX
357  regex_t * regex;
358 #endif
359  } val;
360 
361  TAILQ_ENTRY(evhtp_callback_s) next;
362 };
363 
364 TAILQ_HEAD(evhtp_callbacks_s, evhtp_callback_s);
365 
369 struct evhtp_kv_s {
370  char * key;
371  char * val;
372 
373  size_t klen;
374  size_t vlen;
375 
376  char k_heaped;
377  char v_heaped;
379  TAILQ_ENTRY(evhtp_kv_s) next;
380 };
381 
382 TAILQ_HEAD(evhtp_kvs_s, evhtp_kv_s);
383 
384 
385 
389 struct evhtp_uri_s {
390  evhtp_authority_t * authority;
391  evhtp_path_t * path;
392  unsigned char * fragment;
393  unsigned char * query_raw;
395  htp_scheme scheme;
396 };
397 
398 
403  char * username;
404  char * password;
405  char * hostname;
406  uint16_t port;
407 };
408 
409 
413 struct evhtp_path_s {
414  char * full;
415  char * path;
416  char * file;
417  char * match_start;
418  char * match_end;
419  unsigned int matched_soff;
422  unsigned int matched_eoff;
425 };
426 
427 
432  evhtp_t * htp;
433  evhtp_connection_t * conn;
434  evhtp_hooks_t * hooks;
435  evhtp_uri_t * uri;
440  evhtp_proto proto;
441  htp_method method;
442  evhtp_res status;
443  uint8_t keepalive : 1,
444  finished : 1,
445  chunked : 1,
446  error : 1,
447  pad : 4;
450  void * cbarg;
452  TAILQ_ENTRY(evhtp_request_s) next;
453 };
454 
455 #define evhtp_request_content_len(r) htparser_get_content_length(r->conn->parser)
456 
458  evhtp_t * htp;
459  evbase_t * evbase;
461 #ifndef EVHTP_DISABLE_EVTHR
462  evthr_t * thread;
463 #endif
464 #ifndef EVHTP_DISABLE_SSL
465  evhtp_ssl_t * ssl;
466 #endif
467  evhtp_hooks_t * hooks;
468  htparser * parser;
470  struct sockaddr * saddr;
471  struct timeval recv_timeo;
472  struct timeval send_timeo;
473  evutil_socket_t sock;
474  evhtp_request_t * request;
475  uint64_t max_body_size;
476  uint64_t body_bytes_read;
477  uint64_t num_requests;
478  evhtp_type type;
479  uint8_t error : 1,
480  owner : 1,
481  vhost_via_sni : 1,
482  paused : 1,
483  connected : 1,
484  waiting : 1,
485  free_connection : 1,
486  keepalive : 1;
487  struct evbuffer * scratch_buf;
489 #ifdef EVHTP_FUTURE_USE
490  TAILQ_HEAD(, evhtp_request_s) pending;
491 #endif
492 };
493 
510 
514  void * on_path_arg;
515  void * on_read_arg;
519  void * on_error_arg;
524  void * on_write_arg;
525  void * on_event_arg;
526 };
527 
528 #ifndef EVHTP_DISABLE_SSL
530  char * pemfile;
531  char * privfile;
532  char * cafile;
533  char * capath;
534  char * ciphers;
535  char * named_curve;
536  char * dhparams;
537  long ssl_opts;
544  evhtp_ssl_scache_type scache_type;
551  void * args;
552 };
553 #endif
554 
563 EVHTP_EXPORT evhtp_t * evhtp_new(evbase_t * evbase, void * arg);
564 EVHTP_EXPORT void evhtp_free(evhtp_t * evhtp);
565 
566 
576 EVHTP_EXPORT void evhtp_set_timeouts(evhtp_t * htp, const struct timeval * r, const struct timeval * w);
577 
578 
592 EVHTP_EXPORT void evhtp_set_parser_flags(evhtp_t * htp, int flags);
593 
600 EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t * htp, int flags);
601 
602 #ifndef EVHTP_DISABLE_SSL
603 EVHTP_EXPORT int evhtp_ssl_use_threads(void);
604 EVHTP_EXPORT int evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
605 #endif
606 
607 
614 EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t * htp);
615 
624 EVHTP_EXPORT int evhtp_use_callback_locks(evhtp_t * htp);
625 
633 EVHTP_EXPORT void evhtp_set_gencb(evhtp_t * htp, evhtp_callback_cb cb, void * arg);
634 
635 
645 EVHTP_EXPORT void evhtp_set_pre_accept_cb(evhtp_t * htp, evhtp_pre_accept_cb, void * arg);
646 
647 
657 EVHTP_EXPORT void evhtp_set_post_accept_cb(evhtp_t * htp, evhtp_post_accept_cb, void * arg);
658 
669 EVHTP_EXPORT evhtp_callback_t * evhtp_set_cb(evhtp_t * htp, const char * path,
670  evhtp_callback_cb cb, void * arg);
671 
672 
683 #ifndef EVHTP_DISABLE_REGEX
684 EVHTP_EXPORT evhtp_callback_t * evhtp_set_regex_cb(evhtp_t * htp, const char * pattern,
685  evhtp_callback_cb cb, void * arg);
686 #endif
687 
688 
689 
702 EVHTP_EXPORT evhtp_callback_t * evhtp_set_glob_cb(evhtp_t * htp, const char * pattern,
703  evhtp_callback_cb cb, void * arg);
704 
705 
731 EVHTP_EXPORT evhtp_callback_t * evhtp_get_cb(evhtp_t * htp, const char * needle);
732 
772 EVHTP_EXPORT int evhtp_set_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type,
773  evhtp_hook cb, void * arg);
774 
775 
784 EVHTP_EXPORT int evhtp_unset_hook(evhtp_hooks_t ** hooks, evhtp_hook_type type);
785 
786 
794 EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t ** hooks);
795 
811 EVHTP_EXPORT int evhtp_bind_socket(evhtp_t * htp, const char * addr, uint16_t port, int backlog);
812 
813 
819 EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t * htp);
820 
831 EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t * htp, struct sockaddr *,
832  size_t sin_len, int backlog);
833 
834 
848 EVHTP_EXPORT int evhtp_use_threads(evhtp_t * htp, evhtp_thread_init_cb init_cb, int nthreads, void * arg);
849 
850 
857 EVHTP_EXPORT void evhtp_send_reply(evhtp_request_t * request, evhtp_res code);
858 
859 
860 /* The following three functions allow for the user to do what evhtp_send_reply does at its core
861  * but for the weak of heart.
862  */
863 EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t * request, evhtp_res code);
864 EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t * request, evbuf_t * buf);
865 EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t * request);
866 
873 EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method);
874 
882 EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t * request, evhtp_res code);
883 
884 
891 EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t * request, evbuf_t * buf);
892 
899 EVHTP_EXPORT void evhtp_send_reply_chunk_end(evhtp_request_t * request);
900 
920 EVHTP_EXPORT evhtp_callback_t *
921 evhtp_callback_new(const char * path, evhtp_callback_type type, evhtp_callback_cb cb, void * arg);
922 
923 
929 EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t * callback);
930 
931 
940 EVHTP_EXPORT int evhtp_callbacks_add_callback(evhtp_callbacks_t * cbs, evhtp_callback_t * cb);
941 
942 
955 EVHTP_EXPORT int evhtp_add_vhost(evhtp_t * evhtp, const char * name, evhtp_t * vhost);
956 
957 
968 EVHTP_EXPORT int evhtp_add_alias(evhtp_t * evhtp, const char * name);
969 
980 EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char * key, const char * val, char kalloc, char valloc);
981 
982 
988 EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void);
989 
990 
996 EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t * kv);
997 
998 
1004 EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t * kvs);
1005 
1012 EVHTP_EXPORT void evhtp_kv_rm_and_free(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1013 
1022 EVHTP_EXPORT const char * evhtp_kv_find(evhtp_kvs_t * kvs, const char * key);
1023 
1024 
1033 EVHTP_EXPORT evhtp_kv_t * evhtp_kvs_find_kv(evhtp_kvs_t * kvs, const char * key);
1034 
1035 
1042 EVHTP_EXPORT void evhtp_kvs_add_kv(evhtp_kvs_t * kvs, evhtp_kv_t * kv);
1043 
1050 EVHTP_EXPORT void evhtp_kvs_add_kvs(evhtp_kvs_t * dst, evhtp_kvs_t * src);
1051 
1052 
1062 EVHTP_EXPORT int evhtp_kvs_for_each(evhtp_kvs_t * kvs, evhtp_kvs_iterator cb, void * arg);
1063 
1064 #define EVHTP_PARSE_QUERY_FLAG_STRICT 0
1065 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX (1 << 0)
1066 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS (1 << 1)
1067 #define EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS (1 << 2)
1068 #define EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP (1 << 3)
1069 #define EVHTP_PARSE_QUERY_FLAG_IGNORE_FRAGMENTS (1 << 4)
1070 #define EVHTP_PARSE_QUERY_FLAG_LENIENT \
1071  EVHTP_PARSE_QUERY_FLAG_IGNORE_HEX \
1072  | EVHTP_PARSE_QUERY_FLAG_ALLOW_EMPTY_VALS \
1073  | EVHTP_PARSE_QUERY_FLAG_ALLOW_NULL_VALS \
1074  | EVHTP_PARSE_QUERY_FLAG_TREAT_SEMICOLON_AS_SEP
1075 
1087 EVHTP_EXPORT evhtp_query_t * evhtp_parse_query_wflags(const char * query, size_t len, int flags);
1088 
1100 EVHTP_EXPORT evhtp_query_t * evhtp_parse_query(const char * query, size_t len);
1101 
1111 EVHTP_EXPORT int evhtp_unescape_string(unsigned char ** out, unsigned char * str, size_t str_len);
1112 
1123 EVHTP_EXPORT evhtp_header_t * evhtp_header_new(const char * key, const char * val,
1124  char kalloc, char valloc);
1125 
1136 EVHTP_EXPORT evhtp_header_t * evhtp_header_key_add(evhtp_headers_t * headers,
1137  const char * key, char kalloc);
1138 
1139 
1149 EVHTP_EXPORT evhtp_header_t * evhtp_header_val_add(evhtp_headers_t * headers,
1150  const char * val, char valloc);
1151 
1152 
1159 EVHTP_EXPORT void evhtp_headers_add_header(evhtp_headers_t * headers, evhtp_header_t * header);
1160 
1169 EVHTP_EXPORT const char * evhtp_header_find(evhtp_headers_t * headers, const char * key);
1170 
1171 #define evhtp_header_find evhtp_kv_find
1172 #define evhtp_headers_find_header evhtp_kvs_find_kv
1173 #define evhtp_headers_for_each evhtp_kvs_for_each
1174 #define evhtp_header_new evhtp_kv_new
1175 #define evhtp_header_free evhtp_kv_free
1176 #define evhtp_headers_new evhtp_kvs_new
1177 #define evhtp_headers_free evhtp_kvs_free
1178 #define evhtp_header_rm_and_free evhtp_kv_rm_and_free
1179 #define evhtp_headers_add_header evhtp_kvs_add_kv
1180 #define evhtp_headers_add_headers evhtp_kvs_add_kvs
1181 #define evhtp_query_new evhtp_kvs_new
1182 #define evhtp_query_free evhtp_kvs_free
1183 
1184 
1192 EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t * r);
1193 EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t * r);
1194 
1195 /* the following functions all do the same thing, pause and the processing */
1196 EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t * connection);
1197 EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t * connection);
1198 EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t * request);
1199 EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t * request);
1200 
1201 
1209 EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t * request);
1210 
1217 EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t * conn, evbev_t * bev);
1218 
1225 EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t * request, evbev_t * bev);
1226 
1227 
1235 EVHTP_EXPORT evbev_t * evhtp_connection_get_bev(evhtp_connection_t * conn);
1236 
1245 EVHTP_EXPORT void
1246 evhtp_connection_set_timeouts(evhtp_connection_t * conn,
1247  const struct timeval * r,
1248  const struct timeval * w);
1249 
1257 EVHTP_EXPORT evbev_t * evhtp_request_get_bev(evhtp_request_t * request);
1258 
1259 
1272 EVHTP_EXPORT evbev_t * evhtp_connection_take_ownership(evhtp_connection_t * connection);
1273 
1274 
1281 EVHTP_EXPORT void evhtp_connection_free(evhtp_connection_t * connection);
1282 EVHTP_EXPORT void evhtp_request_free(evhtp_request_t * request);
1283 
1291 EVHTP_EXPORT void evhtp_set_max_body_size(evhtp_t * htp, uint64_t len);
1292 
1300 EVHTP_EXPORT void evhtp_connection_set_max_body_size(evhtp_connection_t * conn, uint64_t len);
1301 
1308 EVHTP_EXPORT void evhtp_request_set_max_body_size(evhtp_request_t * request, uint64_t len);
1309 EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t * request, int val);
1310 
1317 EVHTP_EXPORT void evhtp_set_max_keepalive_requests(evhtp_t * htp, uint64_t num);
1318 
1319 
1320 /*****************************************************************
1321 * client request functions *
1322 *****************************************************************/
1323 
1327 EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(evbase_t * evbase,
1328  struct evdns_base * dns_base,
1329  const char * addr, uint16_t port);
1330 
1334 EVHTP_EXPORT evhtp_connection_t *
1335 evhtp_connection_new(evbase_t * evbase, const char * addr, uint16_t port);
1336 
1337 #ifndef EVHTP_DISABLE_SSL
1338 EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(evbase_t * evbase, const char * addr, uint16_t port, evhtp_ssl_ctx_t * ctx);
1339 #endif
1340 
1341 
1345 EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void * arg);
1346 
1350 EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t * c,
1351  evhtp_request_t * r, htp_method meth, const char * uri);
1352 
1353 EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *);
1354 
1355 #ifdef __cplusplus
1356 }
1357 #endif
1358 
1359 #endif /* __EVHTP__H__ */
EVHTP_EXPORT evhtp_proto evhtp_request_get_proto(evhtp_request_t *r)
void * post_accept_cbarg
Definition: evhtp.h:278
evhtp_hook_chunk_new_cb on_new_chunk
Definition: evhtp.h:504
uint16_t evhtp_res
Definition: evhtp.h:97
int(* evhtp_ssl_chk_issued_cb)(evhtp_x509_store_ctx_t *ctx, evhtp_x509_t *x, evhtp_x509_t *issuer)
Definition: evhtp.h:192
evhtp_query_t * query
list of k/v for query arguments
Definition: evhtp.h:394
EVHTP_EXPORT void evhtp_connection_resume(evhtp_connection_t *connection)
type which defines to hook whenever a connection error occurs
Definition: evhtp.h:135
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
evhtp_res(* evhtp_hook_request_fini_cb)(evhtp_request_t *req, void *arg)
Definition: evhtp.h:178
EVHTP_EXPORT void evhtp_send_reply_chunk_end(evhtp_request_t *request)
call when all chunks have been sent and you wish to send the last bits.
void * cbarg
argument which is passed to the cb function
Definition: evhtp.h:450
size_t klen
Definition: evhtp.h:373
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
event_t * resume_ev
Definition: evhtp.h:469
evhtp_uri_t * uri
request URI information
Definition: evhtp.h:435
void * pre_accept_cbarg
Definition: evhtp.h:277
int parser_flags
default query flags to alter &#39;strictness&#39; (see EVHTP_PARSE_QUERY_FLAG_*)
Definition: evhtp.h:305
uint64_t max_body_size
Definition: evhtp.h:297
EVHTP_EXPORT int evhtp_unset_all_hooks(evhtp_hooks_t **hooks)
removes all hooks.
EVHTP_EXPORT void evhtp_connection_set_timeouts(evhtp_connection_t *conn, const struct timeval *r, const struct timeval *w)
sets a connection-specific read/write timeout which overrides the global read/write settings...
htparser * parser
Definition: evhtp.h:468
struct evbuffer evbuf_t
Definition: evhtp.h:68
evhtp_hook_hostname_cb on_hostname
Definition: evhtp.h:507
evserv_t * server
the libevent listener struct
Definition: evhtp.h:293
type which defines to hook after all headers have been parsed
Definition: evhtp.h:122
evbev_t * bev
Definition: evhtp.h:460
evhtp_type type
server or client
Definition: evhtp.h:478
void *(* evhtp_ssl_scache_init)(evhtp_t *)
Definition: evhtp.h:197
evhtp_res(* evhtp_post_accept_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp.h:173
evhtp_path_t * path
Definition: evhtp.h:391
long scache_size
Definition: evhtp.h:546
unsigned char * query_raw
the unparsed query arguments
Definition: evhtp.h:393
void * on_headers_start_arg
Definition: evhtp.h:511
evhtp_connection_t * conn
the associated connection
Definition: evhtp.h:433
type which defines to hook whenever an error occurs
Definition: evhtp.h:131
EVHTP_EXPORT unsigned int evhtp_request_status(evhtp_request_t *)
char * hostname
hostname if present in URI
Definition: evhtp.h:405
EVHTP_EXPORT void evhtp_request_free(evhtp_request_t *request)
EVHTP_EXPORT evhtp_callback_t * evhtp_set_glob_cb(evhtp_t *htp, const char *pattern, evhtp_callback_cb cb, void *arg)
sets a callback to to be executed on simple glob/wildcard patterns this is useful if the app does not...
evhtp_ssl_scache_add scache_add
Definition: evhtp.h:548
htp_method method
HTTP method used.
Definition: evhtp.h:441
EVHTP_EXPORT evhtp_kv_t * evhtp_kv_new(const char *key, const char *val, char kalloc, char valloc)
Allocates a new key/value structure.
evhtp_hook_read_cb on_read
Definition: evhtp.h:499
void * cbarg
Definition: evhtp.h:276
EVHTP_EXPORT void evhtp_send_reply_chunk_start(evhtp_request_t *request, evhtp_res code)
start a chunked response.
EVHTP_EXPORT int evhtp_ssl_use_threads(void)
EVHTP_EXPORT int evhtp_use_callback_locks(evhtp_t *htp)
creates a lock around callbacks and hooks, allowing for threaded applications to add/remove/modify ho...
evhtp_res(* evhtp_hook_header_cb)(evhtp_request_t *req, evhtp_header_t *hdr, void *arg)
Definition: evhtp.h:174
evhtp_post_accept_cb post_accept
Definition: evhtp.h:275
evhtp_ssl_scache_del scache_del
Definition: evhtp.h:550
EVHTP_EXPORT evhtp_connection_t * evhtp_request_get_connection(evhtp_request_t *request)
returns the underlying evhtp_connection_t structure from a request
int verify_peer
Definition: evhtp.h:539
char * alias
Definition: evhtp.h:282
type which defines to hook once a path has been parsed
Definition: evhtp.h:123
void * on_connection_fini_arg
Definition: evhtp.h:517
EVHTP_EXPORT evbev_t * evhtp_connection_get_bev(evhtp_connection_t *conn)
returns the underlying connections bufferevent
char * key
Definition: evhtp.h:370
char * file
the filename if present (c.html)
Definition: evhtp.h:416
main structure containing all configuration information
Definition: evhtp.h:290
SSL evhtp_ssl_t
Definition: evhtp.h:56
char k_heaped
set to 1 if the key can be free()&#39;d
Definition: evhtp.h:376
evhtp_res(* evhtp_hook_chunk_fini_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp.h:181
evthr_t * thread
Definition: evhtp.h:462
evhtp_res(* evhtp_hook_headers_cb)(evhtp_request_t *req, evhtp_headers_t *hdr, void *arg)
Definition: evhtp.h:175
evhtp_hook_chunk_fini_cb on_chunk_fini
Definition: evhtp.h:505
EVHTP_EXPORT evhtp_query_t * evhtp_parse_query_wflags(const char *query, size_t len, int flags)
Parses the query portion of the uri into a set of key/values.
#define evhtp_headers_iterator
Definition: evhtp.h:205
char * cafile
Definition: evhtp.h:532
EVHTP_EXPORT void evhtp_unbind_socket(evhtp_t *htp)
stops the listening socket.
evhtp_res status
The HTTP response code or other error conditions.
Definition: evhtp.h:442
#define evhtp_headers_t
Definition: evhtp.h:106
EVHTP_EXPORT void evhtp_connection_set_bev(evhtp_connection_t *conn, evbev_t *bev)
Sets the connections underlying bufferevent.
EVHTP_EXPORT int evhtp_callbacks_add_callback(evhtp_callbacks_t *cbs, evhtp_callback_t *cb)
Adds a evhtp_callback_t to the evhtp_callbacks_t list.
type which defines to hook whenever the parser recieves data in a body
Definition: evhtp.h:124
EVHTP_EXPORT void evhtp_kvs_free(evhtp_kvs_t *kvs)
frees a the list of key/values, and all underlying entries
htp_scheme scheme
set if a scheme is found
Definition: evhtp.h:395
evhtp_hooks_t * hooks
per-callback hooks
Definition: evhtp.h:351
evhtp_ssl_scache_type scache_type
Definition: evhtp.h:544
struct evbuffer * scratch_buf
always zero&#39;d out after used
Definition: evhtp.h:487
pthread_mutex_t * lock
parent lock for add/del cbs in threads
Definition: evhtp.h:317
struct evhtp_callbacks_s evhtp_callbacks_t
Definition: evhtp.h:84
char * named_curve
Definition: evhtp.h:535
void(* evhtp_callback_cb)(evhtp_request_t *req, void *arg)
Definition: evhtp.h:164
long store_flags
Definition: evhtp.h:543
evhtp_hook_header_cb on_header
Definition: evhtp.h:496
unsigned int hash
the full hash generated integer
Definition: evhtp.h:349
long ssl_ctx_timeout
Definition: evhtp.h:538
SSL_SESSION evhtp_ssl_sess_t
Definition: evhtp.h:55
evhtp_hook_path_cb on_path
Definition: evhtp.h:498
SSL_CTX evhtp_ssl_ctx_t
Definition: evhtp.h:57
EVHTP_EXPORT int evhtp_bind_socket(evhtp_t *htp, const char *addr, uint16_t port, int backlog)
bind to a socket, optionally with specific protocol support formatting.
evbase_t * evbase
the initialized event_base
Definition: evhtp.h:292
char * username
the username in URI (scheme://USER:.
Definition: evhtp.h:403
void * on_event_arg
Definition: evhtp.h:525
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 ...
char * pemfile
Definition: evhtp.h:530
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;
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;
evhtp_headers_t * headers_in
headers from client
Definition: evhtp.h:438
#define evhtp_header_find
Definition: evhtp.h:1171
struct evhtp_kvs_s evhtp_kvs_t
Definition: evhtp.h:88
evhtp_ssl_scache_type
Definition: evhtp.h:109
evhtp_hook_err_cb on_error
Definition: evhtp.h:503
uint8_t evhtp_error_flags
Definition: evhtp.h:98
uint64_t max_body_size
Definition: evhtp.h:475
X509_STORE_CTX evhtp_x509_store_ctx_t
Definition: evhtp.h:59
EVHTP_EXPORT void evhtp_send_reply_end(evhtp_request_t *request)
EVHTP_EXPORT void evhtp_request_set_bev(evhtp_request_t *request, evbev_t *bev)
sets the underlying bufferevent for a evhtp_request
evhtp_t * parent
only when this is a vhost
Definition: evhtp.h:291
EVHTP_EXPORT evhtp_query_t * evhtp_parse_query(const char *query, size_t len)
Parses the query portion of the uri into a set of key/values in a strict manner.
evhtp_hooks_t * hooks
request specific hooks
Definition: evhtp.h:434
evhtp_callbacks_t * callbacks
Definition: evhtp.h:321
a generic key/value structure
Definition: evhtp.h:369
unsigned int matched_eoff
offset of where the uri ends mainly used for regex matching
Definition: evhtp.h:422
a structure containing all information for a http request.
Definition: evhtp.h:431
evhtp_t * htp
Definition: evhtp.h:458
evthr_pool_t * thr_pool
connection threadpool
Definition: evhtp.h:313
EVHTP_EXPORT void evhtp_set_parser_flags(evhtp_t *htp, int flags)
during the request processing cycle, these flags will be used to for query argument parsing...
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new_dns(evbase_t *evbase, struct evdns_base *dns_base, const char *addr, uint16_t port)
allocate a new connection
type which defines to hook before the request is free&#39;d
Definition: evhtp.h:125
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.
void * on_path_arg
Definition: evhtp.h:514
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
char * ciphers
Definition: evhtp.h:534
EVHTP_EXPORT evhtp_header_t * evhtp_header_val_add(evhtp_headers_t *headers, const char *val, char valloc)
finds the last header in the headers tailq and adds the value
evhtp_callback_cb cb
Definition: evhtp.h:273
evhtp_hook_type
types associated with where a developer can hook into during the request processing cycle...
Definition: evhtp.h:120
char * dhparams
Definition: evhtp.h:536
evhtp_res(* evhtp_hook_headers_start_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp.h:183
evhtp_callback_type type
the type of callback (regex|path)
Definition: evhtp.h:347
EVHTP_EXPORT evhtp_callback_t * evhtp_set_regex_cb(evhtp_t *htp, const char *pattern, evhtp_callback_cb cb, void *arg)
sets a callback to be executed based on a regex pattern
evhtp_hook_connection_fini_cb on_connection_fini
Definition: evhtp.h:501
void * on_chunks_fini_arg
Definition: evhtp.h:522
evhtp_res(* evhtp_hook_read_cb)(evhtp_request_t *req, evbuf_t *buf, void *arg)
Definition: evhtp.h:177
evhtp_hook_conn_err_cb on_connection_error
Definition: evhtp.h:502
EVHTP_EXPORT htp_method evhtp_request_get_method(evhtp_request_t *r)
returns the htp_method enum version of the request method.
void * on_new_chunk_arg
Definition: evhtp.h:520
structure containing a single callback and configuration
Definition: evhtp.h:346
EVHTP_EXPORT int evhtp_bind_sockaddr(evhtp_t *htp, struct sockaddr *, size_t sin_len, int backlog)
bind to an already allocated sockaddr.
evhtp_callback_cb cb
the function to call when fully processed
Definition: evhtp.h:449
evhtp_res(* evhtp_hook_conn_err_cb)(evhtp_connection_t *connection, evhtp_error_flags errtype, void *arg)
Definition: evhtp.h:171
evhtp_proto
Definition: evhtp.h:146
EVHTP_EXPORT int evhtp_use_threads(evhtp_t *htp, evhtp_thread_init_cb init_cb, int nthreads, void *arg)
Enable thread-pool support for an evhtp_t context.
evhtp_res(* evhtp_hook_path_cb)(evhtp_request_t *req, evhtp_path_t *path, void *arg)
Definition: evhtp.h:176
evhtp_ssl_t * ssl
Definition: evhtp.h:465
EVHTP_EXPORT int evhtp_response_needs_body(const evhtp_res code, const htp_method method)
Determine if a response should have a body.
EVHTP_EXPORT void evhtp_send_reply_start(evhtp_request_t *request, evhtp_res code)
EVHTP_EXPORT void evhtp_kvs_add_kv(evhtp_kvs_t *kvs, evhtp_kv_t *kv)
appends a key/val structure to a evhtp_kvs_t tailq
evhtp_hook_chunks_fini_cb on_chunks_fini
Definition: evhtp.h:506
EVHTP_EXPORT evbev_t * evhtp_connection_take_ownership(evhtp_connection_t *connection)
let a user take ownership of the underlying bufferevent and free all other underlying resources...
char * server_name
the name included in Host: responses
Definition: evhtp.h:294
EVHTP_EXPORT void evhtp_set_timeouts(evhtp_t *htp, const struct timeval *r, const struct timeval *w)
set a read/write timeout on all things evhtp_t.
evhtp_hook_write_cb on_write
Definition: evhtp.h:508
evbuf_t * buffer_in
buffer containing data from client
Definition: evhtp.h:436
evhtp_request_t * request
the request currently being processed
Definition: evhtp.h:474
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_new(evbase_t *evbase, const char *addr, uint16_t port)
allocate a new connection
EVHTP_EXPORT int evhtp_unset_hook(evhtp_hooks_t **hooks, evhtp_hook_type type)
remove a specific hook from being called.
evhtp_callback_type
Definition: evhtp.h:138
evhtp_res(* evhtp_hook_hostname_cb)(evhtp_request_t *r, const char *hostname, void *arg)
Definition: evhtp.h:184
evhtp_hooks_t * hooks
Definition: evhtp.h:467
evhtp_type
Definition: evhtp.h:152
evhtp_hook_headers_start_cb on_headers_start
Definition: evhtp.h:495
a generic container representing an entire URI strucutre
Definition: evhtp.h:389
struct evconnlistener evserv_t
Definition: evhtp.h:70
EVHTP_EXPORT void evhtp_kv_free(evhtp_kv_t *kv)
frees resources allocated for a single key/value
void * on_hostname_arg
Definition: evhtp.h:523
EVHTP_EXPORT void evhtp_request_set_max_body_size(evhtp_request_t *request, uint64_t len)
just calls evhtp_connection_set_max_body_size for the request.
char * path
the path (/a/b/)
Definition: evhtp.h:415
void * cbarg
user-defind arguments passed to the cb
Definition: evhtp.h:350
EVHTP_EXPORT void evhtp_callback_free(evhtp_callback_t *callback)
frees information associated with a ainflwx callback.
regex_t * regex
Definition: evhtp.h:357
char * match_start
Definition: evhtp.h:417
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;.
char v_heaped
set to 1 if the val can be free()&#39;d
Definition: evhtp.h:377
evhtp_callback_cb cb
the actual callback function
Definition: evhtp.h:348
EVHTP_EXPORT void evhtp_send_reply_chunk(evhtp_request_t *request, evbuf_t *buf)
send a chunk reply.
evhtp_pre_accept_cb pre_accept
Definition: evhtp.h:274
type which defines to hook after one header has been parsed
Definition: evhtp.h:121
EVHTP_EXPORT void evhtp_set_pre_accept_cb(evhtp_t *htp, evhtp_pre_accept_cb, void *arg)
call a user-defined function before the connection is accepted.
EVHTP_EXPORT void evhtp_set_max_keepalive_requests(evhtp_t *htp, uint64_t num)
sets a maximum number of requests that a single connection can make.
evhtp_res(* evhtp_hook)()
Definition: evhtp.h:169
pthread_mutex_t evhtp_mutex_t
Definition: evhtp.h:79
char * match_end
Definition: evhtp.h:418
evhtp_authority_t * authority
Definition: evhtp.h:390
char * full
the full path+file (/a/b/c.html)
Definition: evhtp.h:414
void * on_read_arg
Definition: evhtp.h:515
TAILQ_HEAD(evhtp_callbacks_s, evhtp_callback_s)
char * glob
Definition: evhtp.h:355
struct bufferevent evbev_t
Definition: evhtp.h:71
EVHTP_EXPORT void evhtp_connection_pause(evhtp_connection_t *connection)
void * on_chunk_fini_arg
Definition: evhtp.h:521
int(* evhtp_ssl_verify_cb)(int pre_verify, evhtp_x509_store_ctx_t *ctx)
Definition: evhtp.h:191
#define evhtp_header_new
Definition: evhtp.h:1174
#define evhtp_query_t
Definition: evhtp.h:107
void * arg
user-defined evhtp_t specific arguments
Definition: evhtp.h:295
EVHTP_EXPORT evhtp_header_t * evhtp_header_key_add(evhtp_headers_t *headers, const char *key, char kalloc)
creates a new evhtp_header_t, sets only the key, and adds to the evhtp_headers TAILQ ...
void(* evhtp_ssl_scache_del)(evhtp_t *htp, unsigned char *sid, int sid_len)
Definition: evhtp.h:195
long scache_timeout
Definition: evhtp.h:545
void * thread_init_cbarg
Definition: evhtp.h:319
EVHTP_EXPORT evhtp_t * evhtp_new(evbase_t *evbase, void *arg)
creates a new evhtp_t instance
EVHTP_EXPORT evhtp_request_t * evhtp_request_new(evhtp_callback_cb cb, void *arg)
allocate a new request
evhtp_proto proto
HTTP protocol used.
Definition: evhtp.h:440
void * args
Definition: evhtp.h:551
evhtp_res(* evhtp_pre_accept_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp.h:172
EVHTP_EXPORT evbev_t * evhtp_request_get_bev(evhtp_request_t *request)
returns the underlying requests bufferevent
char * privfile
Definition: evhtp.h:531
evhtp_ssl_cfg_t * ssl_cfg
Definition: evhtp.h:309
void * on_error_arg
Definition: evhtp.h:519
char * password
the password in URI (scheme://...:PASS.
Definition: evhtp.h:404
#define evhtp_header_t
Definition: evhtp.h:105
evhtp_res(* evhtp_hook_chunk_new_cb)(evhtp_request_t *r, uint64_t len, void *arg)
Definition: evhtp.h:180
EVHTP_EXPORT void evhtp_disable_100_continue(evhtp_t *htp)
when a client sends an Expect: 100-continue, if this is function is called, evhtp will not send a HTT...
EVHTP_EXPORT void evhtp_request_set_keepalive(evhtp_request_t *request, int val)
evhtp_res(* evhtp_hook_write_cb)(evhtp_connection_t *conn, void *arg)
Definition: evhtp.h:185
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;.
struct event event_t
Definition: evhtp.h:69
EVHTP_EXPORT void evhtp_send_reply(evhtp_request_t *request, evhtp_res code)
generates all the right information for a reply to be sent to the client
EVHTP_EXPORT int evhtp_add_vhost(evhtp_t *evhtp, const char *name, evhtp_t *vhost)
add an evhtp_t structure (with its own callbacks) to a base evhtp_t structure for virtual hosts...
evutil_socket_t sock
Definition: evhtp.h:473
X509 evhtp_x509_t
Definition: evhtp.h:58
evhtp_hook_request_fini_cb on_request_fini
Definition: evhtp.h:500
EVHTP_EXPORT void evhtp_set_bev_flags(evhtp_t *htp, int flags)
bufferevent flags which will be used for bev sockets.
EVHTP_EXPORT int evhtp_set_hook(evhtp_hooks_t **hooks, evhtp_hook_type type, evhtp_hook cb, void *arg)
sets a callback hook for either a connection or a path/regex .
char * path
Definition: evhtp.h:354
EVHTP_EXPORT void evhtp_send_reply_body(evhtp_request_t *request, evbuf_t *buf)
EVHTP_EXPORT evhtp_connection_t * evhtp_connection_ssl_new(evbase_t *evbase, const char *addr, uint16_t port, evhtp_ssl_ctx_t *ctx)
evhtp_ssl_ctx_t * ssl_ctx
if ssl enabled, this is the servers CTX
Definition: evhtp.h:308
char * val
Definition: evhtp.h:371
evhtp_t * htp
the parent evhtp_t structure
Definition: evhtp.h:432
evhtp_hook_headers_cb on_headers
Definition: evhtp.h:497
evhtp_ssl_scache_init scache_init
Definition: evhtp.h:547
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
uint64_t body_bytes_read
Definition: evhtp.h:476
evhtp_ssl_chk_issued_cb x509_chk_issued_cb
Definition: evhtp.h:542
EVHTP_EXPORT void evhtp_connection_set_max_body_size(evhtp_connection_t *conn, uint64_t len)
set a max body size for a specific connection, this will default to the size set by evhtp_set_max_bod...
evhtp_res(* evhtp_hook_connection_fini_cb)(evhtp_connection_t *connection, void *arg)
Definition: evhtp.h:179
EVHTP_EXPORT int evhtp_make_request(evhtp_connection_t *c, evhtp_request_t *r, htp_method meth, const char *uri)
make a client request
void * on_connection_error_arg
Definition: evhtp.h:518
void(* evhtp_hook_err_cb)(evhtp_request_t *req, evhtp_error_flags errtype, void *arg)
Definition: evhtp.h:165
EVHTP_EXPORT int evhtp_add_alias(evhtp_t *evhtp, const char *name)
Add an alias hostname for a virtual-host specific evhtp_t.
uint16_t port
port if present in URI
Definition: evhtp.h:406
EVHTP_EXPORT evhtp_kvs_t * evhtp_kvs_new(void)
creates an empty list of key/values
int bev_flags
bufferevent flags to use on bufferevent_*_socket_new()
Definition: evhtp.h:296
struct sockaddr * saddr
Definition: evhtp.h:470
EVHTP_EXPORT void evhtp_request_pause(evhtp_request_t *request)
char * capath
Definition: evhtp.h:533
unsigned int matched_soff
offset of where the uri starts mainly used for regex matching
Definition: evhtp.h:419
int verify_depth
Definition: evhtp.h:540
evhtp_ssl_sess_t *(* evhtp_ssl_scache_get)(evhtp_connection_t *connection, unsigned char *sid, int sid_len)
Definition: evhtp.h:196
evhtp_ssl_verify_cb x509_verify_cb
Definition: evhtp.h:541
EVHTP_EXPORT int evhtp_ssl_init(evhtp_t *htp, evhtp_ssl_cfg_t *ssl_cfg)
evhtp_defaults_t defaults
Definition: evhtp.h:322
size_t vlen
Definition: evhtp.h:374
evhtp_res(* evhtp_hook_chunks_fini_cb)(evhtp_request_t *r, void *arg)
Definition: evhtp.h:182
EVHTP_EXPORT void evhtp_set_post_accept_cb(evhtp_t *htp, evhtp_post_accept_cb, void *arg)
call a user-defined function right after a connection is accepted.
evhtp_hook_event_cb on_event
Definition: evhtp.h:509
void(* evhtp_hook_event_cb)(evhtp_connection_t *conn, short events, void *arg)
Definition: evhtp.h:166
long ssl_opts
Definition: evhtp.h:537
evbase_t * evbase
Definition: evhtp.h:459
evhtp_thread_init_cb thread_init_cb
Definition: evhtp.h:318
evhtp_ssl_scache_get scache_get
Definition: evhtp.h:549
unsigned char * fragment
data after &#39;#&#39; in uri
Definition: evhtp.h:392
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;
void * on_write_arg
Definition: evhtp.h:524
structure which represents a URI path and or file
Definition: evhtp.h:413
evbuf_t * buffer_out
buffer containing data to client
Definition: evhtp.h:437
int(* evhtp_kvs_iterator)(evhtp_kv_t *kv, void *arg)
Definition: evhtp.h:187
int(* evhtp_ssl_scache_add)(evhtp_connection_t *connection, unsigned char *sid, int sid_len, evhtp_ssl_sess_t *sess)
Definition: evhtp.h:194
void * on_header_arg
Definition: evhtp.h:512
uint64_t max_keepalive_requests
Definition: evhtp.h:298
EVHTP_EXPORT evhtp_callback_t * evhtp_callback_new(const char *path, evhtp_callback_type type, evhtp_callback_cb cb, void *arg)
creates a new evhtp_callback_t structure.
#define evhtp_headers_add_header
Definition: evhtp.h:1179
EVHTP_EXPORT void evhtp_request_resume(evhtp_request_t *request)
structure which represents authority information in a URI
Definition: evhtp.h:402
void(* evhtp_thread_init_cb)(evhtp_t *htp, evthr_t *thr, void *arg)
Definition: evhtp.h:163
evhtp_headers_t * headers_out
headers to client
Definition: evhtp.h:439
void * on_request_fini_arg
Definition: evhtp.h:516
void * on_headers_arg
Definition: evhtp.h:513
EVHTP_EXPORT void evhtp_free(evhtp_t *evhtp)
uint64_t num_requests
Definition: evhtp.h:477