]> err.no Git - varnish/commitdiff
Minor cleanups
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Sep 2006 06:26:56 +0000 (06:26 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 18 Sep 2006 06:26:56 +0000 (06:26 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1056 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_response.c

index 3e11e50cae1e61c5306b17a7eda7062d6a420856..b2bbfedb40c50a11d19affa7627ae75ae7ebaa8e 100644 (file)
@@ -654,7 +654,8 @@ cnt_recv(struct sess *sp)
        clock_gettime(CLOCK_REALTIME, &sp->t_req);
        sp->wrk->idle = sp->t_req.tv_sec;
        sp->xid = ++xids;
-       WSL(sp->wrk, SLT_ReqStart, sp->fd, "%s %s %u", sp->addr, sp->port,  sp->xid);
+       WSL(sp->wrk, SLT_ReqStart, sp->fd,
+           "%s %s %u", sp->addr, sp->port,  sp->xid);
 
        AZ(sp->vcl);
        VCL_Refresh(&sp->wrk->vcl);
index 09708f00a0b5647e28ee6eb89b9e71b9943788e6..bb7e846714e14d9265200e4e3cf1bcaa70967434 100644 (file)
@@ -17,6 +17,7 @@
 static struct http_msg {
        unsigned        nbr;
        const char      *txt;
+       const char      *expl;
 } http_msg[] = {
        { 101, "Switching Protocols" },
        { 200, "OK" },
@@ -71,35 +72,29 @@ RES_Error(struct sess *sp, int code, const char *expl)
        struct http_msg *mp;
        const char *msg;
 
+       assert(code >= 100 && code <= 999);
        CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 
        clock_gettime(CLOCK_REALTIME, &sp->t_resp);
 
        msg = "Unknown error";
-       for (mp = http_msg; mp->nbr != 0 && mp->nbr <= code; mp++) 
-               if (mp->nbr == code) {
-                       msg = mp->txt;
+       for (mp = http_msg; mp->nbr != 0 && mp->nbr <= code; mp++)  {
+               if (mp->nbr < code)
+                       continue;
+               if (mp->nbr > code)
                        break;
-               }
+               msg = mp->txt;
+               if (expl == NULL)
+                       expl = mp->expl;
+               break;
+       }
+       if (expl == NULL) 
+               expl = msg;
+       AN(expl);
+       AN(msg);
 
        sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND);
        XXXAN(sb);
-       assert(code >= 100 && code <= 999);
-
-       if (msg == NULL) {
-               switch (code) {
-               case 400:       msg = "Bad Request"; break;
-               case 500:       msg = "Internal Error"; break;
-               default:        msg = "HTTP request error"; break;
-               }
-       }
-       if (expl == NULL) {
-               switch (code) {
-               case 400:       expl = "Your HTTP protocol request did not make sense."; break;
-               case 404:       expl = "The document you requested was not found."; break;
-               default:        expl = "Something unexpected happened."; break;
-               }
-       }
 
        vsb_clear(sb);
        vsb_printf(sb, "HTTP/1.1 %03d %s\r\n", code, msg);