1 #ifndef WIBBLE_NET_HTTP_H
2 #define WIBBLE_NET_HTTP_H
37 struct error :
public std::exception
44 : code(code), desc(desc) {}
46 : code(code), desc(desc), msg(msg) {}
49 virtual const char*
what()
const throw ();
57 error400(
const std::string&
msg) : error(400,
"Bad request", msg) {}
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);