[7.3] ab26b0b4f bereq: Also unset a cached req body
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Oct 25 14:33:08 UTC 2023
commit ab26b0b4fa4436d64ec901b320e7aa876f4d76af
Author: Lachie <lachie at varnish-software.com>
Date: Wed Apr 5 12:10:29 2023 +1000
bereq: Also unset a cached req body
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index fe4f8a81e..5069cadd6 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -35,6 +35,7 @@
#include <stdio.h>
#include "cache_varnishd.h"
+#include "cache_objhead.h"
#include "cache_transport.h"
#include "common/heritage.h"
@@ -595,6 +596,11 @@ VRT_u_bereq_body(VRT_CTX)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
+ if (ctx->bo->bereq_body != NULL) {
+ HSH_DerefObjCore(ctx->bo->wrk, &ctx->bo->bereq_body, 0);
+ http_Unset(ctx->bo->bereq, H_Content_Length);
+ }
+
if (ctx->bo->req != NULL) {
CHECK_OBJ(ctx->bo->req, REQ_MAGIC);
ctx->bo->req = NULL;
diff --git a/bin/varnishtest/tests/v00068.vtc b/bin/varnishtest/tests/v00068.vtc
new file mode 100644
index 000000000..4b54a5ba0
--- /dev/null
+++ b/bin/varnishtest/tests/v00068.vtc
@@ -0,0 +1,33 @@
+varnishtest "unset bereq.body with cached req body"
+
+server s1 {
+ rxreq
+ expect req.method == "GET"
+ expect req.http.Content-Length == <undef>
+ txresp
+
+ rxreq
+ expect req.method == "GET"
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ import std;
+
+ sub vcl_recv {
+ std.cache_req_body(2KB);
+ }
+ sub vcl_backend_fetch {
+ unset bereq.body;
+ }
+} -start
+
+client c1 {
+ txreq -body "fine"
+ rxresp
+ expect resp.status == 200
+
+ txreq
+ rxresp
+ expect resp.status == 200
+} -run
More information about the varnish-commit
mailing list