--------------------- PatchSet 10421 Date: 2008/01/21 03:36:14 Author: adri Branch: s27_adri Tag: (none) Log: Re-implement httpHeaderHasConnDir() to not use a temporary string list. WARNING: COMPLETELY NOT TESTED! Members: src/HttpHeader.c:1.28.6.1.4.26->1.28.6.1.4.27 src/HttpHeaderTools.c:1.14.10.4->1.14.10.5 Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.28.6.1.4.26 retrieving revision 1.28.6.1.4.27 diff -u -r1.28.6.1.4.26 -r1.28.6.1.4.27 --- squid/src/HttpHeader.c 6 Jan 2008 09:56:01 -0000 1.28.6.1.4.26 +++ squid/src/HttpHeader.c 21 Jan 2008 03:36:14 -0000 1.28.6.1.4.27 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.28.6.1.4.26 2008/01/06 09:56:01 adri Exp $ + * $Id: HttpHeader.c,v 1.28.6.1.4.27 2008/01/21 03:36:14 adri Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -1306,3 +1306,42 @@ assert(id >= 0 && id < HDR_ENUM_END); return stringDup(&Headers[id].name); } + +/* + * * 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) +{ + HttpHeaderPos pos = HttpHeaderInitPos; + HttpHeaderEntry *e; + 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; + + /* Lets special case this */ + assert(CBIT_TEST(ListHeadersMask, ht)); + if (!CBIT_TEST(hdr->mask, ht)) + return 0; + + while ((e = httpHeaderGetEntry(hdr, &pos))) + if (e->id == ht && (res = strListIsMember(&e->value, directive, ','))) + return res; + + return 0; +#if 0 + list = httpHeaderGetList(hdr, ht); + res = strListIsMember(&list, directive, ','); + stringClean(&list); + return res; +#endif +} + Index: squid/src/HttpHeaderTools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeaderTools.c,v retrieving revision 1.14.10.4 retrieving revision 1.14.10.5 diff -u -r1.14.10.4 -r1.14.10.5 --- squid/src/HttpHeaderTools.c 17 Dec 2007 08:17:48 -0000 1.14.10.4 +++ squid/src/HttpHeaderTools.c 21 Jan 2008 03:36:15 -0000 1.14.10.5 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.c,v 1.14.10.4 2007/12/17 08:17:48 adri Exp $ + * $Id: HttpHeaderTools.c,v 1.14.10.5 2008/01/21 03:36:15 adri Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -148,31 +148,6 @@ } -/* - * 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; -} - /* handy to printf prefixes of potentially very long buffers */ const char * getStringPrefix(const char *str, const char *end)