const char *
strnrchr(const char *s, size_t count, int c)
{
- const char *rv=NULL;
- const char *l=s;
- while (count > 0 && *l != 0) {
- if (*l==c)
- rv=l;
- ++l;
- --count;
- }
- return rv;
+ const char *rv=NULL;
+ const char *l=s;
+ while (count > 0 && *l != 0) {
+ if (*l==c)
+ rv=l;
+ ++l;
+ --count;
+ }
+ return rv;
}
/* a row in the table used for parsing surrogate-control header and statistics */
typedef struct {
- const char *name;
- http_hdr_sc_type id;
- HttpHeaderFieldStat stat;
+ const char *name;
+ http_hdr_sc_type id;
+ HttpHeaderFieldStat stat;
} HttpHeaderScFields;
/* this table is used for parsing surrogate control header */
sct->noStoreRemote(true);
break;
- case SC_MAX_AGE:
- {
- int ma;
- if (p && httpHeaderParseInt(p, &ma)) {
- sct->maxAge(ma);
- } else {
- debugs(90, 2, "sc: invalid max-age specs near '" << item << "'");
- sct->clearMaxAge();
- }
-
- if ((p = strchr (p, '+'))) {
- int ms;
- ++p; //skip the + char
- if (httpHeaderParseInt(p, &ms)) {
- sct->maxStale(ms);
- } else {
- debugs(90, 2, "sc: invalid max-stale specs near '" << item << "'");
- sct->clearMaxStale();
- /* leave the max-age alone */
- }
- }
- break;
- }
+ case SC_MAX_AGE: {
+ int ma;
+ if (p && httpHeaderParseInt(p, &ma)) {
+ sct->maxAge(ma);
+ } else {
+ debugs(90, 2, "sc: invalid max-age specs near '" << item << "'");
+ sct->clearMaxAge();
+ }
+
+ if ((p = strchr (p, '+'))) {
+ int ms;
+ ++p; //skip the + char
+ if (httpHeaderParseInt(p, &ms)) {
+ sct->maxStale(ms);
+ } else {
+ debugs(90, 2, "sc: invalid max-stale specs near '" << item << "'");
+ sct->clearMaxStale();
+ /* leave the max-age alone */
+ }
+ }
+ break;
+ }
case SC_CONTENT:
- if ( p && httpHeaderParseQuotedString(p, vlen, &sct->content_)) {
- sct->setMask(SC_CONTENT,true); // ugly but saves a copy
- } else {
+ if ( p && httpHeaderParseQuotedString(p, vlen, &sct->content_)) {
+ sct->setMask(SC_CONTENT,true); // ugly but saves a copy
+ } else {
debugs(90, 2, "sc: invalid content= quoted string near '" << item << "'");
sct->clearContent();
}
- break;
+ break;
case SC_OTHER:
default:
node = targets.head;
while (node) {
- static_cast<HttpHdrScTarget *>(node->data)->packInto(p);
+ static_cast<HttpHdrScTarget *>(node->data)->packInto(p);
node = node->next;
}
}
dlink_node *sct = targets.head;
while (sct) {
- static_cast<HttpHdrScTarget *>(sct->data)->updateStats(hist);
+ static_cast<HttpHdrScTarget *>(sct->data)->updateStats(hist);
sct = sct->next;
}
}
// parsing is done in HttpHdrSc, need to grant them access.
friend class HttpHdrSc;
public:
- static const int MAX_AGE_UNSET=-1; //max-age is unset
- static const int MAX_STALE_UNSET=0; //max-stale is unset
+ static const int MAX_AGE_UNSET=-1; //max-age is unset
+ static const int MAX_STALE_UNSET=0; //max-stale is unset
HttpHdrScTarget(const char *target_):
- mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
+ mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
HttpHdrScTarget(const String &target_):
- mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
+ mask(0), max_age(MAX_AGE_UNSET), max_stale(MAX_STALE_UNSET),target(target_) {}
HttpHdrScTarget(const HttpHdrScTarget &t):
- mask(t.mask), max_age(t.max_age), max_stale(t.max_stale),
- content_(t.content_), target(t.target) {}
+ mask(t.mask), max_age(t.max_age), max_stale(t.max_stale),
+ content_(t.content_), target(t.target) {}
bool hasNoStore() const {return isSet(SC_NO_STORE); }
void noStore(bool v) { setMask(SC_NO_STORE,v); }
bool hasMaxAge() const { return isSet(SC_MAX_AGE); }
void maxAge(int v) {
- if (v >= 0) { //setting
- setMask(SC_MAX_AGE,true);
- max_age=v;
- } else {
- setMask(SC_MAX_AGE,false);
- max_age=MAX_AGE_UNSET;
- }
+ if (v >= 0) { //setting
+ setMask(SC_MAX_AGE,true);
+ max_age=v;
+ } else {
+ setMask(SC_MAX_AGE,false);
+ max_age=MAX_AGE_UNSET;
+ }
}
int maxAge() const { return max_age; }
void clearMaxAge() { setMask(SC_MAX_AGE,false); max_age=MAX_AGE_UNSET; }
bool hasContent() const { return isSet(SC_CONTENT); }
void Content(const String &v) {
- setMask(SC_CONTENT,true);
- content_=v;
+ setMask(SC_CONTENT,true);
+ content_=v;
}
String content() const { return content_; }
void clearContent() { setMask(SC_CONTENT,false); content_.clean(); }
if (rep->surrogate_control) {
HttpHdrScTarget *sctusable =
- rep->surrogate_control->getMergedTarget(Config.Accel.surrogate_id);
+ rep->surrogate_control->getMergedTarget(Config.Accel.surrogate_id);
if (!sctusable || !sctusable->hasContent())
/* Nothing generic or targeted at us, or no