[master] 58b2d30 Grow a separator argument in std.collect

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Mar 31 14:25:08 CEST 2017


commit 58b2d3061bd2e2bc9a8f45729e4fb1c2e6dc6ccb
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Mar 30 15:56:36 2017 +0200

    Grow a separator argument in std.collect
    
    Fixes #2292

diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc
index 61eed10..ab1741d 100644
--- a/lib/libvmod_std/vmod.vcc
+++ b/lib/libvmod_std/vmod.vcc
@@ -1,5 +1,5 @@
 #-
-# Copyright (c) 2010-2015 Varnish Software AS
+# Copyright (c) 2010-2017 Varnish Software AS
 # All rights reserved.
 #
 # Author: Poul-Henning Kamp <phk at FreeBSD.org>
@@ -107,17 +107,19 @@ Description
 Example
 	set beresp.http.served-by = std.fileread("/etc/hostname");
 
-$Function VOID collect(HEADER hdr)
+$Function VOID collect(HEADER hdr, STRING sep=",")
 
 Description
 	Collapses multiple *hdr* headers into one long header.
-	The header values are joined with a comma (",").
+	The header values are joined with a comma (",") unless a
+	different separator is specified.
 
 	Care should be taken when collapsing headers. In particular
 	collapsing Set-Cookie will lead to unexpected results on the
 	browser side.
-Example
-	std.collect(req.http.cookie);
+Examples
+	std.collect(req.http.accept);
+	std.collect(req.http.cookie, "; ");
 
 $Function DURATION duration(STRING s, DURATION fallback)
 
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 557e88d..601de8b 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2010-2015 Varnish Software AS
+ * Copyright (c) 2010-2017 Varnish Software AS
  * All rights reserved.
  *
  * Author: Poul-Henning Kamp <phk at FreeBSD.org>
@@ -174,13 +174,13 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...)
 }
 
 VCL_VOID __match_proto__(td_std_collect)
-vmod_collect(VRT_CTX, VCL_HEADER hdr)
+vmod_collect(VRT_CTX, VCL_HEADER hdr, VCL_STRING sep)
 {
 	struct http *hp;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	hp = VRT_selecthttp(ctx, hdr->where);
-	http_CollectHdr(hp, hdr->what);
+	http_CollectHdrSep(hp, hdr->what, sep);
 }
 
 VCL_BOOL __match_proto__(td_std_healthy)



More information about the varnish-commit mailing list