2019-07-27 22:44:32 +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)
|
|
|
|
|
: HttpServlet(stream, session)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~http_servlet(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override
|
|
|
|
|
bool doGet(acl::HttpServletRequest& req, acl::HttpServletResponse& res)
|
|
|
|
|
{
|
|
|
|
|
return doPost(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override
|
|
|
|
|
bool doPost(acl::HttpServletRequest&, acl::HttpServletResponse& res)
|
|
|
|
|
{
|
|
|
|
|
const char* buf = "hello world!";
|
|
|
|
|
size_t len = strlen(buf);
|
|
|
|
|
|
|
|
|
|
res.setContentLength(len);
|
|
|
|
|
res.setKeepAlive(true);
|
|
|
|
|
|
2019-07-27 22:44:32 +08:00
|
|
|
|
// 发送 http 响应体
|
2018-11-30 14:38:22 +08:00
|
|
|
|
return res.write(buf, len) && res.write(NULL, 0);
|
|
|
|
|
}
|
|
|
|
|
};
|