用CHttpFile实现简单的GET/POST数据【转】
2016-06-28 17:47
435 查看
一、GET 数据,下载网页,文件等,用于可下载的文件,不能用于服务端运行的程序,比如.aspx文件等,否则会返回500错误。
CString strSentence, strWriteName="1.htm";
CString strFileName="http://localhost/InDesign/" + strWriteName;
CInternetSession sess;
CHttpFile* fileGet;
try
catch(CException* e)
if(fileGet)
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
二、POST 数据,比如用于提交注册信息等
CString strHttpName="http://localhost/TestReg/RegForm.aspx"; // 需要提交数据的页面
CString strFormData = "username=abc&password=123"; // 需要提交的数据
CInternetSession sess;
CHttpFile* fileGet;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头
try
catch(CException* e)
CString strSentence, strGetSentence = "";
if(fileGet)
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
CString strSentence, strWriteName="1.htm";
CString strFileName="http://localhost/InDesign/" + strWriteName;
CInternetSession sess;
CHttpFile* fileGet;
try
catch(CException* e)
if(fileGet)
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
二、POST 数据,比如用于提交注册信息等
CString strHttpName="http://localhost/TestReg/RegForm.aspx"; // 需要提交数据的页面
CString strFormData = "username=abc&password=123"; // 需要提交的数据
CInternetSession sess;
CHttpFile* fileGet;
CString strHeaders = _T("Content-Type: application/x-www-form-urlencoded"); // 请求头
try
catch(CException* e)
CString strSentence, strGetSentence = "";
if(fileGet)
else
AfxMessageBox("不能找到网页文件!");
sess.Close();
相关文章推荐
- http://www.douco.com/help
- tcpdump非常实用的抓包实例
- TCP之文件传输
- 卷积神经网络反向BP算法公式推导
- http url转义字符,特殊字符
- OkHttp使用(三)文件上传
- 网络字节序转换
- http://www.cnblogs.com/linjiqin/archive/2013/05/27/3101694.html
- 验证视图状态 MAC 失败。如果此应用程序由网络场或群集承载,请确保<machineKey>配置指定了相同的 validationKey 和验证算法。不能在群集中使用 AutoGenerate。
- http_ui查询接口配置
- 企业级日志收集系统——ELKstack 推荐
- 计算机网络基础知识
- c# tcp socket 通信
- HttpClient,DefaultHttpClient使用详解
- NodeJS 创建TCP服务器 客户端
- NodeJS 创建TCP服务器
- apache配置文件:http.conf配置详解
- 配置Tomcat使用https协议
- linux:Nginx+https双向验证(数字安全证书)
- nginx配置ssl双向验证 nginx https ssl证书配置