Commit e04394c7 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Copy the status code, proto, status string and response message on

backend IMS.

When revalidating using backend IMS, copy the status code, status
code, status string and response message from the original object into
the new revalidated object. This makes sure that none of the 304
message fields gets applied to the new revalidated object.

Fixes: #1485
parent e258ca15
......@@ -356,9 +356,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
AZ(bo->do_esi);
if (bo->ims_obj != NULL && bo->beresp->status == 304) {
bo->beresp->status = 200;
http_Merge(bo->ims_obj->http, bo->beresp,
bo->ims_obj->changed_gzip);
assert(bo->beresp->status == 200);
do_ims = 1;
} else
do_ims = 0;
......
......@@ -637,7 +637,9 @@ http_FilterResp(const struct http *fm, struct http *to, unsigned how)
}
/*--------------------------------------------------------------------
* Merge two HTTP headers the "wrong" way.
* Merge two HTTP headers the "wrong" way. Used by backend IMS to
* merge in the headers of the validated object with the headers of
* the 304 response.
*/
void
......@@ -646,6 +648,11 @@ http_Merge(const struct http *fm, struct http *to, int not_ce)
unsigned u, v;
const char *p;
to->status = fm->status;
http_SetH(to, HTTP_HDR_PROTO, fm->hd[HTTP_HDR_PROTO].b);
http_SetH(to, HTTP_HDR_STATUS, fm->hd[HTTP_HDR_STATUS].b);
http_SetH(to, HTTP_HDR_RESPONSE, fm->hd[HTTP_HDR_RESPONSE].b);
for (u = HTTP_HDR_FIRST; u < fm->nhd; u++)
fm->hdf[u] |= HDF_MARKER;
if (not_ce) {
......
varnishtest "#1485: Wrong response reason phrase"
server s1 {
rxreq
txresp -hdr "Etag: foo"
rxreq
expect req.http.If-None-Match == "foo"
txresp -status 304 -msg "Not Modified"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.ttl = 1ms;
set beresp.grace = 0s;
set beresp.keep = 1h;
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
expect resp.msg == "OK"
delay 0.1
txreq
rxresp
expect resp.status == 200
expect resp.msg == "OK"
} -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