Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
3f533abb
Commit
3f533abb
authored
Oct 11, 2018
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collect everything related to beresp.filter_list in one source file
parent
33ec7d09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
124 additions
and
123 deletions
+124
-123
cache_fetch.c
bin/varnishd/cache/cache_fetch.c
+0
-91
cache_vrt_filter.c
bin/varnishd/cache/cache_vrt_filter.c
+124
-0
cache_vrt_var.c
bin/varnishd/cache/cache_vrt_var.c
+0
-32
No files found.
bin/varnishd/cache/cache_fetch.c
View file @
3f533abb
...
...
@@ -498,97 +498,6 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
ObjTrimStore
(
wrk
,
vfc
->
oc
);
return
(
F_STP_FETCHEND
);
}
/*--------------------------------------------------------------------
*/
static
void
vbf_default_filter_list
(
const
struct
busyobj
*
bo
,
struct
vsb
*
vsb
)
{
const
char
*
p
;
int
do_gzip
=
bo
->
do_gzip
;
int
do_gunzip
=
bo
->
do_gunzip
;
int
is_gzip
=
0
,
is_gunzip
=
0
;
/*
* The VCL variables beresp.do_g[un]zip tells us how we want the
* object processed before it is stored.
*
* The backend Content-Encoding header tells us what we are going
* to receive, which we classify in the following three classes:
*
* "Content-Encoding: gzip" --> object is gzip'ed.
* no Content-Encoding --> object is not gzip'ed.
* anything else --> do nothing wrt gzip
*/
/* No body -> done */
if
(
bo
->
htc
->
body_status
==
BS_NONE
||
bo
->
htc
->
content_length
==
0
)
return
;
if
(
!
cache_param
->
http_gzip_support
)
do_gzip
=
do_gunzip
=
0
;
if
(
http_GetHdr
(
bo
->
beresp
,
H_Content_Encoding
,
&
p
))
is_gzip
=
!
strcasecmp
(
p
,
"gzip"
);
else
is_gunzip
=
1
;
/* We won't gunzip unless it is gzip'ed */
if
(
do_gunzip
&&
!
is_gzip
)
do_gunzip
=
0
;
/* We wont gzip unless if it already is gzip'ed */
if
(
do_gzip
&&
!
is_gunzip
)
do_gzip
=
0
;
if
(
do_gunzip
||
(
is_gzip
&&
bo
->
do_esi
))
VSB_cat
(
vsb
,
" gunzip"
);
if
(
bo
->
do_esi
&&
(
do_gzip
||
(
is_gzip
&&
!
do_gunzip
)))
{
VSB_cat
(
vsb
,
" esi_gzip"
);
return
;
}
if
(
bo
->
do_esi
)
{
VSB_cat
(
vsb
,
" esi"
);
return
;
}
if
(
do_gzip
)
VSB_cat
(
vsb
,
" gzip"
);
if
(
is_gzip
&&
!
do_gunzip
)
VSB_cat
(
vsb
,
" testgunzip"
);
}
const
char
*
VBF_Get_Filter_List
(
struct
busyobj
*
bo
)
{
unsigned
u
;
struct
vsb
vsb
[
1
];
u
=
WS_Reserve
(
bo
->
ws
,
0
);
if
(
u
==
0
)
{
WS_Release
(
bo
->
ws
,
0
);
WS_MarkOverflow
(
bo
->
ws
);
return
(
NULL
);
}
AN
(
VSB_new
(
vsb
,
bo
->
ws
->
f
,
u
,
VSB_FIXEDLEN
));
vbf_default_filter_list
(
bo
,
vsb
);
if
(
VSB_finish
(
vsb
))
{
WS_Release
(
bo
->
ws
,
0
);
WS_MarkOverflow
(
bo
->
ws
);
return
(
NULL
);
}
if
(
VSB_len
(
vsb
))
{
WS_Release
(
bo
->
ws
,
VSB_len
(
vsb
)
+
1
);
return
(
VSB_data
(
vsb
)
+
1
);
}
WS_Release
(
bo
->
ws
,
0
);
return
(
""
);
}
static
enum
fetch_step
vbf_stp_fetch
(
struct
worker
*
wrk
,
struct
busyobj
*
bo
)
{
...
...
bin/varnishd/cache/cache_vrt_filter.c
View file @
3f533abb
...
...
@@ -36,8 +36,10 @@
#include <stdlib.h>
#include "vct.h"
#include "cache_varnishd.h"
#include "cache_vcl.h"
#include "vrt_obj.h"
#include "cache_filter.h"
...
...
@@ -142,3 +144,125 @@ VCL_VRT_Init(void)
VRT_AddVFP
(
NULL
,
&
VFP_esi
);
VRT_AddVFP
(
NULL
,
&
VFP_esi_gzip
);
}
/*--------------------------------------------------------------------
*/
static
void
vbf_default_filter_list
(
const
struct
busyobj
*
bo
,
struct
vsb
*
vsb
)
{
const
char
*
p
;
int
do_gzip
=
bo
->
do_gzip
;
int
do_gunzip
=
bo
->
do_gunzip
;
int
is_gzip
=
0
,
is_gunzip
=
0
;
/*
* The VCL variables beresp.do_g[un]zip tells us how we want the
* object processed before it is stored.
*
* The backend Content-Encoding header tells us what we are going
* to receive, which we classify in the following three classes:
*
* "Content-Encoding: gzip" --> object is gzip'ed.
* no Content-Encoding --> object is not gzip'ed.
* anything else --> do nothing wrt gzip
*/
/* No body -> done */
if
(
bo
->
htc
->
body_status
==
BS_NONE
||
bo
->
htc
->
content_length
==
0
)
return
;
if
(
!
cache_param
->
http_gzip_support
)
do_gzip
=
do_gunzip
=
0
;
if
(
http_GetHdr
(
bo
->
beresp
,
H_Content_Encoding
,
&
p
))
is_gzip
=
!
strcasecmp
(
p
,
"gzip"
);
else
is_gunzip
=
1
;
/* We won't gunzip unless it is gzip'ed */
if
(
do_gunzip
&&
!
is_gzip
)
do_gunzip
=
0
;
/* We wont gzip unless if it already is gzip'ed */
if
(
do_gzip
&&
!
is_gunzip
)
do_gzip
=
0
;
if
(
do_gunzip
||
(
is_gzip
&&
bo
->
do_esi
))
VSB_cat
(
vsb
,
" gunzip"
);
if
(
bo
->
do_esi
&&
(
do_gzip
||
(
is_gzip
&&
!
do_gunzip
)))
{
VSB_cat
(
vsb
,
" esi_gzip"
);
return
;
}
if
(
bo
->
do_esi
)
{
VSB_cat
(
vsb
,
" esi"
);
return
;
}
if
(
do_gzip
)
VSB_cat
(
vsb
,
" gzip"
);
if
(
is_gzip
&&
!
do_gunzip
)
VSB_cat
(
vsb
,
" testgunzip"
);
}
const
char
*
VBF_Get_Filter_List
(
struct
busyobj
*
bo
)
{
unsigned
u
;
struct
vsb
vsb
[
1
];
u
=
WS_Reserve
(
bo
->
ws
,
0
);
if
(
u
==
0
)
{
WS_Release
(
bo
->
ws
,
0
);
WS_MarkOverflow
(
bo
->
ws
);
return
(
NULL
);
}
AN
(
VSB_new
(
vsb
,
bo
->
ws
->
f
,
u
,
VSB_FIXEDLEN
));
vbf_default_filter_list
(
bo
,
vsb
);
if
(
VSB_finish
(
vsb
))
{
WS_Release
(
bo
->
ws
,
0
);
WS_MarkOverflow
(
bo
->
ws
);
return
(
NULL
);
}
if
(
VSB_len
(
vsb
))
{
WS_Release
(
bo
->
ws
,
VSB_len
(
vsb
)
+
1
);
return
(
VSB_data
(
vsb
)
+
1
);
}
WS_Release
(
bo
->
ws
,
0
);
return
(
""
);
}
/*--------------------------------------------------------------------*/
VCL_STRING
VRT_r_beresp_filters
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
if
(
ctx
->
bo
->
filter_list
!=
NULL
)
return
(
ctx
->
bo
->
filter_list
);
/* We do not set bo->filter_list yet, things might still change */
return
(
VBF_Get_Filter_List
(
ctx
->
bo
));
}
VCL_VOID
VRT_l_beresp_filters
(
VRT_CTX
,
const
char
*
str
,
...)
{
va_list
ap
;
const
char
*
b
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
va_start
(
ap
,
str
);
b
=
VRT_String
(
ctx
->
bo
->
ws
,
NULL
,
str
,
ap
);
va_end
(
ap
);
if
(
b
==
NULL
)
{
WS_MarkOverflow
(
ctx
->
bo
->
ws
);
return
;
}
ctx
->
bo
->
filter_list
=
b
;
}
bin/varnishd/cache/cache_vrt_var.c
View file @
3f533abb
...
...
@@ -922,35 +922,3 @@ HTTP_VAR(req)
HTTP_VAR
(
resp
)
HTTP_VAR
(
bereq
)
HTTP_VAR
(
beresp
)
/*--------------------------------------------------------------------*/
VCL_STRING
VRT_r_beresp_filters
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
if
(
ctx
->
bo
->
filter_list
!=
NULL
)
return
(
ctx
->
bo
->
filter_list
);
/* We do not set bo->filter_list yet, things might still change */
return
(
VBF_Get_Filter_List
(
ctx
->
bo
));
}
VCL_VOID
VRT_l_beresp_filters
(
VRT_CTX
,
const
char
*
str
,
...)
{
va_list
ap
;
const
char
*
b
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
bo
,
BUSYOBJ_MAGIC
);
va_start
(
ap
,
str
);
b
=
VRT_String
(
ctx
->
bo
->
ws
,
NULL
,
str
,
ap
);
va_end
(
ap
);
if
(
b
==
NULL
)
{
WS_MarkOverflow
(
ctx
->
bo
->
ws
);
return
;
}
ctx
->
bo
->
filter_list
=
b
;
}
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