-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHTTP_Test.cpp
More file actions
58 lines (44 loc) · 1012 Bytes
/
HTTP_Test.cpp
File metadata and controls
58 lines (44 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "net/HTTP/http_server.h"
#include "net/Server.h"
#include "net/EventLoop.h"
#include "base/Logging.h"
#include "net/Util.h"
#include <string.h>
#include "net/HTTP/http_request.h"
using namespace std;
using namespace std::placeholders;
void readCallback(shared_ptr<Channel> ch)
{
int fd = ch->getFd();
char buf[10024];
int n;
n=readn(fd,buf,sizeof buf);
cout<<"receive:"<<buf<<endl<<endl;
http_request http(buf);
http.showDetail();
}
// class TestServer
// {
// public:
// TestServer(EventLoop* loop,int threadNum,int port):
// myServer_(loop,threadNum,port)
// {
// myServer_.setReadCallback(readCallback);
// }
// void start()
// {
// myServer_.start();
// }
// private:
// Server myServer_;
// };
int main()
{
EventLoop loop_;
//TestServer myServer_(&loop_,4,80);
http_server myServer_("/home/centos/web",&loop_,4,80);
myServer_.start();
loop_.loop();
sleep(30);
return 0;
}