summaryrefslogtreecommitdiff
path: root/src/ne_request.h
diff options
context:
space:
mode:
authorjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-09-26 09:13:42 +0000
committerjoe <joe@61a7d7f5-40b7-0310-9c16-bb0ea8cb1845>2006-09-26 09:13:42 +0000
commitc3706745d52552e6b1d9d89ba9e0054bd753812c (patch)
tree6860465c5d0ca700e68458ee10ca1ea20e914fa7 /src/ne_request.h
parent808cce47c401fcbbf6036fc9668716b85df4a58c (diff)
downloadneon-c3706745d52552e6b1d9d89ba9e0054bd753812c.tar.gz
Add new hook which runs after the headers have been read:
* src/ne_request.h (ne_post_headers_fn, ne_hook_post_headers): Add type, prototype. * src/ne_private.h (struct ne_session_s): Add post_headers_hooks field. * src/ne_request.c (ne_begin_request): Run post_headers hooks. * src/ne_session.c (ne_session_destroy): Destroy post_headers hooks. (ne_hook_post_headers, ne_unhook_post_headers): New functions. * test/request.c (status_to_string): New function. (hook_post_send): Use it. (hook_post_headers): New function. (hooks): Test post_headers hook. git-svn-id: http://svn.webdav.org/repos/projects/neon/trunk@1075 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845
Diffstat (limited to 'src/ne_request.h')
-rw-r--r--src/ne_request.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ne_request.h b/src/ne_request.h
index 21497e0..ab14939 100644
--- a/src/ne_request.h
+++ b/src/ne_request.h
@@ -248,19 +248,31 @@ typedef void (*ne_free_hooks)(void *cookie);
/* Hook called when a request is created; passed the request method,
* and the string used as the Request-URI (note that this may be a
- * absolute URI if a proxy is in use, an absolute path, a "*",
- * etc). */
+ * absolute URI if a proxy is in use, an absolute path, a "*", etc).
+ * A create_request hook is called exactly once per request. */
typedef void (*ne_create_request_fn)(ne_request *req, void *userdata,
const char *method, const char *requri);
void ne_hook_create_request(ne_session *sess,
ne_create_request_fn fn, void *userdata);
/* Hook called before the request is sent. 'header' is the raw HTTP
- * header before the trailing CRLF is added: add in more here. */
+ * header before the trailing CRLF is added; more headers can be added
+ * here. A pre_send hook may be called >1 time per request if the
+ * request is retried due to a post_send hook returning NE_RETRY. */
typedef void (*ne_pre_send_fn)(ne_request *req, void *userdata,
ne_buffer *header);
void ne_hook_pre_send(ne_session *sess, ne_pre_send_fn fn, void *userdata);
+/* Hook called directly after the response headers have been read, but
+ * before the resposnse body has been read. 'status' is the response
+ * status-code. A post_header hook may be called >1 time per request
+ * if the request is retried due to a post_send hook returning
+ * NE_RETRY. */
+typedef void (*ne_post_headers_fn)(ne_request *req, void *userdata,
+ const ne_status *status);
+void ne_hook_post_headers(ne_session *sess,
+ ne_post_headers_fn fn, void *userdata);
+
/* Hook called after the request is dispatched (request sent, and
* the entire response read). If an error occurred reading the response,
* this hook will not run. May return:
@@ -294,6 +306,7 @@ void ne_hook_destroy_session(ne_session *sess,
void ne_unhook_create_request(ne_session *sess,
ne_create_request_fn fn, void *userdata);
void ne_unhook_pre_send(ne_session *sess, ne_pre_send_fn fn, void *userdata);
+void ne_unhook_post_headers(ne_session *sess, ne_post_headers_fn fn, void *userdata);
void ne_unhook_post_send(ne_session *sess, ne_post_send_fn fn, void *userdata);
void ne_unhook_destroy_request(ne_session *sess,
ne_destroy_req_fn fn, void *userdata);