[master] adc0193 Compact the status parsing code, it got a little too verbose for Federico's taste :-)

Poul-Henning Kamp phk at varnish-cache.org
Thu Oct 3 09:17:51 CEST 2013


commit adc019308015dedc1287fddb85d8251d2710e4ce
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Oct 3 07:17:10 2013 +0000

    Compact the status parsing code, it got a little too verbose for
    Federico's taste :-)

diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index d03a437..6905ac2 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -478,24 +478,15 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc)
 		retval = 503;
 
 	if (retval == 0) {
-		hp->status = 0;
 		p = hp->hd[HTTP_HDR_STATUS].b;
 
-		if (p[0] < '1' || p[0] > '9')
-			retval = 503;
-		else
-			hp->status += 100 * (p[0] - '0');
-
-		if (p[1] < '0' || p[1] > '9')
-			retval = 503;
+		if (p[0] >= '1' && p[0] <= '9' &&
+		    p[1] >= '0' && p[1] <= '9' &&
+		    p[2] >= '0' && p[2] <= '9')
+			hp->status =
+			    100 * (p[0] - '0') + 10 * (p[1] - '0') + p[2] - '0';
 		else
-			hp->status += 10 * (p[1] - '0');
-
-		if (p[2] < '0' || p[2] > '9')
 			retval = 503;
-		else
-			hp->status += (p[2] - '0');
-		assert(hp->status <= 999);
 	}
 
 	if (retval != 0) {



More information about the varnish-commit mailing list