无论我用WAP连接还是NET连接到GPRS之后,用下面的代码获取http://www.baidu.com的网页内容都是一样的:
void HttpDownloadFile()
{
CString filePath;
GetAppPath(filePath);
filePath.Append(_T("http.html"));
CInternetSession inetSess;
CHttpFile *httpFile = NULL;
PrintLog("In HttpDownloadFile()");
try
{
httpFile = (CHttpFile *)inetSess.OpenURL(m_strUrl, 1, INTERNET_FLAG_TRANSFER_BINARY);
//httpFile = (CHttpFile *)inetSess.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE);
}
catch (CInternetException *e)
{
if(httpFile)
{
PrintLog("httpFile Not NULL");
}
PrintLog("HttpDownloadFile httpFile NULL");
TRACE(_T("---InternetException in HttpDownloadFile---\n"));
HttpExceptionHandle(e);
e->Delete();
inetSess.Close();
delete httpFile;
if(m_observer)
{
m_observer->OnFailed();
}
return -1;
}
CFile file;
file.Open(filePath, CFile::modeCreate | CFile::modeWrite);
unsigned char buf[RW_BLOCK_SIZE];
memset(buf, 0, sizeof(buf));
int rLen = 0;
int iSize = 0;
while((rLen = httpFile->Read(buf, RW_BLOCK_SIZE))>0)
{
file.Write(buf, rLen);
memset(buf, 0, sizeof(buf));
iSize +=rLen;
}
file.Close();
delete httpFile;
inetSess.Close();
if(m_observer)
{
PrintLog("GprsTest finished!");
m_observer->OnSucceeded(iSize);
}
return 0;
}
每次都是这样的内容:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
<meta http-equiv="Cache-Control" content="no-cache" forua="true"/>
<meta http-equiv="Cache-Control" content="must-revalidate" forua="true"/>
</head>
<card id="card" title="" >
<onevent type="onenterforward">
<go href="http://www.baidu.com/?t=19654"> </go> </onevent>
</card>
</wml>
我马上调用第2次HttpDownloadFile(),得到的结果也是上面的网关提示,有没有人遇到过这种情况?