Commit a490ef04 authored by Geoff Simmons's avatar Geoff Simmons

import succeeds with a Varnish 4.0.3 source tree:

- VMOD function vxid commented out, because 4.0.3 doesn't have PRIV_TASK
- VRT_selecthttp is also not exposed in 4.0.3
parent a3d2ec3d
varnishtest "vtstor-vmod: Test basic import"
server s1 {
timeout 10
rxreq
expect req.url == "/"
txresp -status 200 -hdr "foo: 1"
} -start
varnish v1 -vcl+backend {
import vtstor from "${vmod_topbuild}/src/.libs/libvmod_vtstor.so";
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.foo == 1
} -run
......@@ -32,6 +32,34 @@
#include "vtstor.h"
/*
* VRT_selecthttp is not public in Varnish <= 4.0.3.
*/
static struct http *
selecthttp(VRT_CTX, enum gethdr_e where)
{
struct http *hp;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
switch (where) {
case HDR_REQ:
hp = ctx->http_req;
break;
case HDR_BEREQ:
hp = ctx->http_bereq;
break;
case HDR_BERESP:
hp = ctx->http_beresp;
break;
case HDR_RESP:
hp = ctx->http_resp;
break;
default:
WRONG("selecthttp 'where' invalid");
}
return (hp);
}
VCL_VOID __match_proto__(td_vmod_vtstor__init)
vmod_vtstor__init(VRT_CTX,
struct vmod_vtstor_vtstor **vmip, const char *vcl_name)
......@@ -76,7 +104,7 @@ vmod_vtstor_store(VRT_CTX, struct vmod_vtstor_vtstor *vmi,
AN(hdr);
AN(hdr->what);
hp = VRT_selecthttp(ctx, hdr->where);
hp = selecthttp(ctx, hdr->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
unsigned u, l = hdr->what[0];
......@@ -96,7 +124,7 @@ vmod_vtstor_get(VRT_CTX, struct vmod_vtstor_vtstor *vmi, VCL_HEADER hdr)
AN(hdr);
AN(hdr->what);
hp = VRT_selecthttp(ctx, hdr->where);
hp = selecthttp(ctx, hdr->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
unsigned u, l = hdr->what[0];
......@@ -117,7 +145,7 @@ vmod_vtstor_delete(VRT_CTX, struct vmod_vtstor_vtstor *vmi, VCL_HEADER hdr)
AN(hdr);
AN(hdr->what);
hp = VRT_selecthttp(ctx, hdr->where);
hp = selecthttp(ctx, hdr->where);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
unsigned u, l = hdr->what[0];
......@@ -128,6 +156,7 @@ vmod_vtstor_delete(VRT_CTX, struct vmod_vtstor_vtstor *vmi, VCL_HEADER hdr)
}
}
#if 0
VCL_STRING __match_proto__(td_vmod_vxid)
vmod_vxid(VRT_CTX, struct vmod_priv *priv)
{
......@@ -140,3 +169,4 @@ vmod_vxid(VRT_CTX, struct vmod_priv *priv)
}
return(priv->priv);
}
#endif
......@@ -33,4 +33,4 @@ $Method VOID .store(STRING, HEADER)
$Method STRING .get(HEADER)
$Method VOID .delete(HEADER)
$Function STRING vxid(PRIV_TASK)
# $Function STRING vxid(PRIV_TASK)
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