[4.0] 6960078 Minor polishing in http space, to get them out of substantial change to follow shortly.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jun 24 11:31:54 CEST 2014
commit 69600783b911cb6b15f3fb07f6dbd595697a0933
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jun 10 07:19:41 2014 +0000
Minor polishing in http space, to get them out of substantial change
to follow shortly.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 22e0362..732bf9f 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -89,15 +89,10 @@ enum sess_close {
#undef SESS_CLOSE
};
-/*--------------------------------------------------------------------*/
-
-/*
- * NB: HDR_STATUS is only used in cache_http.c, everybody else uses the
- * http->status integer field.
+/*--------------------------------------------------------------------
+ * Indicies into http->hd[]
*/
-
enum {
- /* Fields from the first line of HTTP proto */
#define SLTH(tag, ind, req, resp, sdesc, ldesc) ind,
#include "tbl/vsl_tags_http.h"
#undef SLTH
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 1d1f872..8411e1f 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -193,6 +193,39 @@ HTTP_Copy(struct http *to, const struct http * const fm)
memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->hdf);
}
+/*--------------------------------------------------------------------*/
+
+void
+http_SetH(const struct http *to, unsigned n, const char *fm)
+{
+
+ assert(n < to->shd);
+ AN(fm);
+ to->hd[n].b = TRUST_ME(fm);
+ to->hd[n].e = strchr(to->hd[n].b, '\0');
+ to->hdf[n] = 0;
+ http_VSLH(to, n);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+http_PutField(struct http *to, int field, const char *string)
+{
+ char *p;
+
+ CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
+ p = WS_Copy(to->ws, string, -1);
+ if (p == NULL) {
+ http_fail(to);
+ VSLb(to->vsl, SLT_LostHeader, "%s", string);
+ return;
+ }
+ to->hd[field].b = p;
+ to->hd[field].e = strchr(p, '\0');
+ to->hdf[field] = 0;
+ http_VSLH(to, field);
+}
/*--------------------------------------------------------------------*/
@@ -515,6 +548,7 @@ uint16_t
http_GetStatus(const struct http *hp)
{
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
return (hp->status);
}
@@ -522,44 +556,11 @@ const char *
http_GetReq(const struct http *hp)
{
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
Tcheck(hp->hd[HTTP_HDR_METHOD]);
return (hp->hd[HTTP_HDR_METHOD].b);
}
-/*--------------------------------------------------------------------*/
-
-static void
-http_PutField(struct http *to, int field, const char *string)
-{
- char *p;
-
- CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
- p = WS_Copy(to->ws, string, -1);
- if (p == NULL) {
- http_fail(to);
- VSLb(to->vsl, SLT_LostHeader, "%s", string);
- return;
- }
- to->hd[field].b = p;
- to->hd[field].e = strchr(p, '\0');
- to->hdf[field] = 0;
- http_VSLH(to, field);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-http_SetH(const struct http *to, unsigned n, const char *fm)
-{
-
- assert(n < to->shd);
- AN(fm);
- to->hd[n].b = TRUST_ME(fm);
- to->hd[n].e = strchr(to->hd[n].b, '\0');
- to->hdf[n] = 0;
- http_VSLH(to, n);
-}
-
/*--------------------------------------------------------------------
* Force a particular header field to a particular value
*/
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index 4daa814..66323a9 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -312,6 +312,9 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
h2 = HTTP_HDR_STATUS;
h3 = HTTP_HDR_REASON;
}
+ AZ(hp->hd[h1].b);
+ AZ(hp->hd[h2].b);
+ AZ(hp->hd[h3].b);
/* Skip leading LWS */
for (p = htc->rxbuf.b ; vct_islws(*p); p++)
@@ -339,7 +342,6 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
return (400);
}
hp->hd[h2].e = p;
-
if (!Tlen(hp->hd[h2]))
return (400);
@@ -364,9 +366,7 @@ htc_splitline(struct http *hp, const struct http_conn *htc, int req)
*hp->hd[h1].e = '\0';
*hp->hd[h2].e = '\0';
-
- if (hp->hd[h3].e != NULL)
- *hp->hd[h3].e = '\0';
+ *hp->hd[h3].e = '\0';
return (htc_dissect_hdrs(hp, p, htc));
}
More information about the varnish-commit
mailing list