Commit c0a515b0 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Pål Hermunn Johansen

Deal with fetch failures in ved_stripgzip

An object failing fetch that is waited upon by the ESI delivery code
would cause asserts finding an empty object. If waiting for an object,
check the status of the object and deliver zero bytes if failed.

Fixes: #1953
parent 2794a742
......@@ -530,8 +530,14 @@ ved_stripgzip(struct req *req, struct busyobj *bo)
CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC);
preq = ecx->preq;
/* OA_GZIPBITS is not valid until BOS_FINISHED */
if (bo != NULL)
VBO_waitstate(bo, BOS_FINISHED);
if (req->objcore->flags & OC_F_FAILED) {
/* No way of signalling errors in the middle of
the ESI body. Omit this ESI fragment. */
return;
}
AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
......
varnishtest "#1953: ved_stripgzip and failed object"
server s1 {
rxreq
txresp -gzipbody {<1><esi:include src="/2"/></1>}
rxreq
txresp -nolen -hdr "Content-Encoding: gzip" -hdr "Content-Length: 42"
# No body sent, will cause fetch error
# The delay allows time for the ESI deliver thread to get to the point
# where it is waiting for this body
delay 1
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
if (bereq.url == "/") {
set beresp.do_esi = true;
}
}
} -start
client c1 {
txreq -hdr "Accept-Encoding: gzip"
rxresp
expect resp.http.Content-Encoding == "gzip"
gunzip
expect resp.body == "<1></1>"
} -run
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