From: Martin Willi Date: Thu, 27 May 2010 07:30:14 +0000 (+0200) Subject: Added support for reading raw PUT/POST data from HTTP request X-Git-Tag: 4.4.1~215 X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=commitdiff_plain;h=ddf29f5b07cfb8c75381477de91435f12736f241 Added support for reading raw PUT/POST data from HTTP request --- diff --git a/src/libfast/request.c b/src/libfast/request.c index 6bf596f..16c1ae5 100644 --- a/src/libfast/request.c +++ b/src/libfast/request.c @@ -204,6 +204,14 @@ static char* get_query_data(private_request_t *this, char *name) } /** + * Implementation of request_t.read_data. + */ +static int read_data(private_request_t *this, char *buf, int len) +{ + return FCGX_GetStr(buf, len, this->req.in); +} + +/** * Implementation of request_t.get_base. */ static char* get_base(private_request_t *this) @@ -407,6 +415,7 @@ request_t *request_create(int fd, bool debug) this->public.add_cookie = (void(*)(request_t*, char *name, char *value))add_cookie; this->public.get_cookie = (char*(*)(request_t*,char*))get_cookie; this->public.get_query_data = (char*(*)(request_t*, char *name))get_query_data; + this->public.read_data = (int(*)(request_t*, char*, int))read_data; this->public.session_closed = (bool(*)(request_t*))session_closed; this->public.close_session = (void(*)(request_t*))close_session; this->public.redirect = (void(*)(request_t*, char *fmt,...))redirect; diff --git a/src/libfast/request.h b/src/libfast/request.h index af0f8e4..9ca74a9 100644 --- a/src/libfast/request.h +++ b/src/libfast/request.h @@ -86,6 +86,15 @@ struct request_t { char* (*get_query_data)(request_t *this, char *name); /** + * Read raw POST/PUT data from HTTP request. + * + * @param buf buffer to read data into + * @param len size of the supplied buffer + * @return number of bytes read, < 0 on error + */ + int (*read_data)(request_t *this, char *buf, int len); + + /** * Close the session and it's context after handling. */ void (*close_session)(request_t *this);