Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-zipflow
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-zipflow
Commits
c9502dc4
Unverified
Commit
c9502dc4
authored
Jul 25, 2023
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic implementation of zipflow.bundle, support empty zips
parent
4c416624
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
4 deletions
+44
-4
Makefile.am
src/Makefile.am
+2
-1
vmod_zipflow.c
src/vmod_zipflow.c
+17
-3
empty.vtc
src/vtc/empty.vtc
+25
-0
No files found.
src/Makefile.am
View file @
c9502dc4
...
...
@@ -27,7 +27,8 @@ AM_VTC_LOG_FLAGS = \
-p
vmod_path
=
"
$(abs_builddir)
/.libs:
$(vmoddir)
:
$(VARNISHAPI_VMODDIR)
"
TESTS
=
\
vtc/vmod_zipflow.vtc
vtc/vmod_zipflow.vtc
\
vtc/empty.vtc
# Documentation
...
...
src/vmod_zipflow.c
View file @
c9502dc4
...
...
@@ -64,6 +64,7 @@ static const void *zipflow_priv = &zipflow_priv;
struct
zipflow_task
{
unsigned
magic
;
#define ZIPFLOW_TASK_MAGIC 0xaa175160
unsigned
bundle
:
1
;
char
level
;
VCL_STRING
name
;
unsigned
mode
;
...
...
@@ -94,6 +95,7 @@ get_zipflow_task(VRT_CTX)
if
(
zft
==
NULL
)
return
(
NULL
);
zft
->
bundle
=
1
;
zft
->
level
=
default_level
;
zft
->
name
=
"unnamed_file"
;
zft
->
mode
=
0644
;
...
...
@@ -129,10 +131,15 @@ vmod_is_subreq(VRT_CTX)
VCL_VOID
vmod_bundle
(
VRT_CTX
,
VCL_BOOL
toggle
)
{
struct
zipflow_task
*
zft
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
// XXX TODO
(
void
)
toggle
;
zft
=
get_zipflow_task
(
ctx
);
if
(
zft
==
NULL
)
return
;
zft
->
bundle
=
toggle
?
1
:
0
;
}
VCL_VOID
...
...
@@ -253,7 +260,10 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
return
(
1
);
}
AZ
(
zip_log
(
zft
->
zip
,
vdc
->
vsl
,
vdp_zipflow_log
));
AZ
(
zip_meta
(
zft
->
zip
,
zft
->
name
,
3
,
zft
->
mode
,
zft
->
atime
,
zft
->
mtime
));
if
(
zft
->
bundle
)
{
AZ
(
zip_meta
(
zft
->
zip
,
zft
->
name
,
3
,
zft
->
mode
,
zft
->
atime
,
zft
->
mtime
));
}
AN
(
priv
);
AZ
(
*
priv
);
...
...
@@ -296,6 +306,10 @@ vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, void **priv,
AN
(
priv
);
CAST_OBJ_NOTNULL
(
zft
,
*
priv
,
ZIPFLOW_TASK_MAGIC
);
if
(
zft
->
bundle
==
0
)
{
(
void
)
zip_close
(
zft
->
zip
);
return
(
1
);
}
r
=
zip_data
(
zft
->
zip
,
ptr
,
len
,
act
==
VDP_END
);
if
(
r
)
{
VSLb
(
vdc
->
vsl
,
SLT_Error
,
"zip_data returned %d"
,
r
);
...
...
src/vtc/empty.vtc
0 → 100644
View file @
c9502dc4
varnishtest "test vmod-zipflow: empty zip file"
server s1 {
rxreq
txresp -body "zip file content"
} -start
varnish v1 -vcl+backend {
import zipflow;
sub vcl_deliver {
zipflow.bundle(false);
zipflow.meta("filename", mode="444", atime=now, mtime=now - 1d);
set resp.filters += " zipflow";
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -run
shell -exit 1 -expect {zipfile is empty} \
"curl -svo t.zip -H 'Host: ${v1_addr}' http://${v1_addr}:${v1_port}/ && unzip -l t.zip"
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