Commit 83748716 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Pack obj->http into a oa_http bytestring and populate the obj->http

structure from that while we still need it.
parent 7820ecde
...@@ -561,6 +561,8 @@ struct object { ...@@ -561,6 +561,8 @@ struct object {
uint8_t *vary; uint8_t *vary;
uint8_t *oa_http;
unsigned gziped:1; unsigned gziped:1;
unsigned changed_gzip:1; unsigned changed_gzip:1;
...@@ -948,7 +950,6 @@ void HTTP_Init(void); ...@@ -948,7 +950,6 @@ void HTTP_Init(void);
void http_PutResponse(struct http *to, const char *proto, uint16_t status, void http_PutResponse(struct http *to, const char *proto, uint16_t status,
const char *response); const char *response);
void http_FilterReq(struct http *to, const struct http *fm, unsigned how); void http_FilterReq(struct http *to, const struct http *fm, unsigned how);
void http_FilterResp(const struct http *fm, struct http *to, unsigned how);
uint8_t *HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how); uint8_t *HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how);
int HTTP_Decode(struct http *to, uint8_t *fm); int HTTP_Decode(struct http *to, uint8_t *fm);
void http_ForceHeader(struct http *to, const char *hdr, const char *val); void http_ForceHeader(struct http *to, const char *hdr, const char *val);
......
...@@ -101,7 +101,6 @@ vbf_beresp2obj(struct busyobj *bo) ...@@ -101,7 +101,6 @@ vbf_beresp2obj(struct busyobj *bo)
int varyl = 0; int varyl = 0;
uint16_t nhttp; uint16_t nhttp;
struct object *obj; struct object *obj;
struct http *hp, *hp2;
l = 0; l = 0;
...@@ -156,23 +155,19 @@ vbf_beresp2obj(struct busyobj *bo) ...@@ -156,23 +155,19 @@ vbf_beresp2obj(struct busyobj *bo)
WS_Assert(bo->ws_o); WS_Assert(bo->ws_o);
/* Filter into object */ /* Filter into object */
hp = bo->beresp; obj->http->logtag = SLT_ObjMethod;
hp2 = obj->http; obj->oa_http = HTTP_Encode(bo->beresp, bo->ws_o,
bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS);
AN(obj->oa_http);
AZ(HTTP_Decode(obj->http, obj->oa_http));
hp2->logtag = SLT_ObjMethod; if (http_GetHdr(bo->beresp, H_Last_Modified, &b))
http_FilterResp(hp, hp2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS);
http_CopyHome(hp2);
if (http_GetHdr(hp, H_Last_Modified, &b))
AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED,
VTIM_parse(b))); VTIM_parse(b)));
else else
AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED, AZ(ObjSetDouble(bo->fetch_objcore, bo->stats, OA_LASTMODIFIED,
floor(bo->fetch_objcore->exp.t_origin))); floor(bo->fetch_objcore->exp.t_origin)));
/* Disassociate the obj from the bo's workspace */
hp2->ws = NULL;
return (0); return (0);
} }
......
...@@ -136,7 +136,7 @@ HTTP_estimate(unsigned nhttp) ...@@ -136,7 +136,7 @@ HTTP_estimate(unsigned nhttp)
{ {
/* XXX: We trust the structs to size-aligned as necessary */ /* XXX: We trust the structs to size-aligned as necessary */
return (sizeof (struct http) + (sizeof (txt) + 1) * nhttp); return (PRNDUP(sizeof (struct http) + sizeof(txt) * nhttp + nhttp));
} }
struct http * struct http *
...@@ -605,12 +605,14 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) ...@@ -605,12 +605,14 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
{ {
unsigned u, l; unsigned u, l;
l = 0; l = 4;
*nhd = HTTP_HDR_FIRST; *nhd = 1 + HTTP_HDR_FIRST - 3;
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
for (u = 0; u < fm->nhd; u++) { for (u = 0; u < fm->nhd; u++) {
if (fm->hd[u].b == NULL) if (u == HTTP_HDR_METHOD || u == HTTP_HDR_URL)
continue; continue;
AN(fm->hd[u].b);
AN(fm->hd[u].e);
if (fm->hdf[u] & HDF_FILTER) if (fm->hdf[u] & HDF_FILTER)
continue; continue;
#define HTTPH(a, b, c) \ #define HTTPH(a, b, c) \
...@@ -618,11 +620,10 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd) ...@@ -618,11 +620,10 @@ http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd)
continue; continue;
#include "tbl/http_headers.h" #include "tbl/http_headers.h"
#undef HTTPH #undef HTTPH
l += PRNDUP(Tlen(fm->hd[u]) + 1L); l += Tlen(fm->hd[u]) + 1L;
(*nhd)++; (*nhd)++;
// fm->hdf[u] |= HDF_COPY;
} }
return (l); return (PRNDUP(l + 1L));
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -673,6 +674,7 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how) ...@@ -673,6 +674,7 @@ HTTP_Encode(const struct http *fm, struct ws *ws, unsigned how)
assert(p <= e); assert(p <= e);
e = (uint8_t*)ws->f; e = (uint8_t*)ws->f;
vbe16enc(e, n + 1); vbe16enc(e, n + 1);
VSLb(fm->vsl, SLT_Debug, "HTTPENC %zd", p - (uint8_t*)ws->f);
WS_ReleaseP(ws, (void*)p); WS_ReleaseP(ws, (void*)p);
return (e); return (e);
} }
...@@ -711,7 +713,6 @@ HTTP_Decode(struct http *to, uint8_t *fm) ...@@ -711,7 +713,6 @@ HTTP_Decode(struct http *to, uint8_t *fm)
return (-1); return (-1);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
...@@ -769,21 +770,6 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how) ...@@ -769,21 +770,6 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how)
http_filterfields(to, fm, how); http_filterfields(to, fm, how);
} }
/*--------------------------------------------------------------------*/
void
http_FilterResp(const struct http *fm, struct http *to, unsigned how)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
to->status = fm->status;
http_linkh(to, fm, HTTP_HDR_PROTO);
http_linkh(to, fm, HTTP_HDR_STATUS);
http_linkh(to, fm, HTTP_HDR_REASON);
http_filterfields(to, fm, how);
}
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
* Merge two HTTP headers the "wrong" way. Used by backend IMS to * Merge two HTTP headers the "wrong" way. Used by backend IMS to
* merge in the headers of the validated object with the headers of * merge in the headers of the validated object with the headers of
......
...@@ -105,7 +105,7 @@ cnt_deliver(struct worker *wrk, struct req *req) ...@@ -105,7 +105,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
EXP_Touch(req->objcore, req->t_prev); EXP_Touch(req->objcore, req->t_prev);
HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod);
http_FilterResp(req->obj->http, req->resp, 0); AZ(HTTP_Decode(req->resp, req->obj->oa_http));
http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1"); http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1");
if (req->wrk->stats.cache_hit) if (req->wrk->stats.cache_hit)
......
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