From 22118df57b0ccc51819b3dbeba73fd9050515fa6 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 22 Jul 2006 16:15:17 +0000 Subject: [PATCH] Always use GET and HTTP/1.1 against the backend for fetch git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@561 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 1 + varnish-cache/bin/varnishd/cache_fetch.c | 4 ++-- varnish-cache/bin/varnishd/cache_http.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 38dc3e2b..ce289610 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -303,6 +303,7 @@ void HSH_Init(void); void HTTP_Init(void); void http_CopyHttp(struct http *to, struct http *fm); void http_Write(struct worker *w, struct http *hp, int resp); +void http_GetReq(int fd, struct http *to, struct http *fm); void http_CopyReq(int fd, struct http *to, struct http *fm); void http_CopyResp(int fd, struct http *to, struct http *fm); void http_FilterHeader(int fd, struct http *to, struct http *fm, unsigned how); diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index cb84c1b4..66dc8d36 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -51,7 +51,7 @@ fetch_straight(const struct sess *sp, int fd, struct http *hp, char *b) i &= ~O_NONBLOCK; i = fcntl(fd, F_SETFL, i); - while (cl != 0) { + while (cl > 0) { i = http_Read(hp, fd, p, cl); assert(i > 0); /* XXX seen */ p += i; @@ -273,7 +273,7 @@ FetchHeaders(struct sess *sp) assert(vc != NULL); /* XXX: handle this */ VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name); - http_CopyReq(vc->fd, vc->http, sp->http); + http_GetReq(vc->fd, vc->http, sp->http); http_FilterHeader(vc->fd, vc->http, sp->http, HTTPH_R_FETCH); http_PrintfHeader(vc->fd, vc->http, "X-Varnish: %u", sp->xid); diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 4850c441..5bcd6576 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -516,6 +516,16 @@ http_CopyHttp(struct http *to, struct http *fm) /*--------------------------------------------------------------------*/ +static void +http_seth(int fd, struct http *to, unsigned n, enum shmlogtag tag, const char *fm) +{ + assert(n < MAX_HTTP_HDRS); + assert(fm != NULL); + to->hd[n].b = (void*)(uintptr_t)fm; + to->hd[n].e = strchr(fm, '\0'); + VSLH(tag, fd, to, n); +} + static void http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum shmlogtag tag) { @@ -527,6 +537,17 @@ http_copyh(int fd, struct http *to, struct http *fm, unsigned n, enum shmlogtag VSLH(tag, fd, to, n); } +void +http_GetReq(int fd, struct http *to, struct http *fm) +{ + + CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); + http_seth(fd, to, HTTP_HDR_REQ, SLT_Request, "GET"); + http_copyh(fd, to, fm, HTTP_HDR_URL, SLT_URL); + http_seth(fd, to, HTTP_HDR_PROTO, SLT_Protocol, "HTTP/1.1"); +} + void http_CopyReq(int fd, struct http *to, struct http *fm) { -- 2.39.5