Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to force HttpQueryInfo to get "304 Not Modified" status code?

Status
Not open for further replies.

humanista

Programmer
Oct 8, 2006
2
PL
I have a problem with this code:

Code:
void *hInternet, *hConnect, *hRequest; 
unsigned char status_code[4], *lpBuffer; 
unsigned int dwBufferLength, dwBufferTotal, dwNumberOfBytesRead; 
hInternet = InternetOpen(0, INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0); 
hConnect = InternetConnect(hInternet, "foobar2000.org", 80, 0, 0, INTERNET_SERVICE_HTTP, 0, 0); 
hRequest = HttpOpenRequest(hConnect, 0, 0, 0, 0, 0, 0, 0); 
HttpSendRequest(hRequest, 0, 0, 0, 0); 
dwBufferLength = 4; 
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE, status_code, &dwBufferLength, 0); 
lpBuffer = malloc(10240); 
InternetReadFile(hRequest, lpBuffer, 10240, &dwNumberOfBytesRead); 
for(dwBufferTotal = dwNumberOfBytesRead; dwNumberOfBytesRead != 0; dwBufferTotal += dwNumberOfBytesRead) 
{ 
         InternetReadFile(hRequest, lpBuffer + dwBufferTotal, 10240 - dwBufferTotal, &dwNumberOfBytesRead); 
}
free(lpBuffer);
InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
return;

After executing it twice, server responds with "304 Not Modified" status code, but wininet loads response from cache and HttpQueryInfo gets "200 OK". How can I force HttpQueryInfo to get real "304 Not Modified" status code?

Thanks
 
Then server will responds with "200 OK" status code and that's not what I want. I want it to responds with "304 Not Modified" status code and I want HttpQueryInfo to show me this "304 Not Modified".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top