]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Encapsulate HttpHeaderEntry length calculation (#1416)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sat, 22 Jul 2023 18:58:31 +0000 (18:58 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 22 Jul 2023 18:58:37 +0000 (18:58 +0000)
src/HttpHeader.cc
src/HttpHeader.h

index b7da018d2bdb8758396e98cda44e0c18396c07ff..ba167e4a9003d3e22c005d6e7916b57c13a55ac8 100644 (file)
@@ -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
index 45d8d75b4671eac49700fcb40667c51fd70a7b01..7657749398b278201d15db80feb946c65406eb89 100644 (file)
@@ -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;