Libevhtp  1.2.13
evhtp.c File Reference

implementation file for libevhtp. More...

#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#include <signal.h>
#include <strings.h>
#include <inttypes.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/un.h>
#include <limits.h>
#include <event2/dns.h>
#include "internal.h"
#include "numtoa.h"
#include "evhtp/evhtp.h"
#include "log.h"
Include dependency graph for evhtp.c:

Go to the source code of this file.

Data Structures

struct  evhtp_callback_t
 structure containing a single callback and configuration More...
 

Macros

#define SET_BIT(VAR, FLAG)   VAR |= FLAG
 
#define UNSET_BIT(VAR, FLAG)   VAR &= ~FLAG
 
#define HTP_FLAG_ON(PRE, FLAG)   SET_BIT(PRE->flags, FLAG)
 
#define HTP_FLAG_OFF(PRE, FLAG)   UNSET_BIT(PRE->flags, FLAG)
 
#define HOOK_AVAIL(var, hook_name)   (var->hooks && var->hooks->hook_name)
 
#define HOOK_FUNC(var, hook_name)   (var->hooks->hook_name)
 
#define HOOK_ARGS(var, hook_name)   var->hooks->hook_name ## _arg
 
#define HOOK_REQUEST_RUN(request, hook_name, ...)
 
#define HOOK_REQUEST_RUN_NARGS(__request, hook_name)
 
#define htp__lock_(h)
 Helper macro to lock htp structure. More...
 
#define htp__unlock_(h)
 Helper macro to unlock htp lock. More...
 
#define rc_scratch   conn->scratch_buf
 
#define rc_parser   conn->parser
 
#define ch_fini_arg   hooks->on_connection_fini_arg
 
#define ch_fini   hooks->on_connection_fini
 
#define cr_status   request->status
 
#define rh_err   hooks->on_error
 
#define rh_err_arg   hooks->on_error_arg
 
#define htp__is_http_11_(_major, _minor)   (_major >= 1 && _minor >= 1)
 helper macro to determine if http version is HTTP/1.0 More...
 
#define htp__is_http_10_(_major, _minor)   (_major >= 1 && _minor <= 0)
 helper function to determine if http version is HTTP/1.1 More...
 
#define HTP_FLAG_FNGEN(NAME, TYPE)
 
#define ssl_sk_new_   bufferevent_openssl_socket_new
 
#define ssl_sk_connect_   bufferevent_socket_connect
 

Enumerations

enum  query_parser_state {
  s_query_start = 0, s_query_separator, s_query_key, s_query_val,
  s_query_key_hex_1, s_query_key_hex_2, s_query_val_hex_1, s_query_val_hex_2,
  s_query_done
}
 
enum  unscape_state { unscape_state_start = 0, unscape_state_hex1, unscape_state_hex2 }
 

Functions

 TAILQ_HEAD (evhtp_callbacks_s, evhtp_callback_s)
 
static void * htp__malloc_ (size_t size)
 Wrapper for malloc so that a different malloc can be used if desired. More...
 
static void * htp__realloc_ (void *ptr, size_t size)
 Wrapper for realloc so that a different realloc can be used if desired. More...
 
static void htp__free_ (void *ptr)
 Wrapper for free so that a different free can be used if desired. More...
 
static void * htp__calloc_ (size_t nmemb, size_t size)
 Wrapper for calloc so that a different calloc can be used if desired. More...
 
static char * htp__strdup_ (const char *str)
 implementation of strdup function. More...
 
static char * htp__strndup_ (const char *str, size_t len)
 implementation of strndup function. More...
 
void evhtp_set_mem_functions (void *(*mallocfn_)(size_t len), void *(*reallocfn_)(void *p, size_t sz), void(*freefn_)(void *p))
 
static const char * status_code_to_str (evhtp_res code)
 returns string status code from enum code More...
 
static evhtp_proto htp__protocol_ (const char major, const char minor)
 returns the HTTP protocol version More...
 
static evhtp_res htp__hook_path_ (evhtp_request_t *request, evhtp_path_t *path)
 runs the user-defined on_path hook for a request More...
 
static evhtp_res htp__hook_header_ (evhtp_request_t *request, evhtp_header_t *header)
 runs the user-defined on_header hook for a request More...
 
static evhtp_res htp__hook_headers_ (evhtp_request_t *request, evhtp_headers_t *headers)
 runs the user-defined on_Headers hook for a request after all headers have been parsed. More...
 
static evhtp_res htp__hook_body_ (evhtp_request_t *request, struct evbuffer *buf)
 runs the user-defined on_body hook for requests containing a body. More...
 
static evhtp_res htp__hook_request_fini_ (evhtp_request_t *request)
 runs the user-defined hook called just prior to a request been free()'d More...
 
static evhtp_res htp__hook_chunk_new_ (evhtp_request_t *request, uint64_t len)
 Runs the user defined request hook. More...
 
static evhtp_res htp__hook_chunk_fini_ (evhtp_request_t *request)
 Runs the user defined on_chunk_fini hook. More...
 
static evhtp_res htp__hook_chunks_fini_ (evhtp_request_t *request)
 Runs the user defined on chunk_finis hook. More...
 
static evhtp_res htp__hook_headers_start_ (evhtp_request_t *request)
 Runs the user defined on_headers_start hook. More...
 
static evhtp_res htp__hook_connection_fini_ (evhtp_connection_t *connection)
 runs the user-definedhook called just prior to a connection being closed More...
 
static void htp__hook_error_ (evhtp_request_t *request, evhtp_error_flags errtype)
 runs the user-defined hook when a connection error occurs More...
 
static evhtp_res htp__hook_connection_error_ (evhtp_connection_t *connection, evhtp_error_flags errtype)
 runs the user-defined hook when a connection error occurs More...
 
static evhtp_res htp__hook_hostname_ (evhtp_request_t *r, const char *hostname)
 Runs the user defined hostname processing hook. More...
 
static evhtp_res htp__hook_connection_write_ (evhtp_connection_t *connection)
 Runs the user defined on_write hook. More...
 
static int htp__glob_match_ (const char *pattern, size_t plen, const char *string, size_t str_len)
 glob/wildcard type pattern matching. More...
 
static evhtp_callback_t * htp__callback_find_ (evhtp_callbacks_t *cbs, const char *path, unsigned int *start_offset, unsigned int *end_offset)
 Locates a given callback offsets performs a regex pattern match. More...
 
static int htp__path_new_ (evhtp_path_t **out, const char *data, size_t len)
 parses the path and file from an input buffer More...
 
static void htp__path_free_ (evhtp_path_t *path)
 Correctly frees the evhtp_path_t ptr that is passed in. More...
 
static int htp__authority_new_ (evhtp_authority_t **out)
 create an authority structure More...
 
static void htp__authority_free_ (evhtp_authority_t *authority)
 frees an authority structure More...
 
static void htp__uri_free_ (evhtp_uri_t *uri)
 frees an overlay URI structure More...
 
static int htp__uri_new_ (evhtp_uri_t **out)
 create an overlay URI structure More...
 
static void htp__request_free_ (evhtp_request_t *request)
 frees all data in an evhtp_request_t along with calling finished hooks More...
 
static evhtp_request_t * htp__request_new_ (evhtp_connection_t *c)
 Creates a new evhtp_request_t. More...
 
static int htp__request_parse_start_ (htparser *p)
 Starts the parser for the connection associated with the parser struct. More...
 
static int htp__request_parse_args_ (htparser *p, const char *data, size_t len)
 parses http request arguments More...
 
static int htp__request_parse_headers_start_ (htparser *p)
 
static int htp__request_parse_header_key_ (htparser *p, const char *data, size_t len)
 
static int htp__request_parse_header_val_ (htparser *p, const char *data, size_t len)
 
static evhtp_t * htp__request_find_vhost_ (evhtp_t *evhtp, const char *name)
 
static int htp__request_set_callbacks_ (evhtp_request_t *request)
 
static int htp__request_parse_hostname_ (htparser *p, const char *data, size_t len)
 
static int htp__require_uri_ (evhtp_connection_t *c)
 
static int htp__request_parse_host_ (htparser *p, const char *data, size_t len)
 
static int htp__request_parse_port_ (htparser *p, const char *data, size_t len)
 
static int htp__request_parse_path_ (htparser *p, const char *data, size_t len)
 
static int htp__request_parse_headers_ (htparser *p)
 
static int htp__request_parse_body_ (htparser *p, const char *data, size_t len)
 
static int htp__request_parse_chunk_new_ (htparser *p)
 
static int htp__request_parse_chunk_fini_ (htparser *p)
 
static int htp__request_parse_chunks_fini_ (htparser *p)
 
static int htp__should_parse_query_body_ (evhtp_request_t *req)
 determines if the request body contains the query arguments. More...
 
static int htp__request_parse_fini_ (htparser *p)
 
static int htp__create_headers_ (evhtp_header_t *header, void *arg)
 
static struct evbuffer * htp__create_reply_ (evhtp_request_t *request, evhtp_res code)
 
static void htp__connection_readcb_ (struct bufferevent *bev, void *arg)
 
static void htp__connection_writecb_ (struct bufferevent *bev, void *arg)
 
static void htp__connection_eventcb_ (struct bufferevent *bev, short events, void *arg)
 
static void htp__connection_resumecb_ (int fd, short events, void *arg)
 
static int htp__run_pre_accept_ (evhtp_t *htp, evhtp_connection_t *conn)
 
static int htp__connection_accept_ (struct event_base *evbase, evhtp_connection_t *connection)
 
static void htp__default_request_cb_ (evhtp_request_t *request, void *arg)
 
static evhtp_connection_t * htp__connection_new_ (evhtp_t *htp, evutil_socket_t sock, evhtp_type type)
 
static int htp__run_post_accept_ (evhtp_t *htp, evhtp_connection_t *connection)
 
static void htp__run_in_thread_ (evthr_t *thr, void *arg, void *shared)
 
static void htp__accept_cb_ (struct evconnlistener *serv, int fd, struct sockaddr *s, int sl, void *arg)
 
static unsigned long htp__ssl_get_thread_id_ (void)
 
static void htp__ssl_thread_lock_ (int mode, int type, const char *file, int line)
 
static void htp__ssl_delete_scache_ent_ (evhtp_ssl_ctx_t *ctx, evhtp_ssl_sess_t *sess)
 
static int htp__ssl_add_scache_ent_ (evhtp_ssl_t *ssl, evhtp_ssl_sess_t *sess)
 
static evhtp_ssl_sess_thtp__ssl_get_scache_ent_ (evhtp_ssl_t *ssl, evhtp_ssl_data_t *sid, int sid_len, int *copy)
 
static int htp__ssl_servername_ (evhtp_ssl_t *ssl, int *unused, void *arg)
 
htp_method evhtp_request_get_method (evhtp_request_t *r)
 returns the htp_method enum version of the request method. More...
 
void evhtp_connection_pause (evhtp_connection_t *c)
 pauses a connection (disables reading) More...
 
void evhtp_connection_resume (evhtp_connection_t *c)
 resumes a connection (enables reading) and activates resume event. More...
 
void evhtp_request_pause (evhtp_request_t *request)
 Wrapper around evhtp_connection_pause. More...
 
void evhtp_request_resume (evhtp_request_t *request)
 Wrapper around evhtp_connection_resume. More...
 
evhtp_header_tevhtp_header_key_add (evhtp_headers_t *headers, const char *key, char key_alloc)
 creates a new evhtp_header_t, sets only the key, and adds to the evhtp_headers TAILQ More...
 
evhtp_header_tevhtp_header_val_add (evhtp_headers_t *headers, const char *val, char val_alloc)
 finds the last header in the headers tailq and adds the value More...
 
evhtp_kvs_tevhtp_kvs_new (void)
 creates an empty list of key/values More...
 
evhtp_kv_t * evhtp_kv_new (const char *key, const char *val, char key_alloc, char val_alloc)
 Allocates a new key/value structure. More...
 
void evhtp_kv_free (evhtp_kv_t *kv)
 frees resources allocated for a single key/value More...
 
void evhtp_kv_rm_and_free (evhtp_kvs_t *kvs, evhtp_kv_t *kv)
 free's resources associated with 'kv' if ONLY found within the key/value list More...
 
void evhtp_kvs_free (evhtp_kvs_t *kvs)
 frees a the list of key/values, and all underlying entries More...
 
int evhtp_kvs_for_each (evhtp_kvs_t *kvs, evhtp_kvs_iterator cb, void *arg)
 callback iterator which executes 'cb' for every entry in 'kvs' More...
 
const char * evhtp_kv_find (evhtp_kvs_t *kvs, const char *key)
 find the string value of 'key' from the key/value list 'kvs' More...
 
evhtp_kv_t * evhtp_kvs_find_kv (evhtp_kvs_t *kvs, const char *key)
 find the evhtp_kv_t reference 'key' from the k/val list 'kvs' More...
 
void evhtp_kvs_add_kv (evhtp_kvs_t *kvs, evhtp_kv_t *kv)
 appends a key/val structure to a evhtp_kvs_t tailq More...
 
void evhtp_kvs_add_kvs (evhtp_kvs_t *dst, evhtp_kvs_t *src)
 appends all key/val structures from src tailq onto dst tailq More...
 
static int evhtp_is_hex_query_char (unsigned char ch)
 
int evhtp_unescape_string (unsigned char **out, unsigned char *str, size_t str_len)
 Unescapes strings like '%7B1,%202,%203%7D' would become '{1, 2, 3}'. More...
 
evhtp_query_tevhtp_parse_query_wflags (const char *query, const size_t len, const int flags)
 Parses the query portion of the uri into a set of key/values. More...
 
evhtp_query_tevhtp_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. More...
 
void evhtp_send_reply_start (evhtp_request_t *request, evhtp_res code)
 
void evhtp_send_reply_body (evhtp_request_t *request, struct evbuffer *buf)
 
void evhtp_send_reply_end (evhtp_request_t *request)
 
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 More...
 
int evhtp_response_needs_body (const evhtp_res code, const htp_method method)
 Determine if a response should have a body. More...
 
void evhtp_send_reply_chunk_start (evhtp_request_t *request, evhtp_res code)
 start a chunked response. More...
 
void evhtp_send_reply_chunk (evhtp_request_t *request, struct evbuffer *buf)
 send a chunk reply. More...
 
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. More...
 
void evhtp_unbind_socket (evhtp_t *htp)
 stops the listening socket. More...
 
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. More...
 
int evhtp_bind_sockaddr (evhtp_t *htp, struct sockaddr *sa, size_t sin_len, int backlog)
 bind to an already allocated sockaddr. More...
 
int evhtp_bind_socket (evhtp_t *htp, const char *baddr, uint16_t port, int backlog)
 bind to a socket, optionally with specific protocol support formatting. More...
 
void evhtp_callbacks_free (evhtp_callbacks_t *callbacks)
 
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. More...
 
void evhtp_callback_free (evhtp_callback_t *callback)
 safely frees callback structure memory and internals More...
 
int evhtp_callbacks_add_callback (evhtp_callbacks_t *cbs, evhtp_callback_t *cb)
 Adds a evhtp_callback_t to the evhtp_callbacks_t list. More...
 
static int htp__set_hook_ (evhtp_hooks_t **hooks, evhtp_hook_type type, evhtp_hook cb, void *arg)
 
static int htp__unset_hook_ (evhtp_hooks_t **hooks, evhtp_hook_type type)
 
int evhtp_callback_unset_hook (evhtp_callback_t *callback, evhtp_hook_type type)
 
int evhtp_request_unset_hook (evhtp_request_t *req, evhtp_hook_type type)
 
int evhtp_connection_unset_hook (evhtp_connection_t *conn, evhtp_hook_type type)
 
int evhtp_callback_set_hook (evhtp_callback_t *callback, evhtp_hook_type type, evhtp_hook cb, void *arg)
 
int evhtp_request_set_hook (evhtp_request_t *req, evhtp_hook_type type, evhtp_hook cb, void *arg)
 
int evhtp_connection_set_hook (evhtp_connection_t *conn, evhtp_hook_type type, evhtp_hook cb, void *arg)
 sets a callback hook for either a connection or a path/regex . More...
 
int evhtp_unset_all_hooks (evhtp_hooks_t **hooks)
 removes all hooks. More...
 
evhtp_hooks_t * evhtp_connection_get_hooks (evhtp_connection_t *c)
 
evhtp_hooks_t * evhtp_request_get_hooks (evhtp_request_t *r)
 returns request hooks More...
 
evhtp_hooks_t * evhtp_callback_get_hooks (evhtp_callback_t *cb)
 returns callback hooks More...
 
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 More...
 
evhtp_callback_t * evhtp_get_cb (evhtp_t *htp, const char *path)
 attempts to find the callback matching the exact string 'needle'. More...
 
static void htp__thread_init_ (evthr_t *thr, void *arg)
 
static void htp__thread_exit_ (evthr_t *thr, void *arg)
 
static int htp__use_threads_ (evhtp_t *htp, evhtp_thread_init_cb init_cb, evhtp_thread_exit_cb exit_cb, int nthreads, void *arg)
 
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. More...
 
int evhtp_use_threads_wexit (evhtp_t *htp, evhtp_thread_init_cb init_cb, evhtp_thread_exit_cb exit_cb, int nthreads, void *arg)
 Temporary function which will be renamed evhtp_use_threads in the future. More...
 
int evhtp_use_callback_locks (evhtp_t *htp)
 creates a lock around callbacks and hooks, allowing for threaded applications to add/remove/modify hooks & callbacks in a thread-safe manner. More...
 
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 More...
 
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 care about what was matched, but just that it matched. More...
 
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 More...
 
void evhtp_set_pre_accept_cb (evhtp_t *htp, evhtp_pre_accept_cb cb, void *arg)
 call a user-defined function before the connection is accepted. More...
 
void evhtp_set_post_accept_cb (evhtp_t *htp, evhtp_post_accept_cb cb, void *arg)
 call a user-defined function right after a connection is accepted. More...
 
int evhtp_ssl_use_threads (void)
 
int evhtp_ssl_init (evhtp_t *htp, evhtp_ssl_cfg_t *cfg)
 
struct bufferevent * evhtp_connection_get_bev (evhtp_connection_t *connection)
 returns the underlying connections bufferevent More...
 
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. More...
 
struct bufferevent * evhtp_request_get_bev (evhtp_request_t *request)
 returns the underlying requests bufferevent More...
 
struct bufferevent * evhtp_request_take_ownership (evhtp_request_t *request)
 
void evhtp_connection_set_bev (evhtp_connection_t *conn, struct bufferevent *bev)
 Sets the connections underlying bufferevent. More...
 
void evhtp_request_set_bev (evhtp_request_t *request, struct bufferevent *bev)
 sets the underlying bufferevent for a evhtp_request More...
 
void evhtp_request_set_keepalive (evhtp_request_t *request, int val)
 
evhtp_connection_t * evhtp_request_get_connection (evhtp_request_t *request)
 returns the underlying evhtp_connection_t structure from a request More...
 
evhtp_proto evhtp_request_get_proto (evhtp_request_t *request)
 
void evhtp_connection_set_timeouts (evhtp_connection_t *c, const struct timeval *rtimeo, const struct timeval *wtimeo)
 sets a connection-specific read/write timeout which overrides the global read/write settings. More...
 
void evhtp_connection_set_max_body_size (evhtp_connection_t *c, uint64_t len)
 set a max body size for a specific connection, this will default to the size set by evhtp_set_max_body_size More...
 
void evhtp_request_set_max_body_size (evhtp_request_t *req, uint64_t len)
 just calls evhtp_connection_set_max_body_size for the request. More...
 
void evhtp_connection_free (evhtp_connection_t *connection)
 free's all connection related resources, this will also call your request fini hook and request fini hook. More...
 
void evhtp_request_free (evhtp_request_t *request)
 
void evhtp_set_timeouts (evhtp_t *htp, const struct timeval *r_timeo, const struct timeval *w_timeo)
 set a read/write timeout on all things evhtp_t. More...
 
void evhtp_set_max_keepalive_requests (evhtp_t *htp, uint64_t num)
 sets a maximum number of requests that a single connection can make. More...
 
void evhtp_set_bev_flags (evhtp_t *htp, int flags)
 bufferevent flags which will be used for bev sockets. More...
 
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. More...
 
void evhtp_disable_100_continue (evhtp_t *htp)
 
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. More...
 
 HTP_FLAG_FNGEN (, evhtp_t *)
 
 HTP_FLAG_FNGEN (_connection, evhtp_connection_t *)
 
 HTP_FLAG_FNGEN (_request, evhtp_request_t *)
 
int evhtp_add_alias (evhtp_t *evhtp, const char *name)
 Add an alias hostname for a virtual-host specific evhtp_t. More...
 
int evhtp_add_aliases (evhtp_t *htp, const char *name,...)
 set a variable number of aliases in one call evhtp_add_alias More...
 
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. More...
 
static int evhtp__new_ (evhtp_t **out, struct event_base *evbase, void *arg)
 Allocates new evhtp_t structure. More...
 
evhtp_t * evhtp_new (struct event_base *evbase, void *arg)
 creates a new evhtp_t instance More...
 
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). More...
 
evhtp_connection_t * evhtp_connection_new (struct event_base *evbase, const char *addr, uint16_t port)
 allocate a new connection More...
 
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 More...
 
evhtp_connection_t * evhtp_connection_ssl_new (struct event_base *evbase, const char *addr, uint16_t port, evhtp_ssl_ctx_t *ctx)
 
evhtp_request_t * evhtp_request_new (evhtp_callback_cb cb, void *arg)
 allocate a new request More...
 
int evhtp_make_request (evhtp_connection_t *c, evhtp_request_t *r, htp_method meth, const char *uri)
 make a client request More...
 
unsigned int evhtp_request_status (evhtp_request_t *r)
 

Variables

static void *(* malloc_ )(size_t sz) = malloc
 
static void *(* realloc_ )(void *d, size_t sz) = realloc
 
static void(* free_ )(void *d) = free
 
static int session_id_context = 1
 
static int ssl_num_locks
 
static evhtp_mutex_tssl_locks
 
static int ssl_locks_initialized = 0
 
static htparse_hooks request_psets
 callback definitions for request processing from libhtparse More...
 

Detailed Description

implementation file for libevhtp.

Definition in file evhtp.c.

Macro Definition Documentation

◆ ch_fini

#define ch_fini   hooks->on_connection_fini

Definition at line 153 of file evhtp.c.

◆ ch_fini_arg

#define ch_fini_arg   hooks->on_connection_fini_arg

Definition at line 152 of file evhtp.c.

◆ cr_status

#define cr_status   request->status

Definition at line 156 of file evhtp.c.

◆ HOOK_ARGS

#define HOOK_ARGS (   var,
  hook_name 
)    var->hooks->hook_name ## _arg

Definition at line 79 of file evhtp.c.

◆ HOOK_AVAIL

#define HOOK_AVAIL (   var,
  hook_name 
)    (var->hooks && var->hooks->hook_name)

Definition at line 77 of file evhtp.c.

◆ HOOK_FUNC

#define HOOK_FUNC (   var,
  hook_name 
)    (var->hooks->hook_name)

Definition at line 78 of file evhtp.c.

◆ HOOK_REQUEST_RUN

#define HOOK_REQUEST_RUN (   request,
  hook_name,
  ... 
)
Value:
do { \
if (HOOK_AVAIL(request, hook_name)) \
{ \
return HOOK_FUNC(request, hook_name) (request, __VA_ARGS__, \
HOOK_ARGS(request, hook_name)); \
} \
\
if (request->conn && HOOK_AVAIL(request->conn, hook_name)) \
{ \
return HOOK_FUNC(request->conn, hook_name) (request, __VA_ARGS__, \
HOOK_ARGS(request->conn, hook_name)); \
} \
} while (0)
#define HOOK_AVAIL(var, hook_name)
Definition: evhtp.c:77
#define HOOK_FUNC(var, hook_name)
Definition: evhtp.c:78

Definition at line 81 of file evhtp.c.

◆ HOOK_REQUEST_RUN_NARGS

#define HOOK_REQUEST_RUN_NARGS (   __request,
  hook_name 
)
Value:
do { \
if (HOOK_AVAIL(__request, hook_name)) \
{ \
return HOOK_FUNC(__request, hook_name) (__request, \
HOOK_ARGS(__request, hook_name)); \
} \
\
if (__request->conn && HOOK_AVAIL(__request->conn, hook_name)) \
{ \
return HOOK_FUNC(__request->conn, hook_name) (request, \
HOOK_ARGS(__request->conn, hook_name)); \
} \
} while (0);
#define HOOK_AVAIL(var, hook_name)
Definition: evhtp.c:77
#define HOOK_FUNC(var, hook_name)
Definition: evhtp.c:78

Definition at line 95 of file evhtp.c.

◆ htp__is_http_10_

#define htp__is_http_10_ (   _major,
  _minor 
)    (_major >= 1 && _minor <= 0)

helper function to determine if http version is HTTP/1.1

Parameters
majorthe major version number
minorthe minor version number
Returns
1 if HTTP/1.1, else 0

Definition at line 544 of file evhtp.c.

◆ htp__is_http_11_

#define htp__is_http_11_ (   _major,
  _minor 
)    (_major >= 1 && _minor >= 1)

helper macro to determine if http version is HTTP/1.0

Parameters
majorthe major version number
minorthe minor version number
Returns
1 if HTTP/1.0, else 0

Definition at line 532 of file evhtp.c.

◆ htp__lock_

#define htp__lock_ (   h)
Value:
do { \
if (h->lock) \
{ \
pthread_mutex_lock(h->lock); \
} \
} while (0)

Helper macro to lock htp structure.

Parameters
hhtp structure

Definition at line 115 of file evhtp.c.

◆ htp__unlock_

#define htp__unlock_ (   h)
Value:
do { \
if (h->lock) \
{ \
pthread_mutex_unlock(h->lock); \
} \
} while (0)

Helper macro to unlock htp lock.

Parameters
hhtp structure

Definition at line 127 of file evhtp.c.

◆ HTP_FLAG_FNGEN

#define HTP_FLAG_FNGEN (   NAME,
  TYPE 
)
Value:
void \
evhtp ## NAME ## _enable_flag(TYPE v, int flag) { \
HTP_FLAG_ON(v, flag); \
} \
\
void \
evhtp ## NAME ## _disable_flag(TYPE v, int flag) { \
HTP_FLAG_OFF(v, flag); \
} \
\
int \
evhtp ## NAME ## _get_flags(TYPE v) { \
if (v) \
{ \
return v->flags; \
} \
return -1; \
}

Definition at line 5162 of file evhtp.c.

◆ HTP_FLAG_OFF

#define HTP_FLAG_OFF (   PRE,
  FLAG 
)    UNSET_BIT(PRE->flags, FLAG)

Definition at line 75 of file evhtp.c.

◆ HTP_FLAG_ON

#define HTP_FLAG_ON (   PRE,
  FLAG 
)    SET_BIT(PRE->flags, FLAG)

Definition at line 74 of file evhtp.c.

◆ rc_parser

#define rc_parser   conn->parser

Definition at line 149 of file evhtp.c.

◆ rc_scratch

#define rc_scratch   conn->scratch_buf

Definition at line 148 of file evhtp.c.

◆ rh_err

#define rh_err   hooks->on_error

Definition at line 159 of file evhtp.c.

◆ rh_err_arg

#define rh_err_arg   hooks->on_error_arg

Definition at line 160 of file evhtp.c.

◆ SET_BIT

#define SET_BIT (   VAR,
  FLAG 
)    VAR |= FLAG

Definition at line 71 of file evhtp.c.

◆ ssl_sk_connect_

#define ssl_sk_connect_   bufferevent_socket_connect

Definition at line 5471 of file evhtp.c.

◆ ssl_sk_new_

#define ssl_sk_new_   bufferevent_openssl_socket_new

Definition at line 5470 of file evhtp.c.

◆ UNSET_BIT

#define UNSET_BIT (   VAR,
  FLAG 
)    VAR &= ~FLAG

Definition at line 72 of file evhtp.c.

Enumeration Type Documentation

◆ query_parser_state

Enumerator
s_query_start 
s_query_separator 
s_query_key 
s_query_val 
s_query_key_hex_1 
s_query_key_hex_2 
s_query_val_hex_1 
s_query_val_hex_2 
s_query_done 

Definition at line 3356 of file evhtp.c.

◆ unscape_state

Enumerator
unscape_state_start 
unscape_state_hex1 
unscape_state_hex2 

Definition at line 3396 of file evhtp.c.

Function Documentation

◆ evhtp__new_()

static int evhtp__new_ ( evhtp_t **  out,
struct event_base *  evbase,
void *  arg 
)
static

Allocates new evhtp_t structure.

Parameters
[OUT]out - double ptr to evhtp_t structure.
[IN]evbase - event_base structure
[IN]arg - anonymous argument
Returns
0 on success, -1 on failure

Definition at line 5284 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_accept_socket()

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.

Note
Since the file descriptor is passed to the function, it will not attempt to close it if an error occurs.
Parameters
htp
sock
backlog
Returns
0 on success, -1 on error (check errno)

Definition at line 3951 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_add_alias()

int evhtp_add_alias ( evhtp_t *  evhtp,
const char *  name 
)

Add an alias hostname for a virtual-host specific evhtp_t.

This avoids having multiple evhtp_t virtual hosts with the same callback for the same vhost.

Parameters
evhtp
name
Returns

Definition at line 5186 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_add_aliases()

int evhtp_add_aliases ( evhtp_t *  evhtp,
const char *  name,
  ... 
)

set a variable number of aliases in one call evhtp_add_alias

Note
last argument must be NULL terminated
Parameters
evhtp
name
...
Returns
0 on success, -1 on error

Definition at line 5211 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_add_vhost()

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.

It should be noted that if you enable SSL on the base evhtp_t and your version of OpenSSL supports SNI, the SNI hostname will always take precedence over the Host header value.

Parameters
evhtp
name
vhost
Returns

Definition at line 5236 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_bind_sockaddr()

int evhtp_bind_sockaddr ( evhtp_t *  htp,
struct sockaddr *  ,
size_t  sin_len,
int  backlog 
)

bind to an already allocated sockaddr.

See also
evhtp_bind_socket
Parameters
htp- ptr to evhtp_t structure
sa- ptr to sockaddr structure
sin_len- size of sockaddr structure
backlog- backlog flag
Returns
0 on success, -1 on fail

Definition at line 4045 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_bind_socket()

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.

The addr can be defined as one of the following: ipv6:<ipv6addr> for binding to an IPv6 address. unix:<named pipe>=""> for binding to a unix named socket ipv4:<ipv4addr> for binding to an ipv4 address Otherwise the addr is assumed to be ipv4.

Parameters
htp
addr
port
backlog
Returns

Definition at line 4122 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_callback_free()

void evhtp_callback_free ( evhtp_callback_t *  callback)

safely frees callback structure memory and internals

See also
evhtp_safe_free
Parameters
callback- callback to be freed

Definition at line 4244 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_callback_get_hooks()

evhtp_hooks_t* evhtp_callback_get_hooks ( evhtp_callback_t *  cb)

returns callback hooks

Parameters
cb
Returns

Definition at line 4478 of file evhtp.c.

◆ evhtp_callback_new()

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.

All callbacks are stored in this structure which define what the final function to be called after all parsing is done. A callback can be either a static string or a regular expression.

Parameters
pathcan either be a static path (/path/to/resource/) or a POSIX compatible regular expression (^/resource/(.*))
typeinforms the function what type of of information is is contained within the path argument. This can either be callback_type_path, or callback_type_regex.
cbthe callback function to be invoked
argoptional argument which is passed when the callback is executed.
Returns
0 on success, -1 on error.

Definition at line 4199 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_callback_set_hook()

int evhtp_callback_set_hook ( evhtp_callback_t *  callback,
evhtp_hook_type  type,
evhtp_hook  cb,
void *  arg 
)

Definition at line 4387 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_callback_unset_hook()

int evhtp_callback_unset_hook ( evhtp_callback_t *  callback,
evhtp_hook_type  type 
)

Definition at line 4369 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_callbacks_add_callback()

int evhtp_callbacks_add_callback ( evhtp_callbacks_t cbs,
evhtp_callback_t *  cb 
)

Adds a evhtp_callback_t to the evhtp_callbacks_t list.

Parameters
cbsan allocated evhtp_callbacks_t structure
cban initialized evhtp_callback_t structure
Returns
0 on success, -1 on error

Definition at line 4277 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_callbacks_free()

void evhtp_callbacks_free ( evhtp_callbacks_t callbacks)

Definition at line 4179 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_connection_free()

void evhtp_connection_free ( evhtp_connection_t *  connection)

free's all connection related resources, this will also call your request fini hook and request fini hook.

Parameters
connection

Definition at line 5073 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_connection_get_bev()

struct bufferevent* evhtp_connection_get_bev ( evhtp_connection_t *  conn)

returns the underlying connections bufferevent

Parameters
conn
Returns
bufferevent on success, otherwise NULL

Definition at line 4967 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_get_hooks()

evhtp_hooks_t* evhtp_connection_get_hooks ( evhtp_connection_t *  c)

Definition at line 4444 of file evhtp.c.

◆ evhtp_connection_new()

evhtp_connection_t* evhtp_connection_new ( struct event_base *  evbase,
const char *  addr,
uint16_t  port 
)

allocate a new connection

Definition at line 5391 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_connection_new_dns()

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 at line 5397 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_connection_pause()

void evhtp_connection_pause ( evhtp_connection_t *  connection)

pauses a connection (disables reading)

Parameters
ca evhtp_connection_t * structure

Definition at line 3040 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_resume()

void evhtp_connection_resume ( evhtp_connection_t *  connection)

resumes a connection (enables reading) and activates resume event.

Parameters
c

Definition at line 3052 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_set_bev()

void evhtp_connection_set_bev ( evhtp_connection_t *  conn,
struct bufferevent *  bev 
)

Sets the connections underlying bufferevent.

Parameters
conn
bev

Definition at line 5009 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_set_hook()

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 .

A user may set a variety of hooks either per-connection, or per-callback. This allows the developer to hook into various parts of the request processing cycle.

a per-connection hook can be set at any time, but it is recommended to set these during either a pre-accept phase, or post-accept phase. This allows a developer to set hooks before any other hooks are called.

a per-callback hook works differently. In this mode a developer can setup a set of hooks prior to starting the event loop for specific callbacks. For example if you wanted to hook something ONLY for a callback set by evhtp_set_cb or evhtp_set_regex_cb this is the method of doing so.

per-callback example:

evhtp_callback_t * cb = evhtp_set_regex_cb(htp, "/anything/(.*)", default_cb, NULL);

evhtp_set_hook(&cb->hooks, evhtp_hook_on_headers, anything_headers_cb, NULL);

evhtp_set_hook(&cb->hooks, evhtp_hook_on_fini, anything_fini_cb, NULL);

With the above example, once libevhtp has determined that it has a user-defined callback for /anything/.*; anything_headers_cb will be executed after all headers have been parsed, and anything_fini_cb will be executed before the request is free()'d.

The same logic applies to per-connection hooks, but it should be noted that if a per-callback hook is set, the per-connection hook will be ignored.

Parameters
hooksdouble pointer to the evhtp_hooks_t structure
typethe hook type
cbthe callback to be executed.
argoptional argument which is passed when the callback is executed
Returns
0 on success, -1 on error (if hooks is NULL, it is allocated)

Definition at line 4399 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_connection_set_max_body_size()

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_body_size

Parameters
conn
len

Definition at line 5056 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_set_timeouts()

void evhtp_connection_set_timeouts ( evhtp_connection_t *  conn,
const struct timeval *  r,
const struct timeval *  w 
)
inline

sets a connection-specific read/write timeout which overrides the global read/write settings.

Parameters
conn
rtimeval for read
wtimeval for write

Definition at line 5042 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_connection_ssl_new()

evhtp_connection_t* evhtp_connection_ssl_new ( struct event_base *  evbase,
const char *  addr,
uint16_t  port,
evhtp_ssl_ctx_t ctx 
)

Definition at line 5474 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_connection_take_ownership()

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.

Warning: this will free all evhtp_connection/request structures, remove all associated hooks and reset the bufferevent to defaults, i.e., disable EV_READ, and set all callbacks to NULL.

Parameters
connection
Returns
underlying connections bufferevent.

Definition at line 4972 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_connection_unset_hook()

int evhtp_connection_unset_hook ( evhtp_connection_t *  conn,
evhtp_hook_type  type 
)

Definition at line 4381 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_disable_100_continue()

void evhtp_disable_100_continue ( evhtp_t *  htp)

Definition at line 5151 of file evhtp.c.

◆ evhtp_get_cb()

evhtp_callback_t* evhtp_get_cb ( evhtp_t *  htp,
const char *  needle 
)

attempts to find the callback matching the exact string 'needle'.

This is useful in cases where we want to get the original handle, but is not in scope.

with pattern based callbacks, this does not attempt to find a callback that would match the string if the pattern matcher was executed.

Meaning: evhtp_set_glob_cb(htp, "/foo/bar*", ....);

Calling evhtp_get_cb(htp, "/foo/bar/baz");

Will return NULL since it's not the exact pattern set

Calling evhtp_get_cb(htp, "/foo/bar*");

Is the correct usage.

Parameters
htp
needle
Returns
NULL if callback is not not found

Definition at line 4523 of file evhtp.c.

◆ evhtp_header_key_add()

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

Parameters
headersthe evhtp_headers_t TAILQ (evhtp_kv_t)
keya null terminated string
kallocif 1 the string will be copied, otherwise assigned
Returns
an evhtp_header_t pointer or NULL on error

Definition at line 3081 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_header_val_add()

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

Parameters
headersthe evhtp_headers_t TAILQ (evhtp_kv_t)
vala null terminated string
vallocif 1 the string will be copied, otherwise assigned
Returns
an evhtp_header_t pointer or NULL on error

Definition at line 3096 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_is_hex_query_char()

static int evhtp_is_hex_query_char ( unsigned char  ch)
inlinestatic

Definition at line 3369 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_kv_find()

const char* evhtp_kv_find ( evhtp_kvs_t kvs,
const char *  key 
)

find the string value of 'key' from the key/value list 'kvs'

Parameters
kvs
key
Returns
NULL if not found

Definition at line 3288 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_kv_free()

void evhtp_kv_free ( evhtp_kv_t *  kv)

frees resources allocated for a single key/value

Parameters
kv

Definition at line 3206 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_kv_new()

evhtp_kv_t* evhtp_kv_new ( const char *  key,
const char *  val,
char  kalloc,
char  valloc 
)

Allocates a new key/value structure.

Parameters
keynull terminated string
valnull terminated string
kallocif set to 1, the key will be copied, if 0 no copy is done.
vallocif set to 1, the val will be copied, if 0 no copy is done.
Returns
evhtp_kv_t * on success, NULL on error.

Definition at line 3147 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_kv_rm_and_free()

void evhtp_kv_rm_and_free ( evhtp_kvs_t kvs,
evhtp_kv_t *  kv 
)

free's resources associated with 'kv' if ONLY found within the key/value list

Parameters
kvs
kv

Definition at line 3227 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_kvs_add_kv()

void evhtp_kvs_add_kv ( evhtp_kvs_t kvs,
evhtp_kv_t *  kv 
)

appends a key/val structure to a evhtp_kvs_t tailq

Parameters
kvsan evhtp_kvs_t structure
kvan evhtp_kv_t structure

Definition at line 3328 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_kvs_add_kvs()

void evhtp_kvs_add_kvs ( evhtp_kvs_t dst,
evhtp_kvs_t src 
)

appends all key/val structures from src tailq onto dst tailq

Parameters
dstan evhtp_kvs_t structure
srcan evhtp_kvs_t structure

Definition at line 3339 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_kvs_find_kv()

evhtp_kv_t* evhtp_kvs_find_kv ( evhtp_kvs_t kvs,
const char *  key 
)

find the evhtp_kv_t reference 'key' from the k/val list 'kvs'

Parameters
kvs
key
Returns

Definition at line 3308 of file evhtp.c.

◆ evhtp_kvs_for_each()

int evhtp_kvs_for_each ( evhtp_kvs_t kvs,
evhtp_kvs_iterator  cb,
void *  arg 
)

callback iterator which executes 'cb' for every entry in 'kvs'

Parameters
kvs
cb
arg
Returns

Definition at line 3266 of file evhtp.c.

◆ evhtp_kvs_free()

void evhtp_kvs_free ( evhtp_kvs_t kvs)

frees a the list of key/values, and all underlying entries

Parameters
kvs

Definition at line 3240 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_kvs_new()

evhtp_kvs_t* evhtp_kvs_new ( void  )

creates an empty list of key/values

Returns

Definition at line 3134 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_make_request()

int evhtp_make_request ( evhtp_connection_t *  c,
evhtp_request_t *  r,
htp_method  meth,
const char *  uri 
)

make a client request

Definition at line 5562 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_parse_query()

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.

Parses query arguments like "?herp=derp&foo=bar&blah=baz"

Parameters
querydata containing the uri query arguments
lensize of the data
Returns
evhtp_query_t * on success, NULL on error

Definition at line 3748 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_parse_query_wflags()

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.

Parses query arguments like "?herp=&foo=bar;blah=baz&a=%3"

Parameters
querydata containing the uri query arguments
lensize of the data
flagsparse query flags to alter 'strictness' (see EVHTP_PARSE_QUERY_FLAG_*)
Returns
evhtp_query_t * on success, NULL on error

Definition at line 3482 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_request_free()

void evhtp_request_free ( evhtp_request_t *  request)

Definition at line 5113 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_get_bev()

struct bufferevent* evhtp_request_get_bev ( evhtp_request_t *  request)

returns the underlying requests bufferevent

Parameters
request
Returns
bufferevent on success, otherwise NULL

Definition at line 4999 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_request_get_connection()

evhtp_connection_t* evhtp_request_get_connection ( evhtp_request_t *  request)

returns the underlying evhtp_connection_t structure from a request

Parameters
request
Returns
evhtp_connection_t on success, otherwise NULL

Definition at line 5030 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_request_get_hooks()

evhtp_hooks_t* evhtp_request_get_hooks ( evhtp_request_t *  r)

returns request hooks

Parameters
r
Returns

Definition at line 4461 of file evhtp.c.

◆ evhtp_request_get_method()

htp_method evhtp_request_get_method ( evhtp_request_t *  r)

returns the htp_method enum version of the request method.

Parameters
r
Returns
htp_method enum

Definition at line 3030 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_get_proto()

evhtp_proto evhtp_request_get_proto ( evhtp_request_t *  request)

Definition at line 5036 of file evhtp.c.

◆ evhtp_request_new()

evhtp_request_t* evhtp_request_new ( evhtp_callback_cb  cb,
void *  arg 
)

allocate a new request

Definition at line 5547 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_pause()

void evhtp_request_pause ( evhtp_request_t *  request)

Wrapper around evhtp_connection_pause.

See also
evhtp_connection_pause
Parameters
request

Definition at line 3064 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_request_resume()

void evhtp_request_resume ( evhtp_request_t *  request)

Wrapper around evhtp_connection_resume.

See also
evhtp_connection_resume
Parameters
request

Definition at line 3073 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_set_bev()

void evhtp_request_set_bev ( evhtp_request_t *  request,
struct bufferevent *  bev 
)

sets the underlying bufferevent for a evhtp_request

Parameters
request
bev

Definition at line 5015 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_set_hook()

int evhtp_request_set_hook ( evhtp_request_t *  req,
evhtp_hook_type  type,
evhtp_hook  cb,
void *  arg 
)

Definition at line 4393 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_set_keepalive()

void evhtp_request_set_keepalive ( evhtp_request_t *  request,
int  val 
)

Definition at line 5021 of file evhtp.c.

◆ evhtp_request_set_max_body_size()

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.

Parameters
request
len

Definition at line 5067 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_status()

unsigned int evhtp_request_status ( evhtp_request_t *  r)

Definition at line 5597 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_take_ownership()

struct bufferevent* evhtp_request_take_ownership ( evhtp_request_t *  request)

Definition at line 5004 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_request_unset_hook()

int evhtp_request_unset_hook ( evhtp_request_t *  req,
evhtp_hook_type  type 
)

Definition at line 4375 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_response_needs_body()

int evhtp_response_needs_body ( const evhtp_res  code,
const htp_method  method 
)

Determine if a response should have a body.

Follows the rules in RFC 2616 section 4.3.

Returns
1 if the response MUST have a body; 0 if the response MUST NOT have a body.

Definition at line 3819 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_send_reply()

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

Parameters
request
codeHTTP return status code

Definition at line 3790 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_send_reply_body()

void evhtp_send_reply_body ( evhtp_request_t *  request,
struct evbuffer *  buf 
)

Definition at line 3774 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_send_reply_chunk()

void evhtp_send_reply_chunk ( evhtp_request_t *  request,
struct evbuffer *  buf 
)

send a chunk reply.

Parameters
request
buf

Definition at line 3900 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_send_reply_chunk_end()

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.

This will add the last 0CRLFCRCL and call send_reply_end().

Parameters
request

Definition at line 3928 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_send_reply_chunk_start()

void evhtp_send_reply_chunk_start ( evhtp_request_t *  request,
evhtp_res  code 
)

start a chunked response.

If data already exists on the output buffer, this will be converted to the first chunk.

Parameters
request
code

Definition at line 3828 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_send_reply_end()

void evhtp_send_reply_end ( evhtp_request_t *  request)

Definition at line 3784 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_send_reply_start()

void evhtp_send_reply_start ( evhtp_request_t *  request,
evhtp_res  code 
)

Definition at line 3755 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_set_bev_flags()

void evhtp_set_bev_flags ( evhtp_t *  htp,
int  flags 
)

bufferevent flags which will be used for bev sockets.

Parameters
htp
flags

Definition at line 5139 of file evhtp.c.

◆ evhtp_set_cb()

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

Parameters
htpthe initialized evhtp_t
paththe path to match
cbthe function to be executed
arguser-defined argument passed to the callback
Returns
evhtp_callback_t * on success, NULL on error.

Definition at line 4484 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_set_gencb()

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

Parameters
htpthe initialized evhtp_t
cbthe function to be executed
arguser-defined argument passed to the callback

Definition at line 4717 of file evhtp.c.

Here is the caller graph for this function:

◆ evhtp_set_glob_cb()

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 care about what was matched, but just that it matched.

This is technically faster than regex.

Parameters
htp
patternwildcard pattern, the '*' can be set at either or both the front or end.
cb
arg
Returns

Definition at line 4678 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_set_max_body_size()

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.

Parameters
htp
len

Definition at line 5145 of file evhtp.c.

◆ evhtp_set_max_keepalive_requests()

void evhtp_set_max_keepalive_requests ( evhtp_t *  htp,
uint64_t  num 
)

sets a maximum number of requests that a single connection can make.

Parameters
htp
num

Definition at line 5133 of file evhtp.c.

◆ evhtp_set_mem_functions()

void evhtp_set_mem_functions ( void *(*)(size_t len)  mallocfn_,
void *(*)(void *p, size_t sz)  reallocfn_,
void(*)(void *p)  freefn_ 
)

Definition at line 321 of file evhtp.c.

◆ evhtp_set_parser_flags()

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.

i.e., what to parse and not to parse.

  SEE: EVHTP_PARSE_QUERY_* stuff.

  For example, if you do not wish for the streaming parser attempting the act
  of fragment parsing:
     evhtp_set_parser_flags(htp, EVHTP_PARSE_QUERY_FLAG_IGNORE_FRAGMENTS);
Parameters
htp
flags

Definition at line 5157 of file evhtp.c.

◆ evhtp_set_post_accept_cb()

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.

Parameters
htp
evhtp_post_accept_cb
arg
Returns

Definition at line 4731 of file evhtp.c.

◆ evhtp_set_pre_accept_cb()

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.

Parameters
htp
evhtp_pre_accept_cb
arg
Returns

Definition at line 4724 of file evhtp.c.

◆ evhtp_set_regex_cb()

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

Parameters
htpthe initialized evhtp_t
patterna POSIX compat regular expression
cbthe function to be executed
arguser-defined argument passed to the callback
Returns
evhtp_callback_t * on success, NULL on error

Definition at line 4637 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_set_timeouts()

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.

When the timeout expires your error hook will be called with the libevent supplied event flags.

Parameters
htpthe base evhtp_t struct
rread-timeout in timeval
wwrite-timeout in timeval.

Definition at line 5119 of file evhtp.c.

◆ evhtp_ssl_init()

int evhtp_ssl_init ( evhtp_t *  htp,
evhtp_ssl_cfg_t *  cfg 
)

Definition at line 4772 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_ssl_use_threads()

int evhtp_ssl_use_threads ( void  )

Definition at line 4740 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_unbind_socket()

void evhtp_unbind_socket ( evhtp_t *  htp)

stops the listening socket.

Parameters
htp

Definition at line 3940 of file evhtp.c.

◆ evhtp_unescape_string()

int evhtp_unescape_string ( unsigned char **  out,
unsigned char *  str,
size_t  str_len 
)

Unescapes strings like '%7B1,%202,%203%7D' would become '{1, 2, 3}'.

Parameters
outdouble pointer where output is stored. This is allocated by the user.
strthe string to unescape
str_lenthe length of the string to unescape
Returns
0 on success, -1 on error

Definition at line 3403 of file evhtp.c.

◆ evhtp_unset_all_hooks()

int evhtp_unset_all_hooks ( evhtp_hooks_t **  hooks)

removes all hooks.

Parameters
hooks
Returns

Definition at line 4405 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evhtp_use_callback_locks()

int evhtp_use_callback_locks ( evhtp_t *  htp)

creates a lock around callbacks and hooks, allowing for threaded applications to add/remove/modify hooks & callbacks in a thread-safe manner.

Parameters
htp
Returns
0 on success, -1 on error

Definition at line 4618 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_use_threads()

int evhtp_use_threads ( evhtp_t *  ,
evhtp_thread_init_cb  ,
int  nthreads,
void *   
)

Enable thread-pool support for an evhtp_t context.

Connectios are distributed across 'nthreads'. An optional "on-start" callback can be set which allows you to manipulate the thread-specific inforation (such as the thread-specific event_base).

Parameters
htp
init_cb
exit_cb
nthreads
arg
Returns

Definition at line 4599 of file evhtp.c.

Here is the call graph for this function:

◆ evhtp_use_threads_wexit()

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.

evhtp_use_threads() has been noted as deprecated for now

Definition at line 4606 of file evhtp.c.

Here is the call graph for this function:

◆ htp__accept_cb_()

static void htp__accept_cb_ ( struct evconnlistener *  serv,
int  fd,
struct sockaddr *  s,
int  sl,
void *  arg 
)
static

Definition at line 2820 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__authority_free_()

static void htp__authority_free_ ( evhtp_authority_t *  authority)
static

frees an authority structure

Parameters
authorityevhtp_authority_t

Definition at line 1152 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__authority_new_()

static int htp__authority_new_ ( evhtp_authority_t **  out)
static

create an authority structure

Returns
0 on success, -1 on error

Definition at line 1132 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__callback_find_()

static evhtp_callback_t* htp__callback_find_ ( evhtp_callbacks_t cbs,
const char *  path,
unsigned int *  start_offset,
unsigned int *  end_offset 
)
static

Locates a given callback offsets performs a regex pattern match.

Parameters
[IN]cbs ptr to evhtp_callbacks_t structure
[IN]path
[OUT]start_offset
[OUT]end_offset
Returns

Definition at line 905 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__calloc_()

static void* htp__calloc_ ( size_t  nmemb,
size_t  size 
)
static

Wrapper for calloc so that a different calloc can be used if desired.

See also
evhtp_set_mem_functions
Parameters
nmembnumber of members (as a size_t)
sizesize of member blocks (as a size_t)
Returns
void * to new memory block

Definition at line 228 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__connection_accept_()

static int htp__connection_accept_ ( struct event_base *  evbase,
evhtp_connection_t *  connection 
)
static

Definition at line 2642 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__connection_eventcb_()

static void htp__connection_eventcb_ ( struct bufferevent *  bev,
short  events,
void *  arg 
)
static

Definition at line 2483 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__connection_new_()

static evhtp_connection_t* htp__connection_new_ ( evhtp_t *  htp,
evutil_socket_t  sock,
evhtp_type  type 
)
static

Definition at line 2724 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__connection_readcb_()

static void htp__connection_readcb_ ( struct bufferevent *  bev,
void *  arg 
)
static

Definition at line 2233 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__connection_resumecb_()

static void htp__connection_resumecb_ ( int  fd,
short  events,
void *  arg 
)
static

Definition at line 2582 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__connection_writecb_()

static void htp__connection_writecb_ ( struct bufferevent *  bev,
void *  arg 
)
static

Definition at line 2322 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__create_headers_()

static int htp__create_headers_ ( evhtp_header_t header,
void *  arg 
)
static

Definition at line 2067 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__create_reply_()

static struct evbuffer* htp__create_reply_ ( evhtp_request_t *  request,
evhtp_res  code 
)
static

Definition at line 2081 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__default_request_cb_()

static void htp__default_request_cb_ ( evhtp_request_t *  request,
void *  arg 
)
static

Definition at line 2716 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__free_()

static void htp__free_ ( void *  ptr)
static

Wrapper for free so that a different free can be used if desired.

See also
evhtp_set_mem_functions
Parameters
ptrpointer to memory to be freed.

Definition at line 211 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__glob_match_()

static int htp__glob_match_ ( const char *  pattern,
size_t  plen,
const char *  string,
size_t  str_len 
)
static

glob/wildcard type pattern matching.

Note: This code was derived from redis's (v2.6) stringmatchlen() function.

Parameters
pattern
string
Returns

Definition at line 830 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_body_()

static evhtp_res htp__hook_body_ ( evhtp_request_t *  request,
struct evbuffer *  buf 
)
inlinestatic

runs the user-defined on_body hook for requests containing a body.

the data is stored in the request->buffer_in so the user may either leave it, or drain upon being called.

Parameters
requestthe request strucutre
bufa evbuffer containing body data
Returns
EVHTP_RES_OK on success, otherwise something else.

Definition at line 635 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_chunk_fini_()

static evhtp_res htp__hook_chunk_fini_ ( evhtp_request_t *  request)
inlinestatic

Runs the user defined on_chunk_fini hook.

Parameters
request
Returns

Definition at line 690 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_chunk_new_()

static evhtp_res htp__hook_chunk_new_ ( evhtp_request_t *  request,
uint64_t  len 
)
inlinestatic

Runs the user defined request hook.

Parameters
request
len
Returns

Definition at line 676 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_chunks_fini_()

static evhtp_res htp__hook_chunks_fini_ ( evhtp_request_t *  request)
inlinestatic

Runs the user defined on chunk_finis hook.

Parameters
request
Returns

Definition at line 704 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_connection_error_()

static evhtp_res htp__hook_connection_error_ ( evhtp_connection_t *  connection,
evhtp_error_flags  errtype 
)
inlinestatic

runs the user-defined hook when a connection error occurs

Parameters
connectionthe connection structure
errtypethe error that ocurred

Definition at line 771 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__hook_connection_fini_()

static evhtp_res htp__hook_connection_fini_ ( evhtp_connection_t *  connection)
inlinestatic

runs the user-definedhook called just prior to a connection being closed

Parameters
connectionthe connection structure
Returns
EVHTP_RES_OK on success, but pretty much ignored in any case.

Definition at line 734 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_connection_write_()

static evhtp_res htp__hook_connection_write_ ( evhtp_connection_t *  connection)
inlinestatic

Runs the user defined on_write hook.

Parameters
connection
Returns

Definition at line 808 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_error_()

static void htp__hook_error_ ( evhtp_request_t *  request,
evhtp_error_flags  errtype 
)
inlinestatic

runs the user-defined hook when a connection error occurs

Parameters
requestthe request structure
errtypethe error that ocurred

Definition at line 756 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_header_()

static evhtp_res htp__hook_header_ ( evhtp_request_t *  request,
evhtp_header_t header 
)
inlinestatic

runs the user-defined on_header hook for a request

once a full key: value header has been parsed, this will call the hook

Parameters
requestthe request strucutre
headerthe header structure
Returns
EVHTP_RES_OK on success, otherwise something else.

Definition at line 600 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_headers_()

static evhtp_res htp__hook_headers_ ( evhtp_request_t *  request,
evhtp_headers_t headers 
)
inlinestatic

runs the user-defined on_Headers hook for a request after all headers have been parsed.

Parameters
requestthe request structure
headersthe headers tailq structure
Returns
EVHTP_RES_OK on success, otherwise something else.

Definition at line 617 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_headers_start_()

static evhtp_res htp__hook_headers_start_ ( evhtp_request_t *  request)
inlinestatic

Runs the user defined on_headers_start hook.

Parameters
request
Returns

Definition at line 718 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_hostname_()

static evhtp_res htp__hook_hostname_ ( evhtp_request_t *  r,
const char *  hostname 
)
inlinestatic

Runs the user defined hostname processing hook.

Parameters
r
hostname
Returns

Definition at line 794 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_path_()

static evhtp_res htp__hook_path_ ( evhtp_request_t *  request,
evhtp_path_t *  path 
)
inlinestatic

runs the user-defined on_path hook for a request

Parameters
requestthe request structure
paththe path structure
Returns
EVHTP_RES_OK on success, otherwise something else.

Definition at line 582 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__hook_request_fini_()

static evhtp_res htp__hook_request_fini_ ( evhtp_request_t *  request)
inlinestatic

runs the user-defined hook called just prior to a request been free()'d

Parameters
requesttherequest structure
Returns
EVHTP_RES_OK on success, otherwise treated as an error

Definition at line 656 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__malloc_()

static void* htp__malloc_ ( size_t  size)
static

Wrapper for malloc so that a different malloc can be used if desired.

See also
evhtp_set_mem_functions
Parameters
sizesize_t of memory to be allocated
Returns
void * to malloc'd memory or NULL if fail

Definition at line 179 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__path_free_()

static void htp__path_free_ ( evhtp_path_t *  path)
static

Correctly frees the evhtp_path_t ptr that is passed in.

Parameters
path

Definition at line 1110 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__path_new_()

static int htp__path_new_ ( evhtp_path_t **  out,
const char *  data,
size_t  len 
)
static

parses the path and file from an input buffer

in order to properly create a structure that can match both a path and a file, this will parse a string into what it considers a path, and a file.

if for example the input was "/a/b/c", the parser will consider "/a/b/" as the path, and "c" as the file.

Parameters
theunallocated destination buffer.
dataraw input data (assumes a /path/[file] structure)
lenlength of the input data
Returns
0 on success, -1 on error.

Definition at line 990 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__protocol_()

static evhtp_proto htp__protocol_ ( const char  major,
const char  minor 
)
inlinestatic

returns the HTTP protocol version

Parameters
majorthe major version number
minorthe minor version number
Returns
EVHTP_PROTO_10 if HTTP/1.0, EVHTP_PROTO_11 if HTTP/1.1, otherwise EVHTP_PROTO_INVALID

Definition at line 558 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__realloc_()

static void* htp__realloc_ ( void *  ptr,
size_t  size 
)
static

Wrapper for realloc so that a different realloc can be used if desired.

See also
evhtp_set_mem_functions
Parameters
ptrcurrent memory ptr
sizesize_t of memory to be allocated
Returns
void * to newly realloc'd memory or NULL if fail

Definition at line 196 of file evhtp.c.

◆ htp__request_find_vhost_()

static evhtp_t* htp__request_find_vhost_ ( evhtp_t *  evhtp,
const char *  name 
)
inlinestatic

Definition at line 1509 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__request_free_()

static void htp__request_free_ ( evhtp_request_t *  request)
static

frees all data in an evhtp_request_t along with calling finished hooks

Parameters
requestthe request structure

Definition at line 1225 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__request_new_()

static evhtp_request_t* htp__request_new_ ( evhtp_connection_t *  c)
static

Creates a new evhtp_request_t.

Parameters
c
Returns
evhtp_request_t structure on success, otherwise NULL

Definition at line 1265 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__request_parse_args_()

static int htp__request_parse_args_ ( htparser p,
const char *  data,
size_t  len 
)
static

parses http request arguments

See also
htparser_get_userdata
Parameters
p
data
len
Returns
0 on success, -1 on failure (sets connection cr_status as well)

Definition at line 1367 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_body_()

static int htp__request_parse_body_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1881 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_chunk_fini_()

static int htp__request_parse_chunk_fini_ ( htparser p)
static

Definition at line 1934 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_chunk_new_()

static int htp__request_parse_chunk_new_ ( htparser p)
static

Definition at line 1920 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_chunks_fini_()

static int htp__request_parse_chunks_fini_ ( htparser p)
static

Definition at line 1947 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_fini_()

static int htp__request_parse_fini_ ( htparser p)
static

Definition at line 2011 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_header_key_()

static int htp__request_parse_header_key_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1453 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_header_val_()

static int htp__request_parse_header_val_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1478 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_headers_()

static int htp__request_parse_headers_ ( htparser p)
static

Definition at line 1836 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_headers_start_()

static int htp__request_parse_headers_start_ ( htparser p)
static

Definition at line 1440 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_host_()

static int htp__request_parse_host_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1729 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_hostname_()

static int htp__request_parse_hostname_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1656 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_path_()

static int htp__request_parse_path_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1795 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_port_()

static int htp__request_parse_port_ ( htparser p,
const char *  data,
size_t  len 
)
static

Definition at line 1767 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_parse_start_()

static int htp__request_parse_start_ ( htparser p)
static

Starts the parser for the connection associated with the parser struct.

Parameters
p
Returns
0 on success, -1 on fail

Definition at line 1324 of file evhtp.c.

Here is the call graph for this function:

◆ htp__request_set_callbacks_()

static int htp__request_set_callbacks_ ( evhtp_request_t *  request)
inlinestatic

Definition at line 1546 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__require_uri_()

static int htp__require_uri_ ( evhtp_connection_t *  c)
static

Definition at line 1713 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__run_in_thread_()

static void htp__run_in_thread_ ( evthr_t *  thr,
void *  arg,
void *  shared 
)
static

Definition at line 2794 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__run_post_accept_()

static int htp__run_post_accept_ ( evhtp_t *  htp,
evhtp_connection_t *  connection 
)
static

Definition at line 2771 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__run_pre_accept_()

static int htp__run_pre_accept_ ( evhtp_t *  htp,
evhtp_connection_t *  conn 
)
static

Definition at line 2620 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__set_hook_()

static int htp__set_hook_ ( evhtp_hooks_t **  hooks,
evhtp_hook_type  type,
evhtp_hook  cb,
void *  arg 
)
static

Definition at line 4285 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__should_parse_query_body_()

static int htp__should_parse_query_body_ ( evhtp_request_t *  req)
static

determines if the request body contains the query arguments.

if the query is NULL and the content length of the body has never been drained, and the content-type is x-www-form-urlencoded, the function returns 1

Parameters
req
Returns
1 if evhtp can use the body as the query arguments, 0 otherwise.

Definition at line 1970 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__ssl_add_scache_ent_()

static int htp__ssl_add_scache_ent_ ( evhtp_ssl_t ssl,
evhtp_ssl_sess_t sess 
)
static

Definition at line 2919 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__ssl_delete_scache_ent_()

static void htp__ssl_delete_scache_ent_ ( evhtp_ssl_ctx_t ctx,
evhtp_ssl_sess_t sess 
)
static

Definition at line 2901 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__ssl_get_scache_ent_()

static evhtp_ssl_sess_t* htp__ssl_get_scache_ent_ ( evhtp_ssl_t ssl,
evhtp_ssl_data_t sid,
int  sid_len,
int *  copy 
)
static

Definition at line 2946 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__ssl_get_thread_id_()

static unsigned long htp__ssl_get_thread_id_ ( void  )
static

Definition at line 2874 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__ssl_servername_()

static int htp__ssl_servername_ ( evhtp_ssl_t ssl,
int *  unused,
void *  arg 
)
static

Definition at line 2972 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__ssl_thread_lock_()

static void htp__ssl_thread_lock_ ( int  mode,
int  type,
const char *  file,
int  line 
)
static

Definition at line 2886 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__strdup_()

static char* htp__strdup_ ( const char *  str)
static

implementation of strdup function.

Parameters
str- null terminated string.
Returns
duplicate of string or NULL if fail

Definition at line 257 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__strndup_()

static char* htp__strndup_ ( const char *  str,
size_t  len 
)
static

implementation of strndup function.

Parameters
str- null terminated string.
len- size_t length off string
Returns
duplicate of string or NULL if fail

Definition at line 289 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__thread_exit_()

static void htp__thread_exit_ ( evthr_t *  thr,
void *  arg 
)
static

Definition at line 4557 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__thread_init_()

static void htp__thread_init_ ( evthr_t *  thr,
void *  arg 
)
static

Definition at line 4546 of file evhtp.c.

Here is the caller graph for this function:

◆ htp__unset_hook_()

static int htp__unset_hook_ ( evhtp_hooks_t **  hooks,
evhtp_hook_type  type 
)
static

Definition at line 4364 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__uri_free_()

static void htp__uri_free_ ( evhtp_uri_t *  uri)
static

frees an overlay URI structure

Parameters
urievhtp_uri_t

Definition at line 1172 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__uri_new_()

static int htp__uri_new_ ( evhtp_uri_t **  out)
static

create an overlay URI structure

Returns
0 on success, -1 on error.

Definition at line 1195 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ htp__use_threads_()

static int htp__use_threads_ ( evhtp_t *  htp,
evhtp_thread_init_cb  init_cb,
evhtp_thread_exit_cb  exit_cb,
int  nthreads,
void *  arg 
)
static

Definition at line 4568 of file evhtp.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HTP_FLAG_FNGEN() [1/3]

HTP_FLAG_FNGEN ( evhtp_t *  )

◆ HTP_FLAG_FNGEN() [2/3]

HTP_FLAG_FNGEN ( _connection  ,
evhtp_connection_t *   
)

◆ HTP_FLAG_FNGEN() [3/3]

HTP_FLAG_FNGEN ( _request  ,
evhtp_request_t *   
)

◆ status_code_to_str()

static const char* status_code_to_str ( evhtp_res  code)
static

returns string status code from enum code

Parameters
codeas evhtp_res enum
Returns
string corresponding to code, else UNKNOWN

Definition at line 342 of file evhtp.c.

Here is the caller graph for this function:

◆ TAILQ_HEAD()

TAILQ_HEAD ( evhtp_callbacks_s  ,
evhtp_callback_s   
)

Variable Documentation

◆ free_

void(* free_) (void *d) = free
static

Definition at line 166 of file evhtp.c.

◆ malloc_

void*(* malloc_) (size_t sz) = malloc
static

Definition at line 164 of file evhtp.c.

◆ realloc_

void*(* realloc_) (void *d, size_t sz) = realloc
static

Definition at line 165 of file evhtp.c.

◆ request_psets

htparse_hooks request_psets
static
Initial value:
= {
.on_msg_begin = htp__request_parse_start_,
.method = NULL,
.scheme = NULL,
.uri = NULL,
.on_hdrs_complete = htp__request_parse_headers_,
.on_chunk_complete = htp__request_parse_chunk_fini_,
.on_chunks_complete = htp__request_parse_chunks_fini_,
.on_msg_complete = htp__request_parse_fini_
}
static int htp__request_parse_fini_(htparser *p)
Definition: evhtp.c:2011
static int htp__request_parse_body_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1881
static int htp__request_parse_args_(htparser *p, const char *data, size_t len)
parses http request arguments
Definition: evhtp.c:1367
static int htp__request_parse_chunks_fini_(htparser *p)
Definition: evhtp.c:1947
static int htp__request_parse_headers_start_(htparser *p)
Definition: evhtp.c:1440
static int htp__request_parse_path_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1795
static int htp__request_parse_hostname_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1656
static int htp__request_parse_chunk_new_(htparser *p)
Definition: evhtp.c:1920
static int htp__request_parse_header_key_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1453
static int htp__request_parse_port_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1767
static int htp__request_parse_host_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1729
static int htp__request_parse_chunk_fini_(htparser *p)
Definition: evhtp.c:1934
static int htp__request_parse_headers_(htparser *p)
Definition: evhtp.c:1836
static int htp__request_parse_start_(htparser *p)
Starts the parser for the connection associated with the parser struct.
Definition: evhtp.c:1324
static int htp__request_parse_header_val_(htparser *p, const char *data, size_t len)
Definition: evhtp.c:1478

callback definitions for request processing from libhtparse

Definition at line 2211 of file evhtp.c.

◆ session_id_context

int session_id_context = 1
static

Definition at line 445 of file evhtp.c.

◆ ssl_locks

evhtp_mutex_t* ssl_locks
static

Definition at line 448 of file evhtp.c.

◆ ssl_locks_initialized

int ssl_locks_initialized = 0
static

Definition at line 449 of file evhtp.c.

◆ ssl_num_locks

int ssl_num_locks
static

Definition at line 447 of file evhtp.c.