当返回数据含有跳转地址时,取出Location: 地址,并通过AfxParseURL解析出服务器地址。
pHttpFile->QueryInfoStatusCode(dwStatusCode);
if (dwStatusCode > 300 && dwStatusCode <= 306) {
CString strNewLocation;
pHttpFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF, strNewLocation);
int nPlace = strNewLocation.Find(_T("Location: "));
if (nPlace == -1)
{
goto exit;
}
strNewLocation = strNewLocation.Mid(nPlace + 10);
nPlace = strNewLocation.Find('\n');
if (nPlace > 0)
{
strNewLocation = strNewLocation.Left(nPlace);
}
DWORD dwServiceType;
CString strServer;
CString strObject;
INTERNET_PORT nPort;
AfxParseURL(strNewLocation, dwServiceType, strServer, strObject, nPort);
strRev = strServer;
goto exit;
}