[sheepdog] [PATCH 3/4] http: parse CONTENT_LENGTH only when necessary

Liu Yuan namei.unix at gmail.com
Thu Nov 14 10:03:53 CET 2013


This will remove the unnecessary setting conent length for 'get' operation

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/http/http.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sheep/http/http.c b/sheep/http/http.c
index 8532378..644cdc5 100644
--- a/sheep/http/http.c
+++ b/sheep/http/http.c
@@ -158,10 +158,12 @@ static int request_init_operation(struct http_request *req)
 	}
 
 	p = FCGX_GetParam("CONTENT_LENGTH", env);
-	req->data_length = strtoll(p, &endp, 10);
-	if (p == endp) {
-		sd_err("invalid content_length %s", p);
-		return BAD_REQUEST;
+	if (strlen(p)) {
+		req->data_length = strtoll(p, &endp, 10);
+		if (p == endp) {
+			sd_err("invalid content_length %s", p);
+			return BAD_REQUEST;
+		}
 	}
 	req->uri = FCGX_GetParam("REQUEST_URI", env);
 	if (!req->uri)
-- 
1.7.9.5




More information about the sheepdog mailing list