📄 chttpreq.h
字号:
/*******************************************************************
* cHttpreq.h
* DESCRIPTION:浏览器请求处理类
*
* AUTHOR:yyc
*
* HISTORY:
*
* DATE:2002-8-22
*
*******************************************************************/
#ifndef __CHTTPREQ_H__
#define __CHTTPREQ_H__
#include "cBuffer.h"
#include <string>
#include <map>
namespace yyc
{
class cHttpreq
{
private:
std::map<std::string,std::string> m_req_paras;//保存请求的参数-值对的map映射
int m_iReqlen;//post请求的数据长度
int m_iRecvlen;//已接收的数据长度
cBuffer m_buf;//缓存未处理完的post请求参数数据
public:
char m_strMethod[6]; //GET或POST方法
char m_strUrl[255];//请求的地址
//将16进制字符转化未十进制数字
static int hextoi(char c);
/**
* 浏览器请求的编码数据的解码
* 浏览器将中文和一些特殊字符进行编码后在以字符串形式发送
* 编码方式为:%(HEX),即将字节转化为十六进制的字符串,前面加一个%号
*
* @param str 要解码的字符串
* 解码后的数据将改写此字符串的内容
*
* @return 解码后字符串的引用
*/
static char * decode_char(char *str);
static char * decode_char(char *str,int len);
cHttpreq(){
memset((void *)m_strUrl,0,6);
memset((void *)m_strMethod,0,255);
m_iReqlen=-1;
m_iRecvlen=0;
}
~cHttpreq(){
}
//根据浏览器请求的参数名获取其值
const char *get_para(const char *para_name);
int do_reqdata(char *buf,int len);
//http请求数据是否接收完
bool is_end();
//显示HTTPREQ对象的内容
void dump();
};
//根据浏览器请求的参数名获取其值
inline const char *cHttpreq::get_para(const char *para_name)
{
if(m_req_paras.count(para_name)>=1)
{
return m_req_paras[para_name].c_str();
}
else
return NULL;
}
//http请求数据是否接收完
inline bool cHttpreq::is_end()
{
return m_iRecvlen>=m_iReqlen;
}
}//?namespace yyc
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -