diff --git a/src/evhttp/evhttp.h b/src/evhttp/evhttp.h index 99d16a2f..68bcff96 100644 --- a/src/evhttp/evhttp.h +++ b/src/evhttp/evhttp.h @@ -229,6 +229,9 @@ struct { void (*cb)(struct evhttp_request *, void *); void *cb_arg; + void (*fail_cb)(struct evhttp_request *, void *); + void *fail_cb_arg; + /* * Chunked data callback - call for each completed chunk if * specified. If not specified, all the data is delivered via diff --git a/src/evhttp/http.c b/src/evhttp/http.c index 2f62ec2f..bfd838d5 100644 --- a/src/evhttp/http.c +++ b/src/evhttp/http.c @@ -650,7 +650,11 @@ evhttp_connection_fail(struct evhttp_connection *evcon, * reply before the connection can be freed. */ if (evhttp_connection_incoming_fail(req, error) == -1) - evhttp_connection_free(evcon); + { + if (req->fail_cb) + req->fail_cb(req, req->fail_cb_arg); + evhttp_connection_free(evcon); + } return; }