Commit 46308b16 authored by Tollef Fog Heen's avatar Tollef Fog Heen

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