From: wessels <> Date: Sat, 6 May 2006 00:16:26 +0000 (+0000) Subject: Bugfix for assertion in httpHeaderFindEntry(). The caller, X-Git-Tag: SQUID_3_0_PRE4~201 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d8ed70bf1528fcb70a39b5427b5eaf1bca53b18;p=thirdparty%2Fsquid.git Bugfix for assertion in httpHeaderFindEntry(). The caller, HttpMsg::hdrCacheInit() was assuming that the content length header is always present in the HTTP reply. To fix I copied httpHeaderGetSize() from squid-2 code. For now this version of httpHeaderGetSize() is basically the same as httpHeaderGetInt(), except that it checks to see if the header exists. If not, it returns -1. --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index c0cbd86bfc..94e4ad2ed4 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.112 2006/04/22 05:29:18 robertc Exp $ + * $Id: HttpHeader.cc,v 1.113 2006/05/05 18:16:26 wessels Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -1118,6 +1118,27 @@ httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id) return -1; } +/* + * This is copied from Squid-2 code, which uses squid_off_t instead + * of int, and ftSize instead of ftInt + */ +int +httpHeaderGetSize(const HttpHeader * hdr, http_hdr_type id) +{ + HttpHeaderEntry *e; + int value = -1; + int ok; + assert_eid(id); + assert(Headers[id].type == ftInt); /* must be of an appropriate type */ + + if ((e = httpHeaderFindEntry(hdr, id))) { + ok = httpHeaderParseSize(e->value.buf(), &value); + httpHeaderNoteParsedEntry(e->id, e->value, !ok); + } + + return value; +} + time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id) { diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index 8b7fac545a..6c11023f73 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.cc,v 1.26 2006/04/18 12:25:50 robertc Exp $ + * $Id: HttpMsg.cc,v 1.27 2006/05/05 18:16:26 wessels Exp $ * * DEBUG: section 74 HTTP Message * AUTHOR: Alex Rousskov @@ -338,7 +338,7 @@ void HttpMsg::packInto(Packer *p, bool full_uri) const void HttpMsg::hdrCacheInit() { - content_length = httpHeaderGetInt(&header, HDR_CONTENT_LENGTH); + content_length = httpHeaderGetSize(&header, HDR_CONTENT_LENGTH); assert(NULL == cache_control); cache_control = httpHeaderGetCc(&header); } diff --git a/src/protos.h b/src/protos.h index 21f20d88ca..3d6c154960 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.524 2006/04/29 13:53:16 serassio Exp $ + * $Id: protos.h,v 1.525 2006/05/05 18:16:26 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -349,6 +349,7 @@ class HttpHdrRange; SQUIDCEXTERN void httpHeaderPutRange(HttpHeader * hdr, const HttpHdrRange * range); SQUIDCEXTERN void httpHeaderPutExt(HttpHeader * hdr, const char *name, const char *value); SQUIDCEXTERN int httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id); +SQUIDCEXTERN int httpHeaderGetSize(const HttpHeader * hdr, http_hdr_type id); SQUIDCEXTERN time_t httpHeaderGetTime(const HttpHeader * hdr, http_hdr_type id); SQUIDCEXTERN TimeOrTag httpHeaderGetTimeOrTag(const HttpHeader * hdr, http_hdr_type id); SQUIDCEXTERN HttpHdrCc *httpHeaderGetCc(const HttpHeader * hdr);