首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

MFC模拟网站登录 报A connection with the server could not be established,该怎么解决

2013-01-25 
MFC模拟网站登录 报A connection with the server could not be established本帖最后由 VisualEleven 于 2

MFC模拟网站登录 报A connection with the server could not be established
本帖最后由 VisualEleven 于 2012-11-07 17:07:14 编辑 主要代码

CInternetSession session2;
CHttpConnection *pSever2 = NULL;
CHttpFile * pFile2 = NULL;
//CString m_strCookies;
//if(!session2.GetCookie("https://passport.5173.com/?returnUrl=http://www.5173.com",_T("temp"),m_strCookies)) 
//{ 
//MessageBox("获取Cookies时出错!"); 
//return; 
//} 
//MessageBox(m_strCookies);
pSever2 = session2.GetHttpConnection("https://passport.5173.com/?returnUrl=http://www.5173.com",nPort);


pFile2 = pSever2->OpenRequest("POST","https://passport.5173.com/?returnUrl=http://www.5173.com",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);

pFile2->AddRequestHeaders("x-requested-with: XMLHttpRequest\r\n");
pFile2->AddRequestHeaders("Accept-Language:zh-CN\r\n");
pFile2->AddRequestHeaders("Referer:https://passport.5173.com/?returnUrl=http://www.5173.com\r\n");
pFile2->AddRequestHeaders("Accept: */*\r\n");
pFile2->AddRequestHeaders("Content-Type:application/x-www-form-urlencoded\r\n");
pFile2->AddRequestHeaders("Accept-Encoding: gzip, deflate\r\n");
pFile2->AddRequestHeaders("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E)\r\n");
pFile2->AddRequestHeaders("Host:passport.5173.com\r\n");
pFile2->AddRequestHeaders("Connection:Keep-Alive\r\n");
pFile2->AddRequestHeaders("Cache-Control: no-cache\r\n");
pFile2 ->SendRequest(NULL, 0, pushData.GetBuffer(0), pushData.GetLength());
DWORD dbRet;
pFile2 ->QueryInfoStatusCode(dbRet);

if(dbRet == HTTP_STATUS_DENIED)
{
MessageBox("操作被拒绝");
}
httpHead ="";
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF,httpHead);
MessageBox(httpHead);
报A connection with the server could not be established 这是什么原因啊 
[解决办法]
自己抓个包比对一下,看看是不是数据发的不对。
[解决办法]
网络是否连通,可以抓包等分析一下

热点排行