1 Star 0 Fork 0

万象qq/Linux

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
request_test.cc 1.77 KB
Copy Edit Raw Blame History
万象qq authored 2025-11-28 21:35 +08:00 . request模块测试
#include"../Request.hpp"
#include<iostream>
void test()
{
//设置对应请求头的内容
Request req;
req.SetHeader("Host","www.baidu.com");
req.SetHeader("Content-Length","50");
//获得存在的请求头的内容
std::cout<<"Host对应的请求头的详细内容是:"<<req.GetHeader("Host")<<std::endl;
//获得不存在的请求头的内容
std::cout<<"Cookie对应的请求头的详细内容是"<<req.GetHeader("Cookie")<<std::endl;
//判断请求头内容是否在里面
bool flag=req.IsSetHeader("Host");
if(flag)
{
std::cout<<"Host请求头在里面"<<std::endl;
}
else
{
std::cout<<"Host请求头不在里面"<<std::endl;
}
flag=req.IsSetHeader("Cookie");
if(flag)
{
std::cout<<"Cookie请求头在里面"<<std::endl;
}
else
{
std::cout<<"Cookie请求头不在里面"<<std::endl;
}
//设置对应请求体的内容
req.SetParams("username","vientiane");
req.SetParams("password","123456");
//获得存在的请求体的内容
std::cout<<"Host对应的请求体的详细内容是:"<<req.GetParams("username")<<std::endl;
//获得不存在的请求体的内容
std::cout<<"Cookie对应的请求体的详细内容是"<<req.GetHeader("Cookie")<<std::endl;
//判断请求头内容是否在里面
flag=req.IsSetParams("username");
if(flag)
{
std::cout<<"username请求体在里面"<<std::endl;
}
else
{
std::cout<<"username请求体不在里面"<<std::endl;
}
flag=req.IsSetParams("Cookie");
if(flag)
{
std::cout<<"Cookie请求体在里面"<<std::endl;
}
else
{
std::cout<<"Cookie请求体不在里面"<<std::endl;
}
}
int main()
{
test();
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/wanxiang-qq/linux.git
git@gitee.com:wanxiang-qq/linux.git
wanxiang-qq
linux
Linux
master

Search