* The response is also handled through the request object.
*/
struct request_t {
-
+
/**
* Add a cookie to the reply (Set-Cookie header).
*
* @param value value of the cookie
*/
void (*add_cookie)(request_t *this, char *name, char *value);
-
+
/**
* Get a cookie the client sent in the request.
*
* @return cookie value, NULL if no such cookie found
*/
char* (*get_cookie)(request_t *this, char *name);
-
+
/**
* Get the request path relative to the application.
*
* @return path
*/
char* (*get_path)(request_t *this);
-
+
/**
* Get the base path of the application.
*
* @return base path
*/
char* (*get_base)(request_t *this);
-
+
/**
* Get the remote host address of this request.
*
* @return host address as string
*/
char* (*get_host)(request_t *this);
-
+
/**
* Get the user agent string.
*
* @return user agent string
*/
char* (*get_user_agent)(request_t *this);
-
+
/**
* Get a post/get variable included in the request.
*
* @return value, NULL if not found
*/
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);
-
+
/**
* Has the session been closed by close_session()?
*
* @return TRUE if session has been closed
*/
bool (*session_closed)(request_t *this);
-
+
/**
* Redirect the client to another location.
*
* @param ... variable argument for fmt
*/
void (*redirect)(request_t *this, char *fmt, ...);
-
+
/**
- * Redirect the client to the referer.
+ * Get the HTTP referer.
+ *
+ * @return HTTP referer
+ */
+ char* (*get_referer)(request_t *this);
+
+ /**
+ * Redirect back to the referer.
*/
void (*to_referer)(request_t *this);
-
+
/**
* Set a template value.
*
* @param value value to set key to
*/
void (*set)(request_t *this, char *key, char *value);
-
+
/**
* Set a template value using format strings.
*
* @param ... variable argument list
*/
void (*setf)(request_t *this, char *format, ...);
-
+
/**
* Render a template.
*
* @param template clearsilver template file location
*/
void (*render)(request_t *this, char *template);
-
+
/**
* Stream a format string to the client.
*
* @return number of streamed bytes, < 0 if stream closed
*/
int (*streamf)(request_t *this, char *format, ...);
-
+
/**
* Serve a request with headers and a body.
*
* @param chunk body to write to output
*/
void (*serve)(request_t *this, char *headers, chunk_t chunk);
-
+
/**
* Increase the reference count to the stream.
*
* @return this with increased refcount
*/
request_t* (*get_ref)(request_t *this);
-
+
/**
* Destroy the request_t.
*/