Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-etag
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-etag
Commits
48173050
Commit
48173050
authored
Apr 16, 2019
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basically working
parent
86c817ef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
35 deletions
+25
-35
vfp_bodyhash.c
src/vfp_bodyhash.c
+0
-20
vfp_bodyhash.h
src/vfp_bodyhash.h
+1
-1
vmod_etag.c
src/vmod_etag.c
+8
-4
vmod_etag.vcc
src/vmod_etag.vcc
+1
-4
vmod_etag.vtc
src/vtc/vmod_etag.vtc
+15
-6
No files found.
src/vfp_bodyhash.c
View file @
48173050
...
...
@@ -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
);
}
src/vfp_bodyhash.h
View file @
48173050
...
...
@@ -25,4 +25,4 @@
*
*/
void
*
Bodyhash_push
(
struct
vfp_ctx
*
vc
,
const
char
*
hdr
)
;
extern
const
struct
vfp
VFP_bodyhash
;
src/vmod_etag.c
View file @
48173050
#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
);
}
src/vmod_etag.vcc
View file @
48173050
...
...
@@ -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)
src/vtc/vmod_etag.vtc
View file @
48173050
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment