I am working on a program that needs to check the existence of a page before it loads (so nothing too exotic).
Everything is working OK, but I cannot get HttpQueryInfo to return a valid status code for a page. The status code returned is: 1875378224
Code producing the problem:
DWORD headerBuffSize = sizeof(DWORD);
DWORD statusCode;
//Check existance of page (for 404 error)
if(!HttpQueryInfo(hRequestHandle,
HTTP_QUERY_STATUS_CODE,
&statusCode,
&headerBuffSize,
NULL))
return 4;
if(statusCode == HTTP_STATUS_NOT_FOUND)
cout << "We got a 404 error" << endl;
cout << "Got Status code: " << statusCode << endl; //1875378224 everywhere
cout << "404 status code: " << HTTP_STATUS_NOT_FOUND << endl; //What it should be getting
I am not sure what to make of it; I have compared my own code to several examples online, and it looks like it should work, although I may have just made a stupid mistake.
Thanks!
The information retrieved from the response header by HttpQueryInfo
is always a text string.
int statusCode;
char responseText[256]; // change to wchar_t for unicode
DWORD responseTextSize = sizeof(responseText);
//Check existance of page (for 404 error)
if(!HttpQueryInfo(hRequestHandle,
HTTP_QUERY_STATUS_CODE,
&responseText,
&responseTextSize,
NULL))
return 4;
statusCode = atoi(responseText);