网站建设的感想,登录手机wordpress,seo推广优化服务,品牌设计公司深圳一、模块设计思路
存储HTTP应答要素#xff0c;提供简单接口
二、成员变量
int _status; // 应答状态码
unordered_mapstring, string _headers; // 报头字段
string _body; // 应答正文
bool _redirect_flag; // 是否重定向信息
stri…一、模块设计思路
存储HTTP应答要素提供简单接口
二、成员变量
int _status; // 应答状态码
unordered_mapstring, string _headers; // 报头字段
string _body; // 应答正文
bool _redirect_flag; // 是否重定向信息
string _redirect_url; // 重定向路径
三、成员函数
1、构造函数
应答状态码200默认不重定向
2、清空数据 void ReSet()
清空成员变量里面所有数据
3、添加报头字段 void SetHeader(const string key, const string val)
哈希表添加键值对
4、查询报头字段 bool HasHeader(const string key) const
哈希表查询
5、获取报头字段 string GetHeader(const string key) const
查询并返回 val
6、设置重定向 void SetRedirect(const string url, int status 302)
重定向标志位改变设置重定向路径设置应答状态码默认302暂时重定向
7、设置应答正文 void SetContent(const string body, string type)
设置应答正文并设置报头字段 Content-Type
8、是否是长短连接 bool Close() const
只有报头字段 Connection 是 keep-alive 才是长连接其他全是短连接
四、代码展示