1,105,334 Community Members

HttpQueryInfo returning Bad Status Info

Member Avatar
dylank
Junior Poster in Training
66 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

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:

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.

Member Avatar
dylank
Junior Poster in Training
66 posts since Oct 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

So, no one?
This seems like a difficult question, or maybe I just worded it wrong, but its been a week now and SO hasn't been able to answer it either.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: