[master] dd16b6d0c Add VRT_UnsetHdr() and remove vrt_magic_string_unset
Poul-Henning Kamp
phk at FreeBSD.org
Thu Aug 19 06:31:07 UTC 2021
commit dd16b6d0c54e13093acc29652b9e3e5a237c1115
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Aug 19 06:29:09 2021 +0000
Add VRT_UnsetHdr() and remove vrt_magic_string_unset
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 8d8ab859b..17e406edf 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -55,7 +55,6 @@
#include "proxy/cache_proxy.h"
const void * const vrt_magic_string_end = &vrt_magic_string_end;
-const void * const vrt_magic_string_unset = &vrt_magic_string_unset;
const struct strands *vrt_null_strands = &(struct strands){
.n = 0,
.p = (const char *[1]){NULL}
@@ -691,6 +690,19 @@ VRT_ValidHdr(VRT_CTX, VCL_STRANDS s)
}
/*--------------------------------------------------------------------*/
+VCL_VOID
+VRT_UnsetHdr(VRT_CTX , VCL_HEADER hs)
+{
+ VCL_HTTP hp;
+
+ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ AN(hs);
+ AN(hs->what);
+ hp = VRT_selecthttp(ctx, hs->where);
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ http_Unset(hp, hs->what);
+}
+
VCL_VOID
VRT_SetHdr(VRT_CTX , VCL_HEADER hs, const char *p, ...)
{
@@ -703,23 +715,19 @@ VRT_SetHdr(VRT_CTX , VCL_HEADER hs, const char *p, ...)
AN(hs->what);
hp = VRT_selecthttp(ctx, hs->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- if (p == vrt_magic_string_unset) {
- http_Unset(hp, hs->what);
- } else {
- va_start(ap, p);
- b = VRT_String(hp->ws, hs->what + 1, p, ap);
- va_end(ap);
- if (b == NULL) {
- VSLb(ctx->vsl, SLT_LostHeader, "%s", hs->what + 1);
- return;
- }
- if (FEATURE(FEATURE_VALIDATE_HEADERS) && ! validhdr(b)) {
- VRT_fail(ctx, "Bad header %s", b);
- return;
- }
- http_Unset(hp, hs->what);
- http_SetHeader(hp, b);
+ va_start(ap, p);
+ b = VRT_String(hp->ws, hs->what + 1, p, ap);
+ va_end(ap);
+ if (b == NULL) {
+ VSLb(ctx->vsl, SLT_LostHeader, "%s", hs->what + 1);
+ return;
+ }
+ if (FEATURE(FEATURE_VALIDATE_HEADERS) && ! validhdr(b)) {
+ VRT_fail(ctx, "Bad header %s", b);
+ return;
}
+ http_Unset(hp, hs->what);
+ http_SetHeader(hp, b);
}
/*--------------------------------------------------------------------*/
diff --git a/include/vrt.h b/include/vrt.h
index 4019f7e57..8c6678935 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -54,6 +54,8 @@
* binary/load-time compatible, increment MAJOR version
*
* NEXT (2021-09-15)
+ * VRT_UnsetHdr() added
+ * vrt_magic_string_unset removed (use VRT_UnsetHdr() instead)
* VNUMpfx() removed, SF_Parse_{Integer|Decimal|Number} added
* vrt_null_strands added
* vrt_null_blob added
@@ -593,6 +595,7 @@ VCL_VOID VRT_synth(VRT_CTX, VCL_INT, VCL_STRING);
VCL_VOID VRT_hit_for_pass(VRT_CTX, VCL_DURATION);
VCL_BOOL VRT_ValidHdr(VRT_CTX, VCL_STRANDS);
+VCL_VOID VRT_UnsetHdr(VRT_CTX, VCL_HEADER);
VCL_VOID VRT_SetHdr(VRT_CTX, VCL_HEADER, const char *, ...);
VCL_VOID VRT_handling(VRT_CTX, unsigned hand);
unsigned VRT_handled(VRT_CTX);
@@ -709,5 +712,4 @@ void VRT_VCL_Allow_Discard(struct vclref **);
VCL_VOID VRT_synth_page(VRT_CTX, VCL_STRANDS);
extern const void * const vrt_magic_string_end;
-extern const void * const vrt_magic_string_unset;
int VRT_Stv(const char *nm);
diff --git a/lib/libvcc/vcc_var.c b/lib/libvcc/vcc_var.c
index c71831bd6..286949e49 100644
--- a/lib/libvcc/vcc_var.c
+++ b/lib/libvcc/vcc_var.c
@@ -93,8 +93,7 @@ vcc_Var_Wildcard(struct vcc *tl, struct symbol *parent, struct symbol *sym)
AZ(VSB_finish(vsb));
sym->lname = TlDup(tl, VSB_data(vsb));
VSB_clear(vsb);
- VSB_printf(vsb, "VRT_SetHdr(ctx, %s, vrt_magic_string_unset)",
- sym->rname);
+ VSB_printf(vsb, "VRT_UnsetHdr(ctx, %s)", sym->rname);
AZ(VSB_finish(vsb));
sym->uname = TlDup(tl, VSB_data(vsb));
VSB_destroy(&vsb);
More information about the varnish-commit
mailing list