Commit 9b35b6f7 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Introduce a function to extract a header from OA_HEADER

parent d9a6da6d
......@@ -983,6 +983,8 @@ void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen,
void http_CollectHdr(struct http *hp, const char *hdr);
void http_VSL_log(const struct http *hp);
void http_Merge(const struct http *fm, struct http *to);
const char *HTTP_GetHdrPack(struct objcore *, struct dstat *,
const char *hdr);
/* cache_http1_proto.c */
......
......@@ -176,7 +176,7 @@ vbf_beresp2obj(struct busyobj *bo)
static enum fetch_step
vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
{
char *p;
const char *q;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
......@@ -202,14 +202,14 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
}
if (bo->ims_oc != NULL) {
if (http_GetHdr(bo->ims_obj->http, H_Last_Modified, &p)) {
q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_Last_Modified);
if (q != NULL)
http_PrintfHeader(bo->bereq0,
"If-Modified-Since: %s", p);
}
if (http_GetHdr(bo->ims_obj->http, H_ETag, &p)) {
"If-Modified-Since: %s", q);
q = HTTP_GetHdrPack(bo->ims_oc, bo->stats, H_ETag);
if (q != NULL)
http_PrintfHeader(bo->bereq0,
"If-None-Match: %s", p);
}
"If-None-Match: %s", q);
}
HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
......@@ -568,22 +568,10 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
uint64_t ol;
struct storage *st;
enum objiter_status ois;
char *p;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (ObjCheckFlag(bo->ims_oc, bo->stats, OF_CHGGZIP)) {
/*
* If we modified the gzip status of the IMS object, that
* must control the C-E header, if any.
*/
http_Unset(bo->beresp, H_Content_Encoding);
if (http_GetHdr(bo->ims_obj->http, H_Content_Encoding, &p))
http_PrintfHeader(bo->beresp,
"Content-Encoding: %s", p);
}
AZ(vbf_beresp2obj(bo));
if (ObjGetattr(bo->ims_oc, bo->stats, OA_ESIDATA, NULL) != NULL)
......
......@@ -721,6 +721,54 @@ HTTP_Decode(struct http *to, uint8_t *fm)
return (-1);
}
/*--------------------------------------------------------------------*/
const char *
HTTP_GetHdrPack(struct objcore *oc, struct dstat *ds, const char *hdr)
{
char *ptr;
unsigned l;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AN(ds);
AN(hdr);
l = hdr[0];
assert(l == strlen(hdr + 1));
assert(hdr[l] == ':');
hdr++;
ptr = ObjGetattr(oc, ds, OA_HEADERS, NULL);
AN(ptr);
/* Skip nhd and status */
ptr += 4;
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
/* Skip PROTO, STATUS and REASON */
ptr = strchr(ptr, '\0') + 1;
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
ptr = strchr(ptr, '\0') + 1;
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
ptr = strchr(ptr, '\0') + 1;
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
while (*ptr != '\0') {
VSL(SLT_Debug, 0, "%d <%s> %u <%s>", __LINE__, ptr, l, hdr);
if (!strncasecmp(ptr, hdr, l)) {
ptr += l;
assert (vct_issp(*ptr));
ptr++;
assert (!vct_issp(*ptr));
return (ptr);
}
ptr = strchr(ptr, '\0') + 1;
VSL(SLT_Debug, 0, "%d %s", __LINE__, ptr);
}
return (NULL);
}
/*--------------------------------------------------------------------*/
static void
......
......@@ -105,7 +105,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
EXP_Touch(req->objcore, req->t_prev);
HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod);
AZ(HTTP_Decode(req->resp,
AZ(HTTP_Decode(req->resp,
ObjGetattr(req->objcore, &req->wrk->stats, OA_HEADERS, NULL)));
http_ForceField(req->resp, HTTP_HDR_PROTO, "HTTP/1.1");
......
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