]> err.no Git - varnish/commitdiff
start examining HTTP status codes from backend
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 14 Jun 2006 09:57:19 +0000 (09:57 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 14 Jun 2006 09:57:19 +0000 (09:57 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@186 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_http.c
varnish-cache/bin/varnishd/cache_vcl.c

index cdde756daefaf04af8a95095236f718b5f322385..08bd82e11b12457c929981866b46a73b721f6f69 100644 (file)
@@ -81,6 +81,7 @@ struct http;
 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);
index 0ca159cd89170c3e6969bc4cead7c45386f9adba..a699e5ac68370c0808fec4b15bae1c7919c1c90c 100644 (file)
@@ -161,9 +161,19 @@ FetchSession(struct worker *w, struct sess *sp)
        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);
index afd722773b44c2a53eb3f042764fa1970256ebd1..9b4b01d1ef00d63bced1e067d924843f5cb8491b 100644 (file)
@@ -143,6 +143,13 @@ http_GetTail(struct http *hp, unsigned len, char **b, char **e)
        return (1);
 }
 
+int
+http_GetStatus(struct http *hp)
+{
+
+       return (strtoul(hp->status, NULL /* XXX */, 10));
+}
+
 /*--------------------------------------------------------------------*/
 
 void
index 4e7893b787a61ec4f658cdca004755ab1708502c..e4e863b9805df380838a604396f89c2dc3a2555e 100644 (file)
@@ -205,7 +205,11 @@ void VCL_fetch(VCL_FARGS) {
        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