[master] 9b35b6f Introduce a function to extract a header from OA_HEADER
Poul-Henning Kamp
phk at FreeBSD.org
Tue Aug 12 23:20:11 CEST 2014
commit 9b35b6f7fca377feb4bd3ff46d99382d8a2437bc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Aug 12 21:19:44 2014 +0000
Introduce a function to extract a header from OA_HEADER
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0f9605b..54af650 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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 */
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 8c1d2a5..895de56 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.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)
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index b788f89..db4123b 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -723,6 +723,54 @@ HTTP_Decode(struct http *to, uint8_t *fm)
/*--------------------------------------------------------------------*/
+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
http_filterfields(struct http *to, const struct http *fm, unsigned how)
{
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index c01d7b7..c69c0ed 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -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");
More information about the varnish-commit
mailing list