-
Notifications
You must be signed in to change notification settings - Fork 4
/
fcgi.h
67 lines (53 loc) · 2.16 KB
/
fcgi.h
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
60
61
62
63
64
65
66
67
/*======================================================
> File Name: fcgi.h
> Author: MiaoShuai
> E-mail:
> Other :
> Created Time: 2015年12月17日 星期四 01时14分57秒
=======================================================*/
#ifndef FCGI_
#define FCGI_
#include "fast_cgi.h"
#include <string>
class FastCgi
{
public:
FastCgi();
~FastCgi();
//设置套接字的值
//void setSockfd(){sockfd_ = startConnect();}
//设置请求Id
void setRequestId(int requestId){requestId_ = requestId;}
//生成头部
FCGI_Header makeHeader(int type,int request,
int contentLength,int paddingLength);
//生成发起请求的请求体
FCGI_BeginRequestBody makeBeginRequestBody(int role,int keepConnection);
//生成PARAMS的name-value body
bool makeNameValueBody(std::string name,int nameLen,
std::string value,int valueLen,
unsigned char *bodyBuffPtr,int *bodyLen);
//获取express_help.conf配置文件中的ip地址
std::string getIpFromConf(void);
//连接php-fpm,如果成功则返回对应的套接字描述符
void startConnect(void);
//发送开始请求记录
bool sendStartRequestRecord(void);
//向php-fpm发送name-value参数对
bool sendParams(std::string name,std::string value);
//发送结束请求记录
bool sendEndRequestRecord(void);
//只读php-fpm返回内容,读到的内容处理后期在添加
bool readFromPhp(void);
private:
//从内容中提取html文件
void getHtmlFromContent(char *content);
//找到html开始处
char *findStartHtml(char *content);
int sockfd_; //与php-fpm建立的sockfd
int requestId_; //record里的请求ID
int flag_; //用来标志当前读取内容是否为html内容
static const int PARAMS_BUFF_LEN = 1024; //环境参数buffer的大小
static const int CONTENT_BUFF_LEN = 1024;//内容buffer的大小
};
#endif