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

Liu Yuan namei.unix at gmail.com
Fri Nov 15 06:50:45 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 fb7aac2..04ef364 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 (p[0] != '\0') {
+		req->data_length = strtoll(p, &endp, 10);
+		if (p == endp) {
+			sd_err("invalid content_length %s", p);
+			return BAD_REQUEST;
+		}
 	}
 	req->uri = FCGX_GetParam("DOCUMENT_URI", env);
 	if (!req->uri)
-- 
1.7.9.5




More information about the sheepdog mailing list