]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Improve reply_body_max_size matching accuracy (#1324)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 22 Apr 2023 16:45:07 +0000 (16:45 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Tue, 25 Apr 2023 13:48:24 +0000 (01:48 +1200)
    HttpReply.cc(553) receivedBodyTooLarge: -4096 >? -1

ClientHttpRequest::out.offset is documented to only count body bytes,
and that is what receivedBodyTooLarge() needs. We should not subtract
the guessed header size, occasionally violating reply_body_max_size
configuration and often leading to a confusing negative body size in
receivedBodyTooLarge() debugging.

Possibly broken since 2003 commit b51aec6: out.offset was not documented
back then, but, AFAICT, it was already used just for the body bytes.

src/client_side_reply.cc

index 0004137cbc9b3a01d11df6eb5ee783595b3f9d0d..7922942f665b46cc26a2e579b3039a547c72a7bf 100644 (file)
@@ -1198,8 +1198,7 @@ clientReplyContext::replyStatus()
     }
 
     // XXX: Should this be checked earlier? We could return above w/o checking.
-    if (reply->receivedBodyTooLarge(*http->request, http->out.offset - 4096)) {
-        /* 4096 is a margin for the HTTP headers included in out.offset */
+    if (reply->receivedBodyTooLarge(*http->request, http->out.offset)) {
         debugs(88, 5, "clientReplyStatus: client reply body is too large");
         return STREAM_FAILED;
     }