I have a problem with this code:
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
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