2019-07-28 10:31:56 +08:00
|
|
|
|
#include "stdafx.h"
|
2018-11-30 14:38:22 +08:00
|
|
|
|
|
|
|
|
|
class http_servlet : public acl::HttpServlet
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
http_servlet(acl::socket_stream* stream, acl::session* session)
|
2021-08-19 21:45:41 +08:00
|
|
|
|
: HttpServlet(stream, session), i_(0)
|
2018-11-30 14:38:22 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~http_servlet(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override
|
|
|
|
|
bool doGet(acl::HttpServletRequest& req, acl::HttpServletResponse& res)
|
|
|
|
|
{
|
|
|
|
|
return doPost(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override
|
|
|
|
|
bool doPost(acl::HttpServletRequest&, acl::HttpServletResponse& res)
|
|
|
|
|
{
|
2021-08-22 23:15:38 +08:00
|
|
|
|
static int __n = 0;
|
2021-08-19 21:45:41 +08:00
|
|
|
|
acl::string buf;
|
2021-08-22 23:15:38 +08:00
|
|
|
|
buf.format("hello world-%d, total=%d", i_++, __n++);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
|
2021-08-19 21:45:41 +08:00
|
|
|
|
res.setContentLength(buf.size());
|
2018-11-30 14:38:22 +08:00
|
|
|
|
res.setKeepAlive(true);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD> http <20><>Ӧ<EFBFBD><D3A6>
|
2021-08-19 21:45:41 +08:00
|
|
|
|
return res.write(buf) && res.write(NULL, 0);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
}
|
2021-08-19 21:45:41 +08:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int i_;
|
2018-11-30 14:38:22 +08:00
|
|
|
|
};
|