发送请求出错
帮我看看程序吧!
CInternetSession m_InetSession(_T("session"),
0,
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
INTERNET_FLAG_DONT_CACHE); //不进行缓冲
CHttpConnection* pServer = NULL;
CHttpFile* pFile = NULL;
CString strHtml = "";
CString strRequest = "GET /getimage HTTP/1.0\r\n"
"Connection: keep-alive\r\n"
"Authorization: Basic YWRtaW46MTIzNA==\r\n\r\n";//向所访问的地址提交的数据
CString strHeaders = "GET /getimage HTTP/1.0\r\n"
"Connection: keep-alive\r\n";
try{
INTERNET_PORT nPort=80; //端口号CString strRequest = "GET /getimage HTTP/1.0\r\n" "Connection: keep-alive\r\n" "Authorization: Basic YWRtaW46MTIzNA==\r\n\r\n"; //the request string
pServer = m_InetSession.GetHttpConnection("192.168.0.1", nPort);
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"/");
pFile->AddRequestHeaders(strHeaders);
pFile->SendRequestEx(strRequest.GetLength());
pFile->WriteString(strRequest);
pFile->EndRequest();
DWORD dwRet;
pFile->QueryInfoStatusCode(dwRet);
if (dwRet == HTTP_STATUS_OK)
{
CString strLine;
int nRead;
while ((nRead = pFile->ReadString(strLine))>0)
{
strHtml += strLine;
}
}
delete pFile;
delete pServer;
到SendRequestEx就不过了,报错Warning: throwing CInternetException for error 12002
First-chance exception in mytest.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
高手们指点小妹一下啊,谢了