From: Eduard Bagdasaryan Date: Sat, 22 Jul 2023 18:58:31 +0000 (+0000) Subject: Encapsulate HttpHeaderEntry length calculation (#1416) X-Git-Tag: SQUID_7_0_1~391 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fbc23dd675184d8cf4e4fc4e423720a591f86bec;p=thirdparty%2Fsquid.git Encapsulate HttpHeaderEntry length calculation (#1416) --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index b7da018d2b..ba167e4a90 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -752,8 +752,7 @@ HttpHeader::addEntry(HttpHeaderEntry * e) entries.push_back(e); - /* increment header length, allow for ": " and crlf */ - len += e->name.length() + 2 + e->value.size() + 2; + len += e->length(); } bool diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 45d8d75b46..7657749398 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -60,6 +60,9 @@ public: int getInt() const; int64_t getInt64() const; + /// expected number of bytes written by packInto(), including ": " and CRLF + size_t length() const { return name.length() + 2 + value.size() + 2; } + Http::HdrType id; SBuf name; String value;