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.
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 code num : " << statusCode << endl; cout << "404 status code: " << HTTP_STATUS_NOT_FOUND << endl;
The problem is I am not able to retrieve a status code; the query simply returns a 1 byte char array containing "0". I am not sure what to make of this (by the way, this code was semi-influenced by one of the stackoverflow answers, but still does not work).
Thanks for your help!
If I was unclear about anything comment and I'll fix it.