[master] 57adab3 Eliminate the maxhdr field from struct http_conn
Poul-Henning Kamp
phk at FreeBSD.org
Tue Apr 5 12:13:05 CEST 2016
commit 57adab3dbb1ff8959d268d5092d56d70ca937b74
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 5 07:41:21 2016 +0000
Eliminate the maxhdr field from struct http_conn
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3444656..5e4fb89 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -225,7 +225,6 @@ struct http_conn {
int fd;
enum sess_close doclose;
unsigned maxbytes;
- unsigned maxhdr;
enum body_status body_status;
struct ws *ws;
char *rxbuf_b;
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index 56d9cc1..f8ac66f 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -106,7 +106,8 @@ HTTP1_Complete(struct http_conn *htc)
*/
static uint16_t
-http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc)
+http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc,
+ unsigned maxhdr)
{
char *q, *r;
@@ -147,7 +148,7 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc)
*q++ = ' ';
}
- if (q - p > htc->maxhdr) {
+ if (q - p > maxhdr) {
VSLb(hp->vsl, SLT_BogoHeader, "Header too long: %.*s",
(int)(q - p > 20 ? 20 : q - p), p);
return (400);
@@ -205,7 +206,8 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc)
*/
static uint16_t
-http1_splitline(struct http *hp, struct http_conn *htc, const int *hf)
+http1_splitline(struct http *hp, struct http_conn *htc, const int *hf,
+ unsigned maxhdr)
{
char *p;
int i;
@@ -271,7 +273,7 @@ http1_splitline(struct http *hp, struct http_conn *htc, const int *hf)
*p = '\0';
p += i;
- return (http1_dissect_hdrs(hp, p, htc));
+ return (http1_dissect_hdrs(hp, p, htc, maxhdr));
}
/*--------------------------------------------------------------------*/
@@ -349,8 +351,8 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
- htc->maxhdr = cache_param->http_req_hdr_len;
- retval = http1_splitline(hp, htc, HTTP1_Req);
+ retval = http1_splitline(hp, htc,
+ HTTP1_Req, cache_param->http_req_hdr_len);
if (retval != 0)
return (retval);
hp->protover = http1_proto_ver(hp);
@@ -415,8 +417,8 @@ HTTP1_DissectResponse(struct http_conn *htc, struct http *hp,
CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
CHECK_OBJ_NOTNULL(req, HTTP_MAGIC);
- htc->maxhdr = cache_param->http_resp_hdr_len;
- if (http1_splitline(hp, htc, HTTP1_Resp))
+ if (http1_splitline(hp, htc,
+ HTTP1_Resp, cache_param->http_resp_hdr_len))
retval = 503;
if (retval == 0) {
More information about the varnish-commit
mailing list