bool
HttpRequest::conditional() const
{
- return flags.ims ||
+ return flags.hasIMS() ||
header.has(HDR_IF_MATCH) ||
header.has(HDR_IF_NONE_MATCH);
}
class RequestFlags {
public:
RequestFlags():
- nocache(0), ims(0), auth(0), cachable(0),
- hierarchical(0), loopdetect(false), proxy_keepalive(false), proxying_(false),
+ nocache(false), ims(false), auth_(false), cachable(false),
+ hierarchical_(false), loopdetect(false), proxy_keepalive(false), proxying_(false),
refresh_(false), redirected(false), need_validation(false),
fail_on_validation_err(false), stale_if_hit(false), nocache_hack(false), accelerated_(false),
ignore_cc(false), intercepted_(false), hostVerified_(false), spoof_client_ip(false),
isRanged_(false)
{}
- unsigned int nocache :1; ///< whether the response to this request may be READ from cache
- unsigned int ims :1;
- unsigned int auth :1;
- unsigned int cachable :1; ///< whether the response to thie request may be stored in the cache
- unsigned int hierarchical :1;
-
// When adding new flags, please update cloneAdaptationImmune() as needed.
bool resetTCP() const;
void setResetTCP();
bool loopDetect() const { return loopdetect; }
void setLoopDetect() { loopdetect = 1; }
+
+ bool hierarchical() const { return hierarchical_; }
+ void setHierarchical() { hierarchical_=true; }
+ void clearHierarchical() { hierarchical_=true; }
+
+ bool isCachable() const { return cachable; }
+ void setCachable(bool newValue=true) { cachable = newValue; }
+ void setNotCachable() { cachable = false; }
+
+ bool hasAuth() const { return auth_; }
+ void markAuth() { auth_=true; }
+
+ bool hasIMS() const { return ims; }
+ void setIMS() { ims=true; }
+ void clearIMS() { ims=false; }
+
+ bool noCache() const { return nocache; }
+ void setNocache() { nocache=true;}
private:
+ bool nocache :1; ///< whether the response to this request may be READ from cache
+ bool ims :1;
+ bool auth_ :1;
+ bool cachable :1; ///< whether the response to thie request may be stored in the cache
+ bool hierarchical_ :1;
bool loopdetect :1;
bool proxy_keepalive :1;
bool proxying_ :1; /* this should be killed, also in httpstateflags */
// if client sent IMS
- if (http->request->flags.ims && !old_entry->modifiedSince(http->request)) {
+ if (http->request->flags.hasIMS() && !old_entry->modifiedSince(http->request)) {
// forward the 304 from origin
debugs(88, 3, "handleIMSReply: origin replied 304, revalidating existing entry and forwarding 304 to client");
sendClientUpstreamResponse();
*/
http->logType = LOG_TCP_MISS;
processMiss();
- } else if (r->flags.nocache) {
+ } else if (r->flags.noCache()) {
/*
* This did not match a refresh pattern that overrides no-cache
* we should honour the client no-cache header.
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.flags.clearIMS();
r.ims = -1;
r.imslen = 0;
r.header.delById(HDR_IF_MODIFIED_SINCE);
return;
}
- if (!r.flags.ims) {
+ if (!r.flags.hasIMS()) {
// RFC 2616: if If-None-Match matched and there is no IMS,
// reply with 304 Not Modified or 412 Precondition Failed
sendNotModifiedOrPreconditionFailedError();
matchedIfNoneMatch = true;
}
- if (r.flags.ims) {
+ if (r.flags.hasIMS()) {
// handle If-Modified-Since requests from the client
if (e->modifiedSince(&r)) {
http->logType = LOG_TCP_IMS_HIT;
{
HttpRequest *r = http->request;
- if (r->flags.cachable || r->flags.isInternal()) {
+ if (r->flags.isCachable() || r->flags.isInternal()) {
lookingforstore = 5;
StoreEntry::getPublicByRequest (this, r);
} else {
/** \li If the request has no-cache flag set or some no_cache HACK in operation we
* 'invalidate' the cached IP entries for this request ???
*/
- if (r->flags.nocache) {
+ if (r->flags.noCache()) {
#if USE_DNSHELPER
ipcacheInvalidate(r->GetHost());
return;
}
- if (r->flags.nocache) {
+ if (r->flags.noCache()) {
debugs(85, 3, "clientProcessRequest2: no-cache REFRESH MISS");
http->storeEntry(NULL);
http->logType = LOG_TCP_CLIENT_REFRESH_MISS;
// NP: it is tempting to use 'flags.nocache' but that is all about READing cache data.
// The problems here are about WRITE for new cache content, which means flags.cachable
- http->request->flags.cachable = 0; // MUST NOT cache (for now)
+ http->request->flags.setNotCachable(); // MUST NOT cache (for now)
// XXX: when we have updated the cache key to base on raw-IP + URI this cacheable limit can go.
- http->request->flags.hierarchical = 0; // MUST NOT pass to peers (for now)
+ http->request->flags.clearHierarchical(); // MUST NOT pass to peers (for now)
// XXX: when we have sorted out the best way to relay requests properly to peers this hierarchical limit can go.
http->doCallouts();
return;
* neighbors support private keys
*/
- if (request->flags.ims && !neighbors_do_private_keys)
+ if (request->flags.hasIMS() && !neighbors_do_private_keys)
return 0;
/*
* This is incorrect: authenticating requests can be sent via a hierarchy
* (they can even be cached if the correct headers are set on the reply)
*/
- if (request->flags.auth)
+ if (request->flags.hasAuth())
return 0;
if (method == METHOD_TRACE)
if (Comm::IsConnOpen(http_conn->pinning.serverConnection)) {
if (http_conn->pinning.auth) {
request->flags.wantConnectionAuth();
- request->flags.auth = 1;
+ request->flags.markAuth();
} else {
request->flags.requestConnectionProxyAuth();
}
request->ims = req_hdr->getTime(HDR_IF_MODIFIED_SINCE);
if (request->ims > 0)
- request->flags.ims = 1;
+ request->flags.setIMS();
if (!request->flags.ignoringCacheControl()) {
if (req_hdr->has(HDR_PRAGMA)) {
* SP1 or not so all 5.5 versions are treated 'normally').
*/
if (Config.onoff.ie_refresh) {
- if (http->flags.accel && request->flags.ims) {
+ if (http->flags.accel && request->flags.hasIMS()) {
if ((str = req_hdr->getStr(HDR_USER_AGENT))) {
if (strstr(str, "MSIE 5.01") != NULL)
no_cache=true;
else
#endif
- request->flags.nocache = 1;
+ request->flags.setNocache();
}
/* ignore range header in non-GETs or non-HEADs */
}
if (req_hdr->has(HDR_AUTHORIZATION))
- request->flags.auth = 1;
+ request->flags.markAuth();
clientCheckPinning(http);
if (request->login[0] != '\0')
- request->flags.auth = 1;
+ request->flags.markAuth();
if (req_hdr->has(HDR_VIA)) {
String s = req_hdr->getList(HDR_VIA);
#endif
- request->flags.cachable = http->request->cacheable();
+ request->flags.setCachable(http->request->cacheable());
if (clientHierarchical(http))
- request->flags.hierarchical = 1;
+ request->flags.setHierarchical();
debugs(85, 5, "clientInterpretRequestHeaders: REQ_NOCACHE = " <<
- (request->flags.nocache ? "SET" : "NOT SET"));
+ (request->flags.noCache() ? "SET" : "NOT SET"));
debugs(85, 5, "clientInterpretRequestHeaders: REQ_CACHABLE = " <<
- (request->flags.cachable ? "SET" : "NOT SET"));
+ (request->flags.isCachable() ? "SET" : "NOT SET"));
debugs(85, 5, "clientInterpretRequestHeaders: REQ_HIERARCHICAL = " <<
- (request->flags.hierarchical ? "SET" : "NOT SET"));
+ (request->flags.hierarchical() ? "SET" : "NOT SET"));
}
ClientRequestContext::checkNoCacheDone(const allow_t &answer)
{
acl_checklist = NULL;
- http->request->flags.cachable = (answer == ACCESS_ALLOWED);
+ if (answer == ACCESS_ALLOWED)
+ http->request->flags.setCachable();
http->doCallouts();
}
if (!calloutContext->no_cache_done) {
calloutContext->no_cache_done = true;
- if (Config.accessList.noCache && request->flags.cachable) {
+ if (Config.accessList.noCache && request->flags.isCachable()) {
debugs(83, 3, HERE << "Doing calloutContext->checkNoCache()");
calloutContext->checkNoCache();
return;
if (rePin) {
debugs(17, 3, HERE << "repinning " << serverConn);
request->clientConnectionManager->pinConnection(serverConn,
- request, serverConn->getPeer(), request->flags.auth);
+ request, serverConn->getPeer(), request->flags.hasAuth());
request->flags.markPinned();
}
++n_tries;
request->flags.markPinned();
if (pinned_connection->pinnedAuth())
- request->flags.auth = 1;
+ request->flags.markAuth();
comm_add_close_handler(serverConn->fd, fwdServerClosedWrapper, this);
// the server may close the pinned connection before this request
pconnRace = racePossible;
}
}
- if (request->flags.auth || request->flags.authSent()) {
+ if (request->flags.hasAuth() || request->flags.authSent()) {
/*
* Responses to requests with authorization may be cached
* only if a Cache-Control: public reply header is present.
*/
if (!we_do_ranges && request->multipartRangeRequest()) {
/* don't cache the result */
- request->flags.cachable = 0;
+ request->flags.setNotCachable();
/* pretend it's not a range request */
delete request->range;
request->range = NULL;
int64_t roffLimit = request->getRangeOffsetLimit();
- if (NULL == request->range || !request->flags.cachable
+ if (NULL == request->range || !request->flags.isCachable()
|| request->range->offsetLimitExceeded(roffLimit) || request->flags.connectionAuthWanted())
result = false;
debugs(11, 8, "decideIfWeDoRanges: range specs: " <<
request->range << ", cachable: " <<
- request->flags.cachable << "; we_do_ranges: " << result);
+ request->flags.isCachable() << "; we_do_ranges: " << result);
return result;
}
return;
}
- flags.cachable = 1;
+ flags.setCachable();
StoreEntry *e = storeCreateEntry(url,
url,
flags,
if (neighborType(p, request) == PEER_SIBLING) {
#if PEER_MULTICAST_SIBLINGS
if (p->type == PEER_MULTICAST && p->options.mcast_siblings &&
- (request->flags.nocache || request->flags.refresh() || request->flags.loopDetect() || request->flags.validationNeeded()))
+ (request->flags.noCache() || request->flags.refresh() || request->flags.loopDetect() || request->flags.validationNeeded()))
debugs(15, 2, "peerAllowedToUse(" << p->name << ", " << request->GetHost() << ") : multicast-siblings optimization match");
#endif
- if (request->flags.nocache)
+ if (request->flags.noCache())
return false;
if (request->flags.refresh())
/* the case below seems strange, but can happen if the
* URL host is on the other side of a firewall */
if (p->type == PEER_SIBLING)
- if (!request->flags.hierarchical)
+ if (!request->flags.hierarchical())
return 0;
if (!peerAllowedToUse(p, request))
int p_rtt;
int i;
- if (!request->flags.hierarchical)
+ if (!request->flags.hierarchical())
return NULL;
storeKeyPublicByRequest(request);
pd_last_req_time = squid_curtime;
- req->flags.cachable = 1;
+ req->flags.setCachable();
/* the rest is based on clientProcessExpired() */
req->flags.setRefresh();
assert(direct != DIRECT_YES);
debugs(44, 3, "peerSelectIcpPing: " << entry->url() );
- if (!request->flags.hierarchical && direct != DIRECT_NO)
+ if (!request->flags.hierarchical() && direct != DIRECT_NO)
return 0;
if (EBIT_TEST(entry->flags, KEY_PRIVATE) && !neighbors_do_private_keys)
if (Config.onoff.prefer_direct)
peerGetSomeDirect(ps);
- if (request->flags.hierarchical || !Config.onoff.nonhierarchical_direct) {
+ if (request->flags.hierarchical() || !Config.onoff.nonhierarchical_direct) {
peerGetSomeParent(ps);
peerGetAllParents(ps);
}
if (request && !request->flags.ignoringCacheControl()) {
HttpHdrCc *cc = request->cache_control;
- if (request->flags.ims && (R->flags.refresh_ims || Config.onoff.refresh_all_ims)) {
+ if (request->flags.hasIMS() && (R->flags.refresh_ims || Config.onoff.refresh_all_ims)) {
/* The clients no-cache header is changed into a IMS query */
debugs(22, 3, "refreshCheck: YES: refresh-ims");
return STALE_FORCED_RELOAD;
} else {
/* The clients no-cache header is not overridden on this request */
debugs(22, 3, "refreshCheck: YES: client reload");
- request->flags.nocache = 1;
+ request->flags.setNocache();
return STALE_FORCED_RELOAD;
}
mem = e->mem_obj;
mem->method = method;
- if (neighbors_do_private_keys || !flags.hierarchical)
+ if (neighbors_do_private_keys || !flags.hierarchical())
e->setPrivateKey();
else
e->setPublicKey();
- if (flags.cachable) {
+ if (flags.isCachable()) {
EBIT_SET(e->flags, ENTRY_CACHABLE);
EBIT_CLR(e->flags, RELEASE_REQUEST);
} else {
assert(mem);
debugs(90, 3, "CheckQuickAbort2: entry=" << entry << ", mem=" << mem);
- if (mem->request && !mem->request->flags.cachable) {
+ if (mem->request && !mem->request->flags.isCachable()) {
debugs(90, 3, "CheckQuickAbort2: YES !mem->request->flags.cachable");
return 1;
}
debugs(71, 2, "storeDigestRewrite: start rewrite #" << sd_state.rewrite_count + 1);
/* make new store entry */
url = internalLocalUri("/squid-internal-periodic/", StoreDigestFileName);
- flags.cachable = 1;
+ flags.setCachable();
e = storeCreateEntry(url, url, flags, METHOD_GET);
assert(e);
sd_state.rewrite_lock = e;
{
/* Create "vary" base object */
RequestFlags flags;
- flags.cachable = 1;
+ flags.setCachable();
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);
{
/* Create "vary" base object */
RequestFlags flags;
- flags.cachable = 1;
+ flags.setCachable();
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
/* We are allowed to do this typecast */
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
testRock::createEntry(const int i)
{
RequestFlags flags;
- flags.cachable = 1;
+ flags.setCachable();
char url[64];
snprintf(url, sizeof(url), "dummy url %i", i);
url[sizeof(url) - 1] = '\0';
{
/* Create "vary" base object */
RequestFlags flags;
- flags.cachable = 1;
+ flags.setCachable();
StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET);
HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const
rep->setHeaders(HTTP_OK, "dummy test object", "x-squid-internal/test", -1, -1, squid_curtime + 100000);