return true;
}
- bool matchedIfNoneMatch = false;
if (r.header.has(HDR_IF_NONE_MATCH)) {
- if (!e->hasIfNoneMatchEtag(r)) {
- // RFC 2616: ignore IMS if If-None-Match did not match
- r.flags.ims = 0;
- r.ims = -1;
- r.imslen = 0;
- r.header.delById(HDR_IF_MODIFIED_SINCE);
- http->logType = LOG_TCP_MISS;
- sendMoreData(result);
- return true;
- }
+ // RFC 7232: If-None-Match recipient MUST ignore IMS
+ r.flags.ims = false;
+ r.ims = -1;
+ r.imslen = 0;
+ r.header.delById(HDR_IF_MODIFIED_SINCE);
- if (!r.flags.ims) {
- // RFC 2616: if If-None-Match matched and there is no IMS,
- // reply with 304 Not Modified or 412 Precondition Failed
+ if (e->hasIfNoneMatchEtag(r)) {
sendNotModifiedOrPreconditionFailedError();
return true;
}
- // otherwise check IMS below to decide if we reply with 304 or 412
- matchedIfNoneMatch = true;
+ // None-Match is true (no ETag matched); treat as an unconditional hit
+ return false;
}
if (r.flags.ims) {
// handle If-Modified-Since requests from the client
if (e->modifiedSince(&r)) {
- http->logType = LOG_TCP_IMS_HIT;
- sendMoreData(result);
-
- } else if (matchedIfNoneMatch) {
- // If-None-Match matched, reply with 304 Not Modified or
- // 412 Precondition Failed
- sendNotModifiedOrPreconditionFailedError();
+ // Modified-Since is true; treat as an unconditional hit
+ return false;
} else {
// otherwise reply with 304 Not Modified
StoreEntry *e = http->storeEntry();
const time_t timestamp = e->timestamp;
HttpReply *const temprep = e->getReply()->make304();
- http->logType = LOG_TCP_IMS_HIT;
+ // log as TCP_INM_HIT if code 304 generated for
+ // If-None-Match request
+ if (!http->request->flags.ims)
+ http->logType = LOG_TCP_INM_HIT;
+ else
+ http->logType = LOG_TCP_IMS_HIT;
removeClientStoreReference(&sc, http);
createStoreEntry(http->request->method, request_flags());
e = http->storeEntry();