...
 
Commits (2)
......@@ -3,7 +3,7 @@
varnishtest "test various custom parameter settings"
server s1 {
loop 3 {
loop 5 {
rxreq
txresp -body {Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.}
}
......@@ -81,6 +81,41 @@ varnish v1 -errvcl {vfp brotli failure: new err: quality 12 out of range (0 to 1
}
}
# Large window
varnish v1 -vcl+backend {
import ${vmod_brotli};
sub vcl_init {
new mybr = brotli.decoder("unbr_largewin", large_win=true);
}
sub vcl_backend_response {
set beresp.filters = "br unbr_largewin";
set beresp.uncacheable = true;
}
}
client c1 -run
# Encoder with large_win only works if the decoder is also set to
# large_win=true.
varnish v1 -vcl+backend {
import ${vmod_brotli};
sub vcl_init {
new br_large = brotli.encoder("br_largewin", large_win=true);
new unbr_large = brotli.decoder("unbr_largewin", large_win=true);
}
sub vcl_backend_response {
set beresp.filters = "br_largewin unbr_largewin";
set beresp.uncacheable = true;
}
}
client c1 -run
logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
expect 0 * Begin bereq
expect * = VfpAcct {^unbr \d+ 269$}
......@@ -96,4 +131,14 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
expect * = VfpAcct {^unbr \d+ 269$}
expect * = VfpAcct {^br_q11 \d+ \d+$}
expect * = End
expect 0 * Begin bereq
expect * = VfpAcct {^unbr_largewin \d+ 269$}
expect * = VfpAcct {^br \d+ \d+$}
expect * = End
expect 0 * Begin bereq
expect * = VfpAcct {^unbr_largewin \d+ 269$}
expect * = VfpAcct {^br_largewin \d+ \d+$}
expect * = End
} -run
......@@ -78,6 +78,7 @@ struct vbr_settings {
#define VBR_SETTINGS_MAGIC 0xa61992aa
VCL_BYTES bufsz;
uint32_t quality;
uint32_t large_win;
enum vbr_which which;
};
......@@ -148,13 +149,18 @@ setEncoderParams(struct vbr *vbr, const struct vbr_settings *settings)
CHECK_OBJ_NOTNULL(settings, VBR_SETTINGS_MAGIC);
assert(BrotliEncoderSetParameter(vbr->state.enc, BROTLI_PARAM_QUALITY,
settings->quality) == BROTLI_TRUE);
assert(BrotliEncoderSetParameter(vbr->state.enc,
BROTLI_PARAM_LARGE_WINDOW,
settings->large_win) == BROTLI_TRUE);
}
static void
setDecoderParams(struct vbr *vbr, const struct vbr_settings *settings)
{
(void) vbr;
(void) settings;
CHECK_OBJ_NOTNULL(settings, VBR_SETTINGS_MAGIC);
assert(BrotliDecoderSetParameter(vbr->state.dec,
BROTLI_DECODER_PARAM_LARGE_WINDOW,
settings->large_win) == BROTLI_TRUE);
}
static inline void
......@@ -615,7 +621,8 @@ coder_init(VRT_CTX, const char *vcl_name, struct vmod_priv *priv,
VCL_VOID
vmod_encoder__init(VRT_CTX, struct vmod_brotli_encoder **encp,
const char *vcl_name, struct vmod_priv *priv,
VCL_STRING filter_name, VCL_BYTES bufsz, VCL_INT quality)
VCL_STRING filter_name, VCL_BYTES bufsz, VCL_INT quality,
VCL_BOOL large_win)
{
struct vmod_brotli_encoder *enc;
struct vfp *vfp = NULL;
......@@ -649,6 +656,7 @@ vmod_encoder__init(VRT_CTX, struct vmod_brotli_encoder **encp,
VRT_AddVFP(ctx, vfp);
settings->which = ENC;
settings->quality = quality;
settings->large_win = large_win;
enc->vfp = vfp;
}
......@@ -675,7 +683,7 @@ vmod_encoder__fini(struct vmod_brotli_encoder **encp)
VCL_VOID
vmod_decoder__init(VRT_CTX, struct vmod_brotli_decoder **decp,
const char *vcl_name, struct vmod_priv *priv,
VCL_STRING filter_name, VCL_BYTES bufsz)
VCL_STRING filter_name, VCL_BYTES bufsz, VCL_BOOL large_win)
{
struct vmod_brotli_decoder *dec;
struct vfp *vfp = NULL;
......@@ -701,6 +709,7 @@ vmod_decoder__init(VRT_CTX, struct vmod_brotli_decoder **decp,
vfp->pull = vfp_unbr_pull;
VRT_AddVFP(ctx, vfp);
settings->which = DEC;
settings->large_win = large_win;
dec->vfp = vfp;
}
......
......@@ -66,11 +66,12 @@ algorithm for responses fetched from backends.
XXX ...
$Object encoder(PRIV_VCL, STRING name, BYTES bufffer=32768, INT quality=11)
$Object encoder(PRIV_VCL, STRING name, BYTES bufffer=32768, INT quality=11,
BOOL large_win=0)
XXX ...
$Object decoder(PRIV_VCL, STRING name, BYTES buffer=32768)
$Object decoder(PRIV_VCL, STRING name, BYTES buffer=32768, BOOL large_win=0)
XXX ...
......