From 0f0fea6fd50974ba3638d75d84d9011b0baf3a24 Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 4 Jul 2006 09:28:21 +0000 Subject: [PATCH] Close non HTTP/1.1 request connections git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@291 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 1 + varnish-cache/bin/varnishd/cache_http.c | 9 +++++++++ varnish-cache/bin/varnishd/cache_pool.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index b8b1669c..502455e9 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -171,6 +171,7 @@ void http_Delete(struct http *hp); int http_GetHdr(struct http *hp, const char *hdr, char **ptr); int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr); int http_GetReq(struct http *hp, char **b); +int http_GetProto(struct http *hp, char **b); int http_GetStatus(struct http *hp); int http_HdrIs(struct http *hp, const char *hdr, const char *val); int http_GetTail(struct http *hp, unsigned len, char **b, char **e); diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index fa486284..d669bfe0 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -164,6 +164,15 @@ http_GetURL(struct http *hp, char **b) return (1); } +int +http_GetProto(struct http *hp, char **b) +{ + if (hp->proto == NULL) + return (0); + *b = hp->proto; + return (1); +} + int http_GetTail(struct http *hp, unsigned len, char **b, char **e) { diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 79a66b42..a5821839 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -116,6 +116,9 @@ CacheWorker(void *priv) if (http_GetHdr(sp->http, "Connection", &b) && !strcmp(b, "close")) { vca_close_session(sp, "Connection header"); + } else if (http_GetProto(sp->http, &b) && + strcmp(b, "HTTP/1.1")) { + vca_close_session(sp, "not HTTP/1.1"); } AZ(pthread_mutex_lock(&sessmtx)); -- 2.39.5