0
我試圖通過代理使用WinINet連接到HTTPS服務。我的代碼如下所示:如何使用WinINet通過代理連接到HTTPS
hInternet = InternetOpenW(L"Test", INTERNET_OPEN_TYPE_PROXY,L"PROXY_IP:PROXY_PORT", L"<local>", 0);
if (hInternet == NULL)
{
printf("InternetOpenW failed! Error code: %d\n", GetLastError());
}
else
{
HINTERNET hConnect = InternetConnectW(hInternet, L"HTTPS_SERVICE_IP", 443, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if (hConnect == NULL)
{
printf("InternetConnectW failed! Error code: %d\n", GetLastError());
}
else
{
HINTERNET hRequest = HttpOpenRequestW(hConnect, NULL, L"", NULL, NULL, NULL, 0, 0);
if (hRequest == NULL)
{
printf("HttpOpenRequestW failed! Error code: %d\n", GetLastError());
}
else
{
BOOL bRequestSent = HttpSendRequestW(hRequest, NULL, 0, NULL, 0);
if (!bRequestSent)
{
printf("HttpSendRequestW failed! Error code: %d\n", GetLastError());
}
else
{
printf("Connection ok!\n");
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hConnect);
}
InternetCloseHandle(hInternet);
}
它將GET請求發送到代理,執行ntml身份驗證,但連接失敗。代理期望客戶端發送CONNECT請求。如何發送CONNECT方法與該代碼?