1#ifndef WIBBLE_NET_HTTP_H
2#define WIBBLE_NET_HTTP_H
37struct error :
public std::exception
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,
222 const std::string& client_fname,
235 std::map<std::string, std::string> headers,
236 const std::string&
outdir,
238 const std::string& client_fname,
259 std::map<std::string, std::string> headers,
260 const std::string&
outdir,
262 const std::string& client_fname,
277 std::map<std::string, std::string> headers,
278 const std::string&
outdir,
280 const std::string& client_fname,
292struct Params :
public std::map<std::string, Param*>
295 std::map<std::string, FileParam*>
files;
342 template<
typename 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);
Split a string using a regular expression to match the token separators.
Definition regexp.h:146
Multiple file uploads with the same name.
Definition http.h:272
std::vector< FileInfo > files
Definition http.h:273
Single file upload field.
Definition http.h:248
FileInfo info
Definition http.h:249
Infomation about one uploaded file.
Definition http.h:209
std::string fname
File pathname on the local file system.
Definition http.h:211
std::string client_fname
File pathname provided by the client.
Definition http.h:213
File upload parameter.
Definition http.h:206
virtual bool read(net::mime::Reader &mime_reader, std::map< std::string, std::string > headers, const std::string &outdir, const std::string &fname_blacklist, const std::string &client_fname, int sock, const std::string &boundary, size_t inputsize)=0
Handle a file upload from a multipart/form-data file upload part.
Multi-valued parameter.
Definition http.h:198
Single-valued parameter.
Definition http.h:192
Base interface for GET or POST parameters.
Definition http.h:178
virtual void parse(const std::string &str)=0
Parse the value of this parameter from the given unescaped string value.
Parse and store HTTP query parameters.
Definition http.h:293
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 conf_fname_blacklist
String containing blacklist characters that are replaced with "_" in the file name.
Definition http.h:335
size_t conf_max_input_size
Maximum size of POST input data.
Definition http.h:298
bool conf_accept_unknown_fields
Whether to accept unknown fields.
Definition http.h:310
std::map< std::string, FileParam * > files
File parameters.
Definition http.h:295
std::string conf_outdir
Directory where we write uploaded files.
Definition http.h:326
bool conf_accept_unknown_file_fields
Whether to accept unknown file upload fields.
Definition http.h:319
std::string server_name
Definition http.h:76
std::string peer_hostname
Definition http.h:73
std::string query_string
Definition http.h:80
std::map< std::string, std::string > headers
Definition http.h:89
std::string method
Definition http.h:86
std::string version
Definition http.h:88
std::string url
Definition http.h:87
wibble::net::mime::Reader mime_reader
Definition http.h:92
std::string path_info
Definition http.h:79
bool response_started
true if some response has already been sent to the client
Definition http.h:84
std::string server_port
Definition http.h:77
std::map< std::string, std::string > extra_response_headers
Definition http.h:94
std::string server_software
String to use as server software "NAME/version".
Definition http.h:82
std::string script_name
Definition http.h:78
wibble::Splitter space_splitter
Definition http.h:90
int sock
Definition http.h:72
std::string peer_port
Definition http.h:75
std::string peer_hostaddr
Definition http.h:74
error400(const std::string &msg)
Definition http.h:57
error400()
Definition http.h:56
error404(const std::string &msg)
Definition http.h:63
error404()
Definition http.h:62
error(int code, const std::string &desc, const std::string &msg)
Definition http.h:45
std::string msg
Definition http.h:41
error(int code, const std::string &desc)
Definition http.h:43
virtual void send(Request &req)
Definition http.cpp:44
int code
Definition http.h:39
std::string desc
Definition http.h:40
virtual const char * what() const
Definition http.cpp:38
virtual ~error()
Definition http.h:47