当我访问这样的 URL 时:http://www.misslee.net/_common/inc/mi3dark_down.asp 它让我返回真实的 URL => http://125.141.146.184:8080/download/SetupMisslee_Dark.exe
我想我被重定向了..我想知道重定向的 URL。请帮我。 如何从HINTERNET获取响应url?
TCHAR szServerName[] = _T("www.misslee.net");
TCHAR szFormAction[] = _T("/_common/inc/mi3dark_down.asp");
TCHAR szHeader[500] = {0,};
LPCWSTR accept[2]={_T("*/*"), NULL};
DWORD_PTR dwContext=1;
BOOL bResult;
DWORD dwSize;
HINTERNET hInternet = InternetOpen( _T("HTTP-POST"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
HINTERNET hConnect = InternetConnect( hInternet, szServerName, INTERNET_DEFAULT_HTTP_PORT, NULL, _T("HTTP/1.1"), INTERNET_SERVICE_HTTP, 0, dwContext);
HINTERNET hRequest = HttpOpenRequest( hConnect, _T("POST"), szFormAction, _T("HTTP/1.1"), NULL, accept,INTERNET_FLAG_DONT_CACHE, dwContext);
bResult = HttpSendRequest( hRequest, NULL, 0, NULL, NULL);
// Redirected response url???????????
最佳答案
将 InternetQueryOption
与 INTERNET_OPTION_URL
一起使用标志。
INTERNET_OPTION_URL
Retrieves a string value that contains the full URL of a downloaded resource. If the original URL contained any extra data, such as search strings or anchors, or if the call was redirected, the URL returned differs from the original. This option is valid on HINTERNET handles returned by InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest. It is used by InternetQueryOption.
关于c++ - 如何从 HINTERNET 获取响应 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8642781/