Commit 48173050 authored by Nils Goroll's avatar Nils Goroll

basically working

parent 86c817ef
......@@ -43,7 +43,6 @@ struct bodyhash {
#define BODYHASH_MAGIC 0xb0d16a56
struct VSHA256Context sha256ctx;
char *hdr;
// unsigned char hash[VSHA256_LEN];
};
......@@ -59,7 +58,6 @@ vfp_bodyhash_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
AN(vfe->priv1);
assert(vfe->vfp == &VFP_bodyhash);
assert(placeholder_l == VSHA256_LEN * 2 + 2);
......@@ -68,7 +66,6 @@ vfp_bodyhash_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
if (bh == NULL)
return (VFP_ERROR);
VSHA256_Init(&bh->sha256ctx);
bh->hdr = vfe->priv1;
vfe->priv1 = bh;
http_ForceHeader(vc->resp, H_ETag, placeholder);
......@@ -132,11 +129,6 @@ vfp_bodyhash_fini(struct vfp_ctx *vc, struct vfp_entry *vfe)
*p++ = '\0';
assert(pdiff(hex, p) == hexl);
if (vc->resp) {
http_ForceHeader(vc->resp, H_ETag, hex);
goto out;
}
// HACKY
p = TRUST_ME(ObjGetAttr(vc->wrk, vc->oc, OA_HEADERS, &l));
if (p == NULL) {
......@@ -178,15 +170,3 @@ const struct vfp VFP_bodyhash = {
.pull = vfp_bodyhash_pull,
.fini = vfp_bodyhash_fini
};
// XXX in cache_varnishd.h
struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *);
void *
Bodyhash_push(struct vfp_ctx *vc, const char *hdr)
{
struct vfp_entry *vfe = VFP_Push(vc, &VFP_bodyhash);
if (vfe)
vfe->priv1 = TRUST_ME(hdr);
return (vfe);
}
......@@ -25,4 +25,4 @@
*
*/
void *Bodyhash_push(struct vfp_ctx *vc, const char *hdr);
extern const struct vfp VFP_bodyhash;
#include "config.h"
#include <cache/cache.h>
#include <cache/cache_filter.h>
#include "vcc_etag_if.h"
#include "vfp_bodyhash.h"
VCL_STRING
vmod_hello(VRT_CTX)
int
vmod_event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
{
if (e != VCL_EVENT_LOAD)
return (0);
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
return ("vmod-etag");
VRT_AddVFP(ctx, &VFP_bodyhash);
return (0);
}
......@@ -19,10 +19,7 @@ Example
XXX: define vmod-etag interface
$Function STRING hello()
Description
Hello world for vmod-etag
$Event event_function
SEE ALSO
========vcl\(7),varnishd\(1)
......@@ -2,20 +2,29 @@ varnishtest "test vmod-etag"
server s1 {
rxreq
txresp
txresp -bodylen 1048576
} -start
varnish v1 -vcl+backend {
import etag;
import etag;
sub vcl_deliver {
set resp.http.Hello = etag.hello();
}
sub vcl_backend_response {
set beresp.filters = beresp.filters + " bodyhash";
}
sub vcl_deliver {
# XXX racy
if (resp.http.Etag ~ "placeholder") {
unset resp.http.Etag;
}
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.http.Hello == "vmod-etag"
txreq
rxresp
expect resp.status == 200
} -run
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