-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.h
More file actions
59 lines (49 loc) · 1.03 KB
/
Copy pathHandler.h
File metadata and controls
59 lines (49 loc) · 1.03 KB
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
59
#pragma once
#include <memory>
#include <iostream>
//#include "hiredis/hiredis.h"
#include "ThreadPool.h"
#include "sys/socket.h"
#include "sys/epoll.h"
#include "unistd.h"
#include "stdlib.h"
#include "string.h"
#include "fcntl.h"
#include "Server.h"
#include "Log.h"
#include "http/HttpRequest.h"
#include "http/HttpResponse.h"
#include "Server.h"
using namespace std;
enum HandlerState {READ, WRITE};
class Server;
class HttpRequest;
class HttpResponse;
class Handler : public ThreadPoolTask{
public:
Handler(){
http_request = NULL;
http_response = NULL;
}
~Handler(){
delete http_response;
delete http_request;
}
//IO相关方法
void bind(int sockfd);
void debind();
void read();
void write();
//调用方法
void run();
private:
//处理http响应需要的类
HttpRequest* http_request;
HttpResponse* http_response;
//私有资源
int sockfd;
HandlerState state;
string read_buffer;
string write_buffer;
int write_index;
};