This snippet shows how you can get the headers for an URL, for example to detect a redirect. I had to use the ANSI functions to ensure correctly returned headers. Manual entry for [HttpQueryInfo](http://msdn.microsoft.com/en-us/library/windows/desktop/aa385373(v=vs.85).aspx). Let me know if you have any questions/remarks.

Member Avatar
Member Avatar
+1 forum 1

I have the following code: const AGENT = 'User Agent'; SERVER = 'www.daniweb.com'; RESOURCE = 'api/access_token'; ID = ''; // my client id SECRET = ''; // my client secret CODE = ''; // my returned code, pasted from the browser REDIRECT_URI = ''; // my redirect uri ACCEPT: packed array [0..1] of LPWSTR = (PChar('*/*'), nil); HEADER = 'Content-Type: application/x-www-form-urlencoded'; DATA: UTF8String = 'code=' + CODE + '&client_id=' + ID + '&client_secret=' + SECRET + '&redirect_uri=' + REDIRECT_URI; function GetUrl: string; var hHttp, hInet, hRequest: HINTERNET; i, bufferLen: Cardinal; buffer: array [0..1023] of AnsiChar; begin hInet := InternetOpen(PChar(AGENT), INTERNET_OPEN_TYPE_PRECONFIG, …

Member Avatar
Member Avatar
+0 forum 2

Hi All, Can any one tell me the what are the differences between WinSock and WinInet in mfc? Thanks in advance.......

Member Avatar
Member Avatar
+0 forum 1

Hi, I have asked StackOverflow, compared my code to multiple different online sources, but I still cannot get the page status from the server. The library I am using is Wininet, and the function failing to retrieve the correct data is HttpQueryInfo. I am linking against wininet. Code: [CODE] int statusCode; DWORD statCharLen = 128; char statChar[statCharLen]; //Check existance of page (for 404 error) if(!HttpQueryInfo(hRequestHandle, HTTP_QUERY_STATUS_CODE, &statChar, &statCharLen, NULL)) return 4; statusCode = atoi(statChar); if(statusCode == 404) cout << "We got a 404 error" << endl; cout << "Stat code text : " << statChar << endl; cout << "Stat …

Member Avatar
Member Avatar
+0 forum 1

The End.