1 #ifndef WIBBLE_NET_HTTP_H 2 #define WIBBLE_NET_HTTP_H 37 struct error :
public std::exception
43 error(
int code,
const std::string& desc)
44 : code(code), desc(desc) {}
45 error(
int code,
const std::string& desc,
const std::string& msg)
46 : code(code), desc(desc), msg(msg) {}
49 virtual const char*
what()
const throw ();
89 std::map<std::string, std::string>
headers;
120 bool read_buf(std::string& res,
size_t size);
140 void send(
const std::string& buf);
143 void send_status_line(
int code,
const std::string&
msg,
const std::string& version =
"HTTP/1.0");
146 void send_server_header();
149 void send_date_header();
152 void send_extra_response_headers();
155 void send_result(
const std::string& content,
const std::string& content_type=
"text/html; charset=utf-8",
const std::string& filename=std::string());
158 void discard_input();
166 std::string pop_path_info();
173 std::string path_info_head();
187 virtual void parse(
const std::string& str) = 0;
193 virtual void parse(
const std::string& str);
199 virtual void parse(
const std::string& str);
219 std::map<std::string, std::string> headers,
220 const std::string& outdir,
221 const std::string& fname_blacklist,
222 const std::string& client_fname,
224 const std::string& boundary,
235 std::map<std::string, std::string> headers,
236 const std::string& outdir,
237 const std::string& fname_blacklist,
238 const std::string& client_fname,
240 const std::string& boundary,
241 size_t inputsize) = 0;
259 std::map<std::string, std::string> headers,
260 const std::string& outdir,
261 const std::string& fname_blacklist,
262 const std::string& client_fname,
264 const std::string& boundary,
277 std::map<std::string, std::string> headers,
278 const std::string& outdir,
279 const std::string& fname_blacklist,
280 const std::string& client_fname,
282 const std::string& boundary,
295 std::map<std::string, FileParam*>
files;
342 template<
typename TYPE>
343 TYPE*
add(
const std::string& name)
345 TYPE* res =
new TYPE;
351 void add(
const std::string& name,
Param* param);
354 void add(
const std::string& name,
FileParam* param);
361 Param* obtain_field(
const std::string& name);
368 FileParam* obtain_file_field(
const std::string& name);
371 Param* field(
const std::string& name);
374 FileParam* file_field(
const std::string& name);
380 void parse_urlencoded(
const std::string& qstring);
383 void parse_multipart(
net::http::Request& req,
size_t inputsize,
const std::string& content_type);
Infomation about one uploaded file.
Definition: http.h:208
Multiple file uploads with the same name.
Definition: http.h:271
error400(const std::string &msg)
Definition: http.h:57
virtual const char * what() const
Definition: http.cpp:38
std::string conf_fname_blacklist
String containing blacklist characters that are replaced with "_" in the file name.
Definition: http.h:335
TYPE * add(const std::string &name)
Universal, automatic add method.
Definition: http.h:343
size_t conf_max_field_size
Maximum size of field data for one non-file field.
Definition: http.h:301
std::string query_string
Definition: http.h:80
error(int code, const std::string &desc)
Definition: http.h:43
error404()
Definition: http.h:62
std::string peer_hostaddr
Definition: http.h:74
std::string script_name
Definition: http.h:78
std::string server_port
Definition: http.h:77
File upload parameter.
Definition: http.h:205
wibble::net::mime::Reader mime_reader
Definition: http.h:92
Single-valued parameter.
Definition: http.h:191
bool conf_accept_unknown_fields
Whether to accept unknown fields.
Definition: http.h:310
std::string url
Definition: http.h:87
std::map< std::string, std::string > extra_response_headers
Definition: http.h:94
std::string fname
File pathname on the local file system.
Definition: http.h:211
int code
Definition: http.h:39
Parse and store HTTP query parameters.
Definition: http.h:292
std::map< std::string, std::string > headers
Definition: http.h:89
virtual void send(Request &req)
Definition: http.cpp:44
error(int code, const std::string &desc, const std::string &msg)
Definition: http.h:45
Base interface for GET or POST parameters.
Definition: http.h:177
std::vector< FileInfo > files
Definition: http.h:273
std::string server_software
String to use as server software "NAME/version".
Definition: http.h:82
std::string desc
Definition: http.h:40
std::string path_info
Definition: http.h:79
std::string server_name
Definition: http.h:76
std::string version
Definition: http.h:88
size_t conf_max_input_size
Maximum size of POST input data.
Definition: http.h:298
std::string msg
Definition: http.h:41
virtual ~error()
Definition: http.h:47
size_t size(const std::string &file)
File size.
Definition: fs.cpp:287
wibble::Splitter space_splitter
Definition: http.h:90
Single file upload field.
Definition: http.h:247
FileInfo info
Definition: http.h:249
bool response_started
true if some response has already been sent to the client
Definition: http.h:84
std::string conf_outdir
Directory where we write uploaded files.
Definition: http.h:326
std::string peer_hostname
Definition: http.h:73
Map< List, F > map(const List &l, const F &f)
Definition: list.h:381
error400()
Definition: http.h:56
std::map< std::string, FileParam * > files
File parameters.
Definition: http.h:295
std::string method
Definition: http.h:86
int sock
Definition: http.h:72
std::string peer_port
Definition: http.h:75
bool conf_accept_unknown_file_fields
Whether to accept unknown file upload fields.
Definition: http.h:319
Split a string using a regular expression to match the token separators.
Definition: regexp.h:145
Multi-valued parameter.
Definition: http.h:197
std::string client_fname
File pathname provided by the client.
Definition: http.h:213
error404(const std::string &msg)
Definition: http.h:63