--------------------- PatchSet 10213 Date: 2007/12/12 09:52:09 Author: adri Branch: s27_adri Tag: (none) Log: strBuf() -> strBuf2(); comment in ADRIAN_TODO the hack performed so it can be tidied up later. Members: ADRIAN_TODO:1.1.2.2->1.1.2.3 src/HttpHeader.c:1.28.6.1.4.8->1.28.6.1.4.9 src/client_side.c:1.202.2.9.4.4->1.202.2.9.4.5 src/protos.h:1.146.2.4.4.8->1.146.2.4.4.9 Index: squid/ADRIAN_TODO =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/ADRIAN_TODO,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/ADRIAN_TODO 11 Dec 2007 16:39:32 -0000 1.1.2.2 +++ squid/ADRIAN_TODO 12 Dec 2007 09:52:09 -0000 1.1.2.3 @@ -29,3 +29,11 @@ * modify the two places which pass (str, len) to pass a String. * the httpHeaderGetTimeOrTag sets "Tag" to be a pointer to a String buffer; change the code to make tag a String and ref it! +* httpHeaderExtStr() currently takes a const char *name, and converts it + to a String before calling EntryCreate2(); this is done so the original + value can be referenced rather than copied. Eventually, when there's a + static-buffer-String initialiser that'll DTRT, use -that- and change + httpHeaderExtStr() to take a String name. + +* Ideally a static-buffer-String initialiser will bypass the need for a backing + buf_t completely.. Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.28.6.1.4.8 retrieving revision 1.28.6.1.4.9 diff -u -r1.28.6.1.4.8 -r1.28.6.1.4.9 --- squid/src/HttpHeader.c 12 Dec 2007 09:37:53 -0000 1.28.6.1.4.8 +++ squid/src/HttpHeader.c 12 Dec 2007 09:52:09 -0000 1.28.6.1.4.9 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.28.6.1.4.8 2007/12/12 09:37:53 adri Exp $ + * $Id: HttpHeader.c,v 1.28.6.1.4.9 2007/12/12 09:52:09 adri Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -1038,6 +1038,24 @@ httpHeaderAddEntry(hdr, httpHeaderEntryCreate(HDR_OTHER, name, value)); } +/* XXX this is very silly */ +/* XXX when a real ref-counted string thing comes into play which has + * XXX a static-string initialiser then please fix the callers of this + * XXX code to use -that- and cut past all the crap here. + */ +void +httpHeaderPutExtStr(HttpHeader * hdr, const char *name, String value) +{ + String v = StringNull; + + stringInit(&v, name); + assert(name); + debug(55, 8) ("%p adds ext entry '%.*s: %.*s'\n", hdr, strLen2(v), strBuf2(v), strLen2(value), strBuf2(value)); + httpHeaderAddEntry(hdr, httpHeaderEntryCreate2(HDR_OTHER, v, value)); + stringClean(&v); +} + + int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id) { Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.4 retrieving revision 1.202.2.9.4.5 diff -u -r1.202.2.9.4.4 -r1.202.2.9.4.5 --- squid/src/client_side.c 12 Dec 2007 08:04:09 -0000 1.202.2.9.4.4 +++ squid/src/client_side.c 12 Dec 2007 09:52:09 -0000 1.202.2.9.4.5 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.4 2007/12/12 08:04:09 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.5 2007/12/12 09:52:09 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1807,12 +1807,12 @@ } else if (http->conn->port->act_as_origin) { HttpHeaderEntry *h = httpHeaderFindEntry(hdr, HDR_DATE); if (h) - httpHeaderPutExt(hdr, "X-Origin-Date", strBuf(h->value)); + httpHeaderPutExtStr(hdr, "X-Origin-Date", h->value); httpHeaderDelById(hdr, HDR_DATE); httpHeaderInsertTime(hdr, 0, HDR_DATE, squid_curtime); h = httpHeaderFindEntry(hdr, HDR_EXPIRES); if (h && http->entry->expires >= 0) { - httpHeaderPutExt(hdr, "X-Origin-Expires", strBuf(h->value)); + httpHeaderPutExtStr(hdr, "X-Origin-Expires", h->value); httpHeaderDelById(hdr, HDR_EXPIRES); httpHeaderInsertTime(hdr, 1, HDR_EXPIRES, squid_curtime + http->entry->expires - http->entry->timestamp); } { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.8 retrieving revision 1.146.2.4.4.9 diff -u -r1.146.2.4.4.8 -r1.146.2.4.4.9 --- squid/src/protos.h 12 Dec 2007 09:07:52 -0000 1.146.2.4.4.8 +++ squid/src/protos.h 12 Dec 2007 09:52:10 -0000 1.146.2.4.4.9 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.8 2007/12/12 09:07:52 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.9 2007/12/12 09:52:10 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -436,6 +436,7 @@ extern void httpHeaderPutContRange(HttpHeader * hdr, const HttpHdrContRange * cr); extern void httpHeaderPutRange(HttpHeader * hdr, const HttpHdrRange * range); extern void httpHeaderPutExt(HttpHeader * hdr, const char *name, const char *value); +extern void httpHeaderPutExtStr(HttpHeader * hdr, const char *name, String value); extern int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id); extern squid_off_t httpHeaderGetSize(const HttpHeader * hdr, http_hdr_type id); extern time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id);