}
/**
- * 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.
+ * \return true if a given directive is found in the Connection header field-value.
+ *
+ * \note if no Connection header exists we may check the Proxy-Connection header
*/
-int
+bool
httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive)
{
String list;
- int res;
+
/* what type of header do we have? */
+ if (hdr->has(HDR_CONNECTION)) {
+ list = hdr->getList(HDR_CONNECTION);
+ return strListIsMember(&list, directive, ',') != 0;
+ }
#if USE_HTTP_VIOLATIONS
- if (hdr->has(HDR_PROXY_CONNECTION))
+ if (hdr->has(HDR_PROXY_CONNECTION)) {
list = hdr->getList(HDR_PROXY_CONNECTION);
- else
+ return strListIsMember(&list, directive, ',') != 0;
+ }
#endif
- if (hdr->has(HDR_CONNECTION))
- list = hdr->getList(HDR_CONNECTION);
- else
- return 0;
-
- res = strListIsMember(&list, directive, ',');
-
- list.clean();
- return res;
+ // else, no connection header for it to exist in
+ return false;
}
/** handy to printf prefixes of potentially very long buffers */
http_hdr_type httpHeaderIdByName(const char *name, size_t name_len, const HttpHeaderFieldInfo * attrs, int end);
http_hdr_type httpHeaderIdByNameDef(const char *name, int name_len);
const char *httpHeaderNameById(int id);
-int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive);
+bool httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive);
int httpHeaderParseInt(const char *start, int *val);
void httpHeaderPutStrf(HttpHeader * hdr, http_hdr_type id, const char *fmt,...) PRINTF_FORMAT_ARG3;