r186 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jun 14 11:57:19 CEST 2006
Author: phk
Date: 2006-06-14 11:57:19 +0200 (Wed, 14 Jun 2006)
New Revision: 186
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_fetch.c
trunk/varnish-cache/bin/varnishd/cache_http.c
trunk/varnish-cache/bin/varnishd/cache_vcl.c
Log:
start examining HTTP status codes from backend
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2006-06-14 09:39:31 UTC (rev 185)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2006-06-14 09:57:19 UTC (rev 186)
@@ -81,6 +81,7 @@
struct http *http_New(void);
void http_Delete(struct http *hp);
int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
+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);
int http_GetURL(struct http *hp, char **b);
Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-14 09:39:31 UTC (rev 185)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2006-06-14 09:57:19 UTC (rev 186)
@@ -161,9 +161,19 @@
event_base_loop(w->eb, 0);
http_Dissect(hp, fd, 2);
- /* XXX: fill in object from headers */
- sp->obj->valid = 1;
- sp->obj->cacheable = 1;
+ switch (http_GetStatus(hp)) {
+ case 200:
+ /* XXX: fill in object from headers */
+ sp->obj->valid = 1;
+ sp->obj->cacheable = 1;
+ break;
+ case 301:
+ sp->obj->valid = 0;
+ sp->obj->cacheable = 0;
+ break;
+ default:
+ break;
+ }
sp->handling = HND_Insert;
sp->vcl->fetch_func(sp);
Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c 2006-06-14 09:39:31 UTC (rev 185)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c 2006-06-14 09:57:19 UTC (rev 186)
@@ -143,6 +143,13 @@
return (1);
}
+int
+http_GetStatus(struct http *hp)
+{
+
+ return (strtoul(hp->status, NULL /* XXX */, 10));
+}
+
/*--------------------------------------------------------------------*/
void
Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c 2006-06-14 09:39:31 UTC (rev 185)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c 2006-06-14 09:57:19 UTC (rev 186)
@@ -205,7 +205,11 @@
sess->done++;
}
-void VCL_error(VCL_FARGS, unsigned err, const char *str) {
+void
+VCL_error(VCL_FARGS, unsigned err, const char *str)
+{
+
+ VSL(SLT_Debug, 0, "VCL_error(%u, %s)", err, str);
}
void
More information about the varnish-commit
mailing list