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

MORITA Kazutaka morita.kazutaka at gmail.com
Thu Nov 14 19:33:40 CET 2013


At Thu, 14 Nov 2013 17:03:53 +0800,
Liu Yuan wrote:
> 
> 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)) {

Checking p[0] != '\0' is enough and faster for a long string.

Thanks,

Kazutaka



More information about the sheepdog mailing list