2019-07-28 10:31:56 +08:00
|
|
|
#pragma once
|
2016-02-05 10:10:24 +08:00
|
|
|
|
|
|
|
class http_servlet : public acl::HttpServlet
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
http_servlet(acl::socket_stream* stream, acl::session* session);
|
2019-07-08 22:08:26 +08:00
|
|
|
~http_servlet(void);
|
2016-02-05 10:10:24 +08:00
|
|
|
|
|
|
|
bool run(void);
|
|
|
|
|
|
|
|
protected:
|
2019-07-08 22:08:26 +08:00
|
|
|
// @override
|
|
|
|
bool doError(request_t&, response_t&);
|
|
|
|
|
|
|
|
// @override
|
|
|
|
bool doOther(request_t&, response_t&,
|
|
|
|
const char* method);
|
|
|
|
|
|
|
|
// @override
|
|
|
|
bool doGet(request_t&, response_t&);
|
|
|
|
|
|
|
|
// @override
|
|
|
|
bool doPost(request_t&, response_t&);
|
2016-02-05 10:10:24 +08:00
|
|
|
|
|
|
|
private:
|
2019-07-08 22:08:26 +08:00
|
|
|
typedef bool (http_servlet::*handler_t)(request_t&,response_t&);
|
|
|
|
|
|
|
|
std::map<acl::string, handler_t> handlers_;
|
|
|
|
|
|
|
|
bool doUpload(request_t&, response_t&);
|
|
|
|
bool doReply(request_t&, response_t&, const char* info);
|
2016-02-05 10:10:24 +08:00
|
|
|
void reset(void);
|
|
|
|
|
2019-07-08 22:08:26 +08:00
|
|
|
bool onPage(request_t&, response_t&);
|
|
|
|
bool onUpload(request_t&, response_t&);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool upload(request_t&, response_t&);
|
|
|
|
bool parse(request_t&, response_t&);
|
2016-02-05 10:10:24 +08:00
|
|
|
long long get_fsize(const char* dir, const char* filename);
|
|
|
|
|
|
|
|
private:
|
2019-07-08 22:08:26 +08:00
|
|
|
bool uploading_;
|
|
|
|
request_t* req_;
|
|
|
|
response_t* res_;
|
2016-02-05 10:10:24 +08:00
|
|
|
acl::ofstream fp_;
|
|
|
|
long long content_length_;
|
|
|
|
long long read_length_;
|
|
|
|
acl::http_mime* mime_;
|
|
|
|
|
|
|
|
acl::string param1_;
|
|
|
|
acl::string param2_;
|
|
|
|
acl::string param3_;
|
|
|
|
acl::string file1_;
|
|
|
|
acl::string file2_;
|
|
|
|
acl::string file3_;
|
|
|
|
long long fsize1_;
|
|
|
|
long long fsize2_;
|
|
|
|
long long fsize3_;
|
|
|
|
};
|