Commit 194acd4f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Pål Hermunn Johansen

Allow VCL set Last-Modified to be used for I-M-S processing.

Submitted by:	rezan
Fixes:		#1931
parent 65d90e3d
......@@ -254,7 +254,7 @@ rfc2616_weak_compare(const char *p, const char *e)
int
RFC2616_Do_Cond(const struct req *req)
{
const char *p, *e;
const char *p, *e, *l;
double ims, lm;
/*
......@@ -274,6 +274,12 @@ RFC2616_Do_Cond(const struct req *req)
ims = VTIM_parse(p);
if (!ims || ims > req->t_req) /* [RFC7232 3.3 p16] */
return (0);
if (http_GetHdr(req->resp, H_Last_Modified, &l)) {
lm = VTIM_parse(l);
if (!lm || lm > ims)
return (0);
return (1);
}
AZ(ObjGetDouble(req->wrk, req->objcore, OA_LASTMODIFIED, &lm));
if (lm > ims)
return (0);
......
varnishtest "Changing Last Modified in vcl_deliver"
server s1 {
rxreq
txresp -hdr "Last-Modified: Wed, 27 Apr 2016 14:00:00 GMT"
} -start
varnish v1 -vcl+backend {
sub vcl_deliver {
if (req.http.deliver == "modify") {
set resp.http.Last-Modified = "Wed, 27 Apr 2016 16:00:00 GMT";
}
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
txreq -hdr "If-Modified-Since: Wed, 27 Apr 2016 14:00:00 GMT"
rxresp
expect resp.status == 304
txreq -hdr "If-Modified-Since: Wed, 27 Apr 2016 12:00:00 GMT"
rxresp
expect resp.status == 200
txreq -hdr "If-Modified-Since: Wed, 27 Apr 2016 14:00:00 GMT" -hdr "deliver: modify"
rxresp
expect resp.status == 200
txreq -hdr "If-Modified-Since: Wed, 27 Apr 2016 16:00:00 GMT" -hdr "deliver: modify"
rxresp
expect resp.status == 304
txreq -hdr "If-Modified-Since: Wed, 27 Apr 2016 18:00:00 GMT" -hdr "deliver: modify"
rxresp
expect resp.status == 304
} -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