RequestFlags():
nocache(0), ims(0), auth(0), cachable(0),
hierarchical(0), loopdetect(0), proxy_keepalive(0), proxying(0),
- refresh(0), redirected(0), need_validation(0),
- fail_on_validation_err(0), stale_if_hit(0), nocache_hack(false), accelerated_(false),
+ refresh(0), 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),
internal(false), internalclient(false), must_keepalive(false), connection_auth_wanted(false), connection_auth_disabled(false), connection_proxy_auth(false), pinned_(false),
canRePin_(false), authSent_(false), noDirect_(false), chunkedReply_(false),
unsigned int proxy_keepalive :1;
unsigned int proxying :1; /* this should be killed, also in httpstateflags */
unsigned int refresh :1;
- unsigned int redirected :1;
- unsigned int need_validation :1;
- unsigned int fail_on_validation_err :1; ///< whether we should fail if validation fails
- unsigned int stale_if_hit :1; ///< reply is stale if it is a hit
- /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
// When adding new flags, please update cloneAdaptationImmune() as needed.
bool resetTCP() const;
* Compilers will have an easy time optimizing to a NOP otherwise. */
void hackNocache() { if (USE_HTTP_VIOLATIONS) nocache_hack=true; }
bool noCacheHackEnabled() const { return USE_HTTP_VIOLATIONS && nocache_hack; }
+
+ void setStaleIfHit() { stale_if_hit=true; }
+ void clearStaleIfHit() { stale_if_hit=false; }
+ bool staleIfHit() const { return stale_if_hit; }
+
+ void setFailOnValidationError() { fail_on_validation_err=true; }
+ bool failOnValidationError() const { return fail_on_validation_err; }
+
+ bool validationNeeded() const { return need_validation; }
+ void setNeedValidation() { need_validation=true; }
+
+ bool isRedirected() const { return redirected; }
+ void markRedirected() { redirected=true; }
private:
+ bool redirected :1;
+ bool need_validation :1;
+ bool fail_on_validation_err :1; ///< whether we should fail if validation fails
+ bool stale_if_hit :1; ///< reply is stale if it is a hit
+ /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
bool nocache_hack :1;
bool accelerated_ :1; ///<request is accelerated
bool ignore_cc :1; ///< ignore Cache-Control
// origin replied 304
if (status == HTTP_NOT_MODIFIED) {
http->logType = LOG_TCP_REFRESH_UNMODIFIED;
- http->request->flags.stale_if_hit = 0; // old_entry is no longer stale
+ http->request->flags.clearStaleIfHit(); // old_entry is no longer stale
// update headers on existing entry
old_rep->updateOnNotModified(http->storeEntry()->getReply());
}
// origin replied with an error
- else if (http->request->flags.fail_on_validation_err) {
+ else if (http->request->flags.failOnValidationError()) {
http->logType = LOG_TCP_REFRESH_FAIL_ERR;
debugs(88, 3, "handleIMSReply: origin replied with error " << status <<
", forwarding to client due to fail_on_validation_err");
* request. Otherwise two siblings could generate a loop if
* both have a stale version of the object.
*/
- r->flags.need_validation = 1;
+ r->flags.setNeedValidation();
if (e->lastmod < 0) {
/*
}
// add Warnings required by RFC 2616 if serving a stale hit
- if (http->request->flags.stale_if_hit && logTypeIsATcpHit(http->logType)) {
+ if (http->request->flags.staleIfHit() && logTypeIsATcpHit(http->logType)) {
hdr->putWarning(110, "Response is stale");
- if (http->request->flags.need_validation)
+ if (http->request->flags.validationNeeded())
hdr->putWarning(111, "Revalidation failed");
}
debugs(61,2, HERE << "URL-rewriter diverts URL from " << urlCanonical(old_request) << " to " << urlCanonical(new_request));
// update the new request to flag the re-writing was done on it
- new_request->flags.redirected = 1;
+ new_request->flags.markRedirected();
// unlink bodypipe from the old request. Not needed there any longer.
if (old_request->body_pipe != NULL) {
ErrorState *
FwdState::makeConnectingError(const err_type type) const
{
- return new ErrorState(type, request->flags.need_validation ?
+ return new ErrorState(type, request->flags.validationNeeded() ?
HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
}
*/
if (request->peer_domain)
hdr_out->putStr(HDR_HOST, request->peer_domain);
- else if (request->flags.redirected && !Config.onoff.redir_rewrites_host)
+ else if (request->flags.isRedirected() && !Config.onoff.redir_rewrites_host)
hdr_out->addEntry(e->clone());
else {
/* use port# only if not default */
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.need_validation))
+ (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.loopdetect)
return false;
- if (request->flags.need_validation)
+ if (request->flags.validationNeeded())
return false;
}
// To resolve this we must use only the original client destination when going DIRECT
// on intercepted traffic which failed Host verification
const HttpRequest *req = psstate->request;
- const bool isIntercepted = !req->flags.redirected &&
+ const bool isIntercepted = !req->flags.isRedirected() &&
(req->flags.intercepted() || req->flags.spoofClientIp());
const bool useOriginalDst = Config.onoff.client_dst_passthru || !req->flags.hostVerified();
const bool choseDirect = fs && fs->code == HIER_DIRECT;
entry->mem_obj->getReply()->cache_control->staleIfError() < staleness) {
debugs(22, 3, "refreshCheck: stale-if-error period expired.");
- request->flags.fail_on_validation_err = 1;
+ request->flags.setFailOnValidationError();
}
if (EBIT_TEST(entry->flags, ENTRY_REVALIDATE) && staleness > -1
) {
debugs(22, 3, "refreshCheck: YES: Must revalidate stale response");
if (request)
- request->flags.fail_on_validation_err = 1;
+ request->flags.setFailOnValidationError();
return STALE_MUST_REVALIDATE;
}
if ( max_stale >= 0 && staleness > max_stale) {
debugs(22, 3, "refreshCheck: YES: max-stale limit");
if (request)
- request->flags.fail_on_validation_err = 1;
+ request->flags.setFailOnValidationError();
return STALE_MAX_STALE;
}
int reason = refreshCheck(entry, request, 0);
++ refreshCounts[rcHTTP].total;
++ refreshCounts[rcHTTP].status[reason];
- request->flags.stale_if_hit = refreshIsStaleIfHit(reason);
+ if (refreshIsStaleIfHit(reason))
+ request->flags.setStaleIfHit();
return (Config.onoff.offline || reason < 200) ? 0 : 1;
}