blob: aad920fc597618fa7c896f644449de41a361e2e4 [file] [log] [blame]
v0.3.7
- Due to various problems http-parser (ry/http-parser) I have written my own
parser (derived and ispired from various nginx functions) (./libhtparse).
- Re-introduced the pre_accept_cb and post_accept_cb which deprecates the
evhtp_set_connection_hooks (which would call a defined function immediately
after a connection was accepted, so it was confusing I think).
The new functions to set the pre/post accepts are:
* evhtp_set_pre_accept_cb(evhtp_t *, evhtp_pre_accept cb, void * arg);
* evhtp_set_post_accept_cb(evhtp_t *, evhtp_post_accept cb, void * arg);
- evhtp_pre_accept functions have the following attributes:
* int fd : (the allocated file descriptor)
* struct sockaddr * : self-explanitory
* int slen : size of sockaddr
* void * arg : argument passed to evhtp_set_pre_accept_cb
- evhtp_post_accept functions have the following attributes:
* evhtp_conn_t * : self explanitory
* void * arg : argument passed to evhtp_set_post_accept_cb
- libevhtp now properly honors all return evhtp_res's from defined request hooks.
Meaning if you return something other than EVHTP_RES_OK, the proper error
handling is done with the exception of EVHTP_RES_PAUSE (see notes on pausing)
- Added [currently only half-working] methods to allow for suspending and
resuming parser execution and connection handling.
A hook which returns an evhtp_res value can now return "EVHTP_RES_PAUSE" which
informs libevhtp to stop all request processing on a connection. Alternatively
you can use the functions evhtp_request_pause(evhtp_request_t *);
You may also get a copy of the suspend/resume event timer directly via the
function evhtp_request_get_resume_ev()
To resume execution/processing one must call the function
evhtp_request_resume(evhtp_request_t *);
To completely disable this functionality you may call the function
evhtp_disable_pausing(evhtp_t *) before dropping into your event loop
- Removed unnecessary bufferevent_[enable|disable] calls, it was too tedious
to work with as it could cause shitty race-like conditions if the client
bufferevent was needed outside of the library.
- EVHTP_CLOSE_* flags have been renamed to EVHTP_FLAG_CLOSE_* and length
extended to 16 bits.
- added functionality to both set and get user-set htp_request args:
evhtp_request_set_cbargs()
evhtp_request_get_cbargs()
- added a hook which is called just prior to a evhtp_request_t being free()'d
- Added the ability to define per-callback hooks. Much like per-connection hooks,
you can set various hooks which are called when a uri|regex (defined by the
set_cb functions) was matched.
In order to do this properly, set_cb functions now return a evhtp_callback_t which
can be passed to the evhtp_set_callback_hook() functions.
For example:
evhtp_callback_t * cb = evhtp_set_cb(htp, "/derp", derp_cb, NULL);
evhtp_set_callback_hook(cb, EVHTP_HOOK_HDRS_READ, derp_hdrs_cb, NULL);
In the case above once evhtp has found that the incoming request is destined
for the "/derp" specific callback, it will call "derp_hdrs_cb" after all
headers have been read.
These act just like normal per-connection hooks, but it should be noted that
if a per-callback hook has been enabled, the per-connection hook will be ignored
for that hook.
v0.3.6
- Removed submodule dependencies
- Added various evhtp_hdr functions
* evhtp_hdrs_new(): creates a new evhtp_hdrs_t struct
* evhtp_hdr_copy(): creates a copy of a evhtp_hdr_t struct
* evhtp_hdrs_copy(): creates a copy of a evhtp_hdrs_t struct
- Added a default request callback if the user has not defined one.
- Added some informational SSL accessor functions
v0.3.5
- Added evhtp_request_t accessors
evbuf_t * evhtp_request_get_input(evhtp_request_t *);
evbuf_t * evhtp_request_get_output(evhtp_request_t *);
evbase_t * evhtp_request_get_evbase(evhtp_request_t *);
evserv_t * evhtp_request_get_listener(evhtp_request_t *);
evhtp_method evhtp_request_get_method(evhtp_request_t *);
evhtp_proto evhtp_request_get_proto(evhtp_request_t *);
evhtp_conn_t * evhtp_request_get_conn(evhtp_request_t *);
evhtp_hdrs_t * evhtp_request_get_headers_in(evhtp_request_t *);
evhtp_hdrs_t * evhtp_request_get_headers_out(evhtp_request_t *);
evhtp_callback_cb evhtp_request_get_cb(evhtp_request_t *);
void * evhtp_request_get_cbarg(evhtp_request_t *);
int evhtp_request_get_sock(evhtp_request_t *);
const char * evhtp_request_get_path(evhtp_request_t *);
const char * evhtp_request_get_uri(evhtp_request_t *);
const char * evhtp_request_method_str(evhtp_request_t *);
int evhtp_request_get_matched_soff(evhtp_request_t *);
int evhtp_request_get_matched_eoff(evhtp_request_t *);
int64_t evhtp_request_get_content_length(evhtp_request_t *);
- Better callback return error and response handling.
* Callbacks which return an evhtp_res code now must use
EVHTP_RES_*, where each EVHTP_RES_* definition is a HTTP
status code. For example "return EVHTP_RES_400;" will
send a 404 error to the client, along with terminating
the parser.
- All static functions prefixed with _htp_* are now just static htp_
- Various small bugfixes.
v0.3.4
- Added optional OpenSSL support (with optional threading abstractions).
* In order to properly enable SSL for your server two things must happen:
evhtp_ssl_cfg structure must be filled with your settings:
evhtp_ssl_cfg scfg = {
.pemfile = ssl_pem,
.privfile = ssl_pem,
.cafile = ssl_ca,
.ciphers = "RC4+RSA:HIGH:+MEDIUM:+LOW",
.ssl_opts = <SSL SPECIFIC FLAGS>,
.enable_scache = 1,
.scache_timeout = 1024,
.scache_init = evhtp_ssl_scache_builtin_init,
.scache_add = evhtp_ssl_scache_builtin_add,
.scache_get = evhtp_ssl_scache_builtin_get,
.scache_del = NULL,
};
* please note that .scache_init, .scache_add, .scache_get, and .scace_del
are function points to allow for a user to define their own session cache
mechanism. Libevhtp has a few default built-in cache functions:
evhtp_ssl_scache_builtin_init,
evhtp_ssl_scache_builtin_add,
evhtp_ssl_scache_builtin_get,
evhtp_ssl_scache_builtin_del
Another side note here is that currently the builtin functions do not expire,
this will be fixed in the next beta-release.
* The second step is to enable the use of the SSL backend by calling
evhtp_use_ssl(evhtp_t *, evhtp_ssl_cfg *);
- Regular expression based path callback functions added:
evhtp_set_regex_cb(evhtp_t *, "^(/path_w_regex/).*", callback, args);
Using the case above, any path/uri in the request with /path_w_regex/*, the API
will execute your defined callback function. The output of which is the same as
any other defined callback.
- Added _htp_callbacks_find_callback_woffsets(), which (if regex) will set 2 integer
variables in the evhtp_rquest_t structure defining the beginning and end of a matched
URI/path.
- _htp_callback_new() has been modified to create regex based evhtp_callback_t's
- Made the evhtp_request_t structure private, various get/set functions have been added
to deal with the internals.
- Modified compile to support libonigurmura, a BSD licensed cross-platform regular expression
library. Currently this is only used to support posix regex functionality.