-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpConn.h
More file actions
54 lines (38 loc) · 947 Bytes
/
Copy pathHttpConn.h
File metadata and controls
54 lines (38 loc) · 947 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
#ifndef HTTPSERVER_HTTPCONN_H
#define HTTPSERVER_HTTPCONN_H
#include "Buffer.h"
#include "HttpRequest.h"
#include "HttpResponse.h"
#include "ConnectionPool.h"
#include <netinet/in.h>
class HttpConn {
public:
void init(int fd, struct sockaddr_in addr);
void reset();
bool sendMsg();
ssize_t recvMsg();
void process();
void doRequest();
void closeConn();
int getFd();
void setFd(int fd);
int getBytesToSend() const;
bool isWriting() const;
void initResponse(ConnectionPool* connPool, char* docRoot);
static int epollFd;
private:
int fd_;
struct sockaddr_in addr_;
Buffer inputBuf_;
Buffer outputBuf_;
// 协议解析相关
HttpRequest httpRequest_;
HttpResponse httpResponse_;
// 文件相关
char* fileAddress_;
struct iovec iv_[2];
int ivCount_;
size_t bytesToSend_;
size_t bytesHaveSend_;
};
#endif // HTTPSERVER_HTTPCONN_H