/* return a string or list of entries with the same id separated by ',' and ws */ String httpHeaderGetStrOrList(const HttpHeader * hdr, http_hdr_type id) { HttpHeaderEntry *e; if (CBIT_TEST(ListHeadersMask, id)) return httpHeaderGetList(hdr, id); if ((e = httpHeaderFindEntry(hdr, id))) { String s; stringInit(&s, strBuf(e->value)); return s; } return StringNull; }
HttpHdrCc * httpHeaderGetCc(const HttpHeader * hdr) { HttpHdrCc *cc; String s; if (!CBIT_TEST(hdr->mask, HDR_CACHE_CONTROL)) return NULL; s = httpHeaderGetList(hdr, HDR_CACHE_CONTROL); cc = httpHdrCcParseCreate(&s); HttpHeaderStats[hdr->owner].ccParsedCount++; if (cc) httpHdrCcUpdateStats(cc, &HttpHeaderStats[hdr->owner].ccTypeDistr); httpHeaderNoteParsedEntry(HDR_CACHE_CONTROL, s, !cc); stringClean(&s); return cc; }
/* * return true if a given directive is found in at least one of * the "connection" header-fields note: if HDR_PROXY_CONNECTION is * present we ignore HDR_CONNECTION. */ int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive) { String list; http_hdr_type ht; int res; /* what type of header do we have? */ if (httpHeaderHas(hdr, HDR_PROXY_CONNECTION)) ht = HDR_PROXY_CONNECTION; else if (httpHeaderHas(hdr, HDR_CONNECTION)) ht = HDR_CONNECTION; else return 0; list = httpHeaderGetList(hdr, ht); res = strListIsMember(&list, directive, ','); stringClean(&list); return res; }