[master] 3287799 Remove blob operations from vmod-vtc

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Sep 4 21:01:10 CEST 2017


commit 32877991a478ee807ef0dd0f0742804ec89eb2cd
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Mon Sep 4 20:41:33 2017 +0200

    Remove blob operations from vmod-vtc
    
    They were inherited from vmod-debug, from a time when vmod-blob didn't
    exist in the source tree.
    
    Refs #2362
    Refs #2402
    Refs #2407

diff --git a/bin/varnishtest/tests/b00051.vtc b/bin/varnishtest/tests/b00051.vtc
index 1ec12a1..ffa5bc5 100644
--- a/bin/varnishtest/tests/b00051.vtc
+++ b/bin/varnishtest/tests/b00051.vtc
@@ -6,12 +6,13 @@ server s1 {
 } -start
 
 varnish v1 -vcl+backend {
-	import vtc;
+	import blob;
+
 	sub vcl_backend_response {
-		set beresp.http.bereq_hash = vtc.blob2hex(bereq.hash);
+		set beresp.http.bereq_hash = blob.encode(HEXLC, bereq.hash);
 	}
 	sub vcl_deliver {
-		set resp.http.req_hash = vtc.blob2hex(req.hash);
+		set resp.http.req_hash = blob.encode(HEXLC, req.hash);
 	}
 } -start
 
diff --git a/bin/varnishtest/tests/m00012.vtc b/bin/varnishtest/tests/m00012.vtc
index 276fa08..294458c 100644
--- a/bin/varnishtest/tests/m00012.vtc
+++ b/bin/varnishtest/tests/m00012.vtc
@@ -1,44 +1,21 @@
 varnishtest "Test VMOD BLOBS"
 
-server s1 {
-	rxreq
-	txresp
-} -start
-
-varnish v1 -vcl+backend {
-	import vtc;
-
-	sub vcl_deliver {
-		set resp.http.foo = vtc.blob2hex(vtc.str2blob("gunk"));
-	}
-} -start
-
-client c1 {
-	txreq
-	rxresp
-	expect resp.http.foo == 67756e6b
-} -run
-
-delay .1
-
 varnish v1 -errvcl {BLOBs can only be used as arguments to VMOD functions.} {
 
-	backend b1 {.host = "127.0.0.1";}
-
-	import vtc;
+	backend b1 {.host = "${bad_backend}";}
 
 	sub vcl_deliver {
-		set resp.http.foo = vtc.str2blob("gunk");
+		set resp.http.foo = req.hash;
 	}
 }
 
 varnish v1 -errvcl {Wrong argument type.  Expected BLOB.  Got STRING.} {
 
-	backend b1 {.host = "127.0.0.1";}
+	backend b1 {.host = "${bad_backend}";}
 
-	import vtc;
+	import blob;
 
 	sub vcl_deliver {
-		set resp.http.foo = vtc.blob2hex("gunk");
+		blob.encode(blob = "blob");
 	}
 }
diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc
index 77dcefa..ba2dd54 100644
--- a/bin/varnishtest/tests/v00020.vtc
+++ b/bin/varnishtest/tests/v00020.vtc
@@ -219,18 +219,18 @@ varnish v1 -errvcl {Function returns VOID} {
 }
 
 varnish v1 -errvcl {'req.hash': Not available in method 'vcl_recv'.} {
+	import blob;
 	backend b { .host = "127.0.0.1"; }
-	import vtc;
 	sub vcl_recv {
-		set req.http.foo = vtc.blob2hex(req.hash);
+		blob.encode(HEXLC, req.hash);
 	}
 }
 
 varnish v1 -errvcl {'req.hash': Not available in method 'vcl_hash'.} {
+	import blob;
 	backend b { .host = "127.0.0.1"; }
-	import vtc;
 	sub vcl_hash {
-		set req.http.foo = vtc.blob2hex(req.hash);
+		blob.encode(HEXLC, req.hash);
 	}
 }
 
@@ -255,9 +255,9 @@ varnish v1 -errvcl {Expected 'from path ...'} {
 }
 
 varnish v1 -errvcl {INT * BLOB not possible.} {
-	import vtc;
+	import blob;
 	sub vcl_deliver {
-		set resp.status = 100 * vtc.str2blob("a");
+		set resp.status = 100 * blob.decode(HEX, "a");
 	}
 }
 
diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc
index a616c30..b57a794 100644
--- a/lib/libvmod_vtc/vmod.vcc
+++ b/lib/libvmod_vtc/vmod.vcc
@@ -128,20 +128,6 @@ Returns the size in bytes of a collection of C-datatypes:
 
 This can be useful for VMOD authors in conjunction with workspace operations.
 
-BLOBS
-=====
-
-For VMODs dealing with BLOB arguments or return values, the following functions
-offer convenience conversions to and from STRING.
-
-$Function BLOB str2blob(STRING src)
-
-Turn a string into a blob.
-
-$Function STRING blob2hex(BLOB src)
-
-Hexdump a blob.
-
 SEE ALSO
 ========
 
diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c
index c4e18cf..e1afcf8 100644
--- a/lib/libvmod_vtc/vmod_vtc.c
+++ b/lib/libvmod_vtc/vmod_vtc.c
@@ -221,42 +221,3 @@ vmod_typesize(VRT_CTX, VCL_STRING s)
 	}
 	return (i);
 }
-
-/*--------------------------------------------------------------------*/
-
-VCL_BLOB __match_proto__(td_vtc_str2blob)
-vmod_str2blob(VRT_CTX, VCL_STRING s)
-{
-	struct vmod_priv *p;
-
-	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-
-	p = WS_Alloc(ctx->ws, sizeof *p);
-	AN(p);
-	memset(p, 0, sizeof *p);
-	p->len = strlen(s);
-	p->priv = WS_Copy(ctx->ws, s, -1);
-	return (p);
-}
-
-VCL_STRING __match_proto__(td_vtc_blob2hex)
-vmod_blob2hex(VRT_CTX, VCL_BLOB b)
-{
-	char *s, *p;
-	uint8_t *q;
-	int i;
-
-	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
-
-	s = WS_Alloc(ctx->ws, b->len * 2 + 2);
-	AN(s);
-	p = s;
-	q = b->priv;
-	for (i = 0; i < b->len; i++) {
-		assert(snprintf(p, 3, "%02x", *q) == 2);
-		p += 2;
-		q += 1;
-	}
-	VRT_priv_fini(b);
-	return (s);
-}



More information about the varnish-commit mailing list