Commit 888cf588 authored by Geoff Simmons's avatar Geoff Simmons

Add the encoder parameter lgwin.

parent 495d5596
......@@ -72,27 +72,33 @@ XXX ...
.. _vmod_brotli.encoder:
new xencoder = brotli.encoder(STRING name, BYTES bufffer, INT quality)
----------------------------------------------------------------------
new xencoder = brotli.encoder(STRING name, BYTES bufffer, INT quality, BOOL large_win, INT lgwin)
-------------------------------------------------------------------------------------------------
::
new xencoder = brotli.encoder(
STRING name,
BYTES bufffer=32768,
INT quality=11
INT quality=11,
BOOL large_win=0,
INT lgwin=0
)
XXX ...
.. _vmod_brotli.decoder:
new xdecoder = brotli.decoder(STRING name, BYTES buffer)
--------------------------------------------------------
new xdecoder = brotli.decoder(STRING name, BYTES buffer, BOOL large_win)
------------------------------------------------------------------------
::
new xdecoder = brotli.decoder(STRING name, BYTES buffer=32768)
new xdecoder = brotli.decoder(
STRING name,
BYTES buffer=32768,
BOOL large_win=0
)
XXX ...
......
......@@ -3,7 +3,7 @@
varnishtest "test various custom parameter settings"
server s1 {
loop 5 {
loop 7 {
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.}
}
......@@ -116,6 +116,56 @@ varnish v1 -vcl+backend {
client c1 -run
# lgwin
varnish v1 -vcl+backend {
import ${vmod_brotli};
sub vcl_init {
new mybr = brotli.encoder("br_lg10", lgwin=10);
}
sub vcl_backend_response {
set beresp.filters = "br_lg10 unbr";
set beresp.uncacheable = true;
}
}
client c1 -run
varnish v1 -vcl+backend {
import ${vmod_brotli};
sub vcl_init {
new mybr = brotli.encoder("br_lg24", lgwin=24);
}
sub vcl_backend_response {
set beresp.filters = "br_lg24 unbr";
set beresp.uncacheable = true;
}
}
client c1 -run
varnish v1 -errvcl {vfp brotli failure: new err: lgwin 9 out of range (10 to 24)} {
import ${vmod_brotli};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new err = brotli.encoder("b", lgwin=9);
}
}
varnish v1 -errvcl {vfp brotli failure: new err: lgwin 25 out of range (10 to 24)} {
import ${vmod_brotli};
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new err = brotli.encoder("b", lgwin=25);
}
}
logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
expect 0 * Begin bereq
expect * = VfpAcct {^unbr \d+ 269$}
......@@ -141,4 +191,14 @@ logexpect l1 -v v1 -d 1 -g vxid -q "VfpAcct" {
expect * = VfpAcct {^unbr_largewin \d+ 269$}
expect * = VfpAcct {^br_largewin \d+ \d+$}
expect * = End
expect 0 * Begin bereq
expect * = VfpAcct {^unbr \d+ 269$}
expect * = VfpAcct {^br_lg10 \d+ \d+$}
expect * = End
expect 0 * Begin bereq
expect * = VfpAcct {^unbr \d+ 269$}
expect * = VfpAcct {^br_lg24 \d+ \d+$}
expect * = End
} -run
......@@ -79,6 +79,7 @@ struct vbr_settings {
VCL_BYTES bufsz;
uint32_t quality;
uint32_t large_win;
uint32_t lgwin;
enum vbr_which which;
};
......@@ -152,6 +153,11 @@ setEncoderParams(struct vbr *vbr, const struct vbr_settings *settings)
assert(BrotliEncoderSetParameter(vbr->state.enc,
BROTLI_PARAM_LARGE_WINDOW,
settings->large_win) == BROTLI_TRUE);
if (settings->lgwin != 0)
assert(BrotliEncoderSetParameter(vbr->state.enc,
BROTLI_PARAM_LGWIN,
settings->lgwin)
== BROTLI_TRUE);
}
static void
......@@ -622,7 +628,7 @@ 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_BOOL large_win)
VCL_BOOL large_win, VCL_INT lgwin)
{
struct vmod_brotli_encoder *enc;
struct vfp *vfp = NULL;
......@@ -638,6 +644,14 @@ vmod_encoder__init(VRT_CTX, struct vmod_brotli_encoder **encp,
return;
}
if (lgwin != 0 &&
(lgwin < BROTLI_MIN_WINDOW_BITS || lgwin > BROTLI_MAX_WINDOW_BITS)) {
VFAIL(ctx, "new %s: lgwin %ld out of range (%d to %d)",
vcl_name, lgwin, BROTLI_MIN_WINDOW_BITS,
BROTLI_MAX_WINDOW_BITS);
return;
}
if (coder_init(ctx, vcl_name, priv, filter_name, bufsz, &vfp,
&settings) != 0)
return;
......@@ -657,6 +671,7 @@ vmod_encoder__init(VRT_CTX, struct vmod_brotli_encoder **encp,
settings->which = ENC;
settings->quality = quality;
settings->large_win = large_win;
settings->lgwin = lgwin;
enc->vfp = vfp;
}
......
......@@ -67,7 +67,7 @@ algorithm for responses fetched from backends.
XXX ...
$Object encoder(PRIV_VCL, STRING name, BYTES bufffer=32768, INT quality=11,
BOOL large_win=0)
BOOL large_win=0, INT lgwin=0)
XXX ...
......
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