[master] c62f60216 http: Add a function to append a value to a header
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Fri Aug 5 09:24:07 UTC 2022
commit c62f60216f5b88b04db85f44cb0b8a529f890d66
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Tue Jul 26 10:33:37 2022 +0200
http: Add a function to append a value to a header
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index cb69f2c2c..3ef0512bf 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -601,6 +601,7 @@ void http_FilterReq(struct http *to, const struct http *fm, unsigned how);
void HTTP_Encode(const struct http *fm, uint8_t *, unsigned len, unsigned how);
int HTTP_Decode(struct http *to, const uint8_t *fm);
void http_ForceHeader(struct http *to, hdr_t, const char *val);
+void http_AppendHeader(struct http *to, hdr_t, const char *val);
void http_PrintfHeader(struct http *to, const char *fmt, ...)
v_printflike_(2, 3);
void http_TimeHeader(struct http *to, const char *fmt, vtim_real now);
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 7c6a127f6..e2f8ba726 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -1478,6 +1478,20 @@ http_ForceHeader(struct http *to, hdr_t hdr, const char *val)
http_PrintfHeader(to, "%s %s", hdr + 1, val);
}
+void
+http_AppendHeader(struct http *to, hdr_t hdr, const char *val)
+{
+ const char *old;
+
+ http_CollectHdr(to, hdr);
+ if (http_GetHdr(to, hdr, &old)) {
+ http_Unset(to, hdr);
+ http_PrintfHeader(to, "%s %s, %s", hdr + 1, old, val);
+ } else {
+ http_PrintfHeader(to, "%s %s", hdr + 1, val);
+ }
+}
+
void
http_PrintfHeader(struct http *to, const char *fmt, ...)
{
More information about the varnish-commit
mailing list