]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
eCAP: Return unknown body size for bodies with unknown body sizes.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 21 Sep 2015 18:17:38 +0000 (12:17 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 21 Sep 2015 18:17:38 +0000 (12:17 -0600)
Previously, unsigned -1 size was returned for those bodies.
Old adapters relying on that buggy behavior will now throw:

  !"attempt to use unknown libecap::BodySize size"

Such adapters should check libecap::BodySize::known() before
using the libecap::Body::bodySize() value.

src/adaptation/ecap/MessageRep.cc

index 3d5e095010760c7d265cd9ccfbc10e6ee6a07731..53962dda40b3f4ea916ed35eefd5b5d2cde786cd 100644 (file)
@@ -353,7 +353,7 @@ Adaptation::Ecap::BodyRep::tie(const BodyPipe::Pointer &aBody)
 Adaptation::Ecap::BodyRep::BodySize
 Adaptation::Ecap::BodyRep::bodySize() const
 {
-    return !theBody ? BodySize() : BodySize(theBody->bodySize());
+    return (theBody && theBody->bodySizeKnown()) ? BodySize(theBody->bodySize()) : BodySize();
 }
 
 /* MessageRep */