18,356
社区成员
发帖
与我相关
我的任务
分享
m_E1 = "http://www.126.com/";
m_E2 = "e:\\1.htm";
//////////////////////////////////////////////////////////////////////////
AfxParseURL(LPCTSTR(m_E1), dwServiceType, strServer, strObject, nPort);
try
{
if (pServer = session.GetHttpConnection(LPCTSTR(strServer), nPort))
{
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
}
if (pFile != NULL)
{
CString strRetHeader = "";
if(pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strRetHeader))
{
MessageBox(strRetHeader);
}
}
}
CInternetSession sess;//Create session
CHttpFile* pFile;
//////////////////////////////////////////////
CHttpConnection *pServer = sess.GetHttpConnection(strServer, nPort);
if(pServer == NULL)
{
strDescript = "对不起,连接服务器失败!";
return false;
}
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strObject,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);
if(pFile == NULL)
{
strDescript = "找不到网络地址" + strUrl;
return false;
}
pFile -> AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
pFile -> AddRequestHeaders("Accept: */*");
pFile -> SendRequest(NULL,0,(LPTSTR)(LPCTSTR)strPara, strPara.GetLength()); //strPara是登录的参数,如username=abcdef&password=123456
CString strSentence;
DWORD dwStatus;
DWORD dwBuffLen = sizeof(dwStatus);
BOOL bSuccess = pFile->QueryInfo(
HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
&dwStatus, &dwBuffLen);