Commit 48bcf013 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

start examining HTTP status codes from backend


git-svn-id: http://www.varnish-cache.org/svn/trunk@186 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f059e77a
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment