4 * @brief Interface of request_t.
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29 typedef struct request_t request_t
;
32 * @brief A HTTP request, encapsulates FCGX_Request.
38 * @brief Add a cookie to the reply (Set-Cookie header).
40 * @param name name of the cookie to set
41 * @param value value of the cookie
43 void (*add_cookie
)(request_t
*this, char *name
, char *value
);
46 * @brief Get a cookie the client sent in the request.
48 * @param name name of the cookie
49 * @return cookie value, NULL if no such cookie found
51 char* (*get_cookie
)(request_t
*this, char *name
);
54 * @brief Get the request path relative to the application.
58 char* (*get_path
)(request_t
*this);
61 * @brief Get the base path of the application.
65 char* (*get_base
)(request_t
*this);
68 * @brief Get a post/get variable included in the request.
70 * @param name name of the POST/GET variable
71 * @return value, NULL if not found
73 char* (*get_query_data
)(request_t
*this, char *name
);
76 * @brief Redirect the client to another location.
78 * @param fmt location format string
79 * @param ... variable argument for fmt
81 void (*redirect
)(request_t
*this, char *fmt
, ...);
84 * @brief Set a template value.
86 * @param key key to set
87 * @param value value to set key to
89 void (*set
)(request_t
*this, char *key
, char *value
);
92 * @brief Set a template value using format strings.
94 * Format string is in the form "key=value", where printf like format
95 * substitution occurs over the whole string.
97 * @param format printf like format string
98 * @param ... variable argument list
100 void (*setf
)(request_t
*this, char *format
, ...);
103 * @brief Render a template.
105 * The render() function additionally sets a HDF variable "base"
106 * which points to the root of the web application and allows to point to
107 * other targets without to worry about path location.
109 * @param template clearsilver template file location
111 void (*render
)(request_t
*this, char *template);
114 * @brief Serve a request with headers and a body.
116 * @param headers HTTP headers, \n separated
117 * @param chunk body to write to output
119 void (*serve
)(request_t
*this, char *headers
, chunk_t chunk
);
122 * @brief Destroy the request_t.
124 void (*destroy
) (request_t
*this);
128 * @brief Create a request from the fastcgi struct.
130 * @param request the FCGI request
131 * @param debug no stripping, no compression, timing information
133 request_t
*request_create(FCGX_Request
*request
, bool debug
);
135 #endif /* REQUEST_H_ */