Commit 1cc6c652 authored by Geoff Simmons's avatar Geoff Simmons

add a function for the version string and a "basic" VTC

parent d17f5740
# looks like -*- perl -*-
varnishtest "vcl.use and .discard, and version string"
server s1 {
} -start
varnish v1 -vcl+backend {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
} -start
varnish v1 -vcl+backend {
}
varnish v1 -cli "vcl.list"
varnish v1 -cli "vcl.use vcl1"
varnish v1 -cli "vcl.use vcl2"
varnish v1 -cli "vcl.use vcl1"
varnish v1 -cli "vcl.show vcl1"
varnish v1 -cli "vcl.use vcl2"
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -cli "vcl.list"
varnish v1 -vcl {
import blobcode from "${vmod_topbuild}/src/.libs/libvmod_blobcode.so";
backend b { .host = "${bad_ip}"; }
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
set resp.http.x-version = blobcode.version();
if (!resp.http.x-version) {
set resp.status = 500;
}
return(deliver);
}
}
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.x-version ~ "^.+$"
} -run
......@@ -29,6 +29,8 @@
#include <errno.h>
#include <pthread.h>
#include "config.h"
#include "vcl.h"
#include "vrt.h"
......@@ -487,3 +489,9 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, const char *p, ...) {
wb_advance(&wb, len);
return wb_finish(&wb, NULL);
}
VCL_STRING __match_proto__(td_blobcode_version)
vmod_version(VRT_CTX __attribute__((unused)))
{
return VERSION;
}
......@@ -173,6 +173,14 @@ Example
``set req.http.Hex2Base64 = blobcode.transcode(decoding=HEX,``
``encoding=BASE64, encoded="666f6f");``
$Function STRING version()
Description
Returns the version string for this VMOD.
Example
``std.log("Using VMOD blobcode version " + blobcode.version());``
$Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX} decoding,
STRING_LIST encoded)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment