...
 
Commits (3)
  • Nils Goroll's avatar
    use ssize_t · 6f5607d9
    Nils Goroll authored
    The corresponding varnish API function arguments are signed, make our
    struct match them.
    6f5607d9
  • Nils Goroll's avatar
    Fill the brotli input buffer · 60a3e730
    Nils Goroll authored
    this can save calls into the brotli code.
    
    Note: I thought we might be able to avoid the additional ring buffer
    copy in the brotli encode by using a buffer of size 1 << lgblock, but the
    brotli code calls RingBufferWrite() even if the input buffer holds all
    of the data to be compressed.
    60a3e730
  • Nils Goroll's avatar
    more polishing of the real world vcl code · bfffd7e4
    Nils Goroll authored
    - minimum ttl of 10s for HFM objects
    - simplify the X-TTL code
    - show is_esi() example
    bfffd7e4
......@@ -124,6 +124,9 @@ varnish v1 \
unset beresp.http.X-TTL;
} else {
set beresp.uncacheable = true;
if (beresp.ttl < 10s) {
set beresp.ttl = 10s;
}
}
return (deliver);
}
......@@ -143,16 +146,14 @@ varnish v1 \
}
sub br_deliver {
unset resp.http.X-TTL;
# for ESI:
# if (objesi.is_esi() || obj.uncacheable)
if (obj.uncacheable) {
# NOP
} else if (local.socket == "self_plain") {
if (obj.uncacheable) {
unset resp.http.X-TTL;
} else {
set resp.http.X-TTL = obj.ttl;
}
set resp.http.X-TTL = obj.ttl;
} else {
unset resp.http.X-TTL;
if (resp.http.Vary ~ "\bV-A-E\s*,") {
set resp.http.Vary = regsub(resp.http.Vary,
"\bV-A-E\s*,\s*", "");
......
......@@ -23,7 +23,21 @@ Enim per accumsan, augue id maecenas bibendum ullamcorper in fermentum, platea f
rxreq
txresp -nolen -hdr "Transfer-encoding: chunked"
chunkedlen 131072
chunkedlen 8
chunkedlen 8
chunkedlen 16
chunkedlen 32
chunkedlen 64
chunkedlen 128
chunkedlen 256
chunkedlen 512
chunkedlen 1024
chunkedlen 2048
chunkedlen 4096
chunkedlen 8192
chunkedlen 16384
chunkedlen 32768
chunkedlen 65536
chunkedlen 0
} -start
......
......@@ -70,8 +70,8 @@ struct vbr {
BrotliDecoderState *dec;
} state;
uint8_t *buf;
size_t bufsz;
size_t buflen;
ssize_t bufsz;
ssize_t buflen;
enum vbr_which which;
};
......@@ -386,7 +386,7 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ssize_t *lenp)
{
struct vbr *vbr;
ssize_t len, dl;
ssize_t len, l, dl;
enum vfp_status vp = VFP_ERROR;
int finished = 0;
BROTLI_BOOL done;
......@@ -407,8 +407,12 @@ vfp_br_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
do {
if (isInputBufEmpty(vbr)) {
len = vbr->bufsz;
vp = VFP_Suck(ctx, vbr->buf, &len);
len = 0;
do {
l = vbr->bufsz - len;
vp = VFP_Suck(ctx, vbr->buf + len, &l);
len += l;
} while (vp == VFP_OK && len < vbr->bufsz);
if (vp == VFP_ERROR)
break;
if (vp == VFP_END)
......@@ -439,7 +443,7 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
ssize_t *lenp)
{
struct vbr *vbr;
ssize_t len, dl;
ssize_t len, l, dl;
enum vfp_status vp = VFP_ERROR;
BrotliDecoderResult result = BROTLI_DECODER_RESULT_ERROR;
const struct vfp_priv *priv;
......@@ -459,8 +463,12 @@ vfp_unbr_pull(struct vfp_ctx *ctx, struct vfp_entry *ent, void *ptr,
do {
if (isInputBufEmpty(vbr)) {
len = vbr->bufsz;
vp = VFP_Suck(ctx, vbr->buf, &len);
len = 0;
do {
l = vbr->bufsz - len;
vp = VFP_Suck(ctx, vbr->buf + len, &l);
len += l;
} while (vp == VFP_OK && len < vbr->bufsz);
if (vp == VFP_ERROR)
break;
setInputBuf(vbr, vbr->buf, len);
......