Commit 62e6b5f5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a HTTP_Copy() function and use it for the "rollback" copy of req.*

This was forgotten when number of HTTP headers was made dynamic.

The lack of this function may have made ESI includes weird.

Should be merged to 2.1



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4650 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f7e0dc2d
......@@ -135,6 +135,7 @@ enum httpwhence {
HTTP_Obj = 3
};
/* NB: remember to update http_Copy() if you add fields */
struct http {
unsigned magic;
#define HTTP_MAGIC 0x6428b5c9
......@@ -514,6 +515,7 @@ void Fetch_Init(void);
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
void HTTP_Copy(struct http *to, const struct http * const fm);
struct http *HTTP_create(void *p, unsigned nhttp);
const char *http_StatusMessage(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, unsigned *nhd);
......
......@@ -1132,7 +1132,7 @@ cnt_start(struct sess *sp)
sp->ws_req = WS_Snapshot(sp->ws);
/* Catch original request, before modification */
*sp->http0 = *sp->http;
HTTP_Copy(sp->http0, sp->http);
if (done != 0) {
sp->err_code = done;
......
......@@ -896,7 +896,7 @@ ESI_Deliver(struct sess *sp)
http_save = *sp->http;
/* Reset request to status before we started messing with it */
*sp->http = *sp->http0;
HTTP_Copy(sp->http, sp->http0);
/* Take a workspace snapshot */
ws_wm = WS_Snapshot(sp->ws);
......
......@@ -894,6 +894,22 @@ http_Unset(struct http *hp, const char *hdr)
/*--------------------------------------------------------------------*/
void
HTTP_Copy(struct http *to, const struct http * const fm)
{
to->conds = fm->conds;
to->logtag = fm->logtag;
to->status = fm->status;
to->protover = fm->protover;
to->nhd = fm->nhd;
assert(fm->nhd <= to->shd);
memcpy(to->hd, fm->hd, fm->nhd * sizeof *to->hd);
memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->hdf);
}
/*--------------------------------------------------------------------*/
unsigned
http_Write(struct worker *w, const struct http *hp, int resp)
{
......
......@@ -867,7 +867,7 @@ void
VRT_Rollback(struct sess *sp)
{
*sp->http = *sp->http0;
HTTP_Copy(sp->http, sp->http0);
WS_Reset(sp->ws, sp->ws_req);
}
......
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