Skip to content

Instantly share code, notes, and snippets.

@ijat
Created September 4, 2020 10:48
Show Gist options
  • Save ijat/842b97dffc03ceb106c6af159a61b87f to your computer and use it in GitHub Desktop.
Save ijat/842b97dffc03ceb106c6af159a61b87f to your computer and use it in GitHub Desktop.
Test winhttpopen
#include <iostream>
#include <string>
#include <Windows.h>
#include <winhttp.h>
#pragma comment(lib, "winhttp.lib")
int main() {
DWORD data;
DWORD dwSize = sizeof(DWORD);
// Use WinHttpOpen to obtain an HINTERNET handle.
HINTERNET hSession = WinHttpOpen(L"privacyidea-cp",
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0);
if (hSession)
{
// Use WinHttpQueryOption to retrieve internet options.
if (WinHttpQueryOption(hSession,
WINHTTP_OPTION_CONNECT_TIMEOUT,
&data, &dwSize))
{
printf("Connection timeout: %u ms\n\n", data);
}
else
{
printf("Error %u in WinHttpQueryOption.\n",
GetLastError());
}
// When finished, release the HINTERNET handle.
WinHttpCloseHandle(hSession);
}
else
{
printf("Error %u in WinHttpOpen.\n", GetLastError());
}
std::string lol;
std::cin >> lol;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment