r2115 - trunk/varnish-cache/bin/varnishd

Dag-Erling Smørgrav des at linpro.no
Thu Oct 18 15:50:28 CEST 2007


cecilihf at projects.linpro.no writes:
> @@ -287,6 +290,17 @@
>  		return (__LINE__);
>  	WRK_Reset(w, &vc->fd);
>  	http_Write(w, hp, 0);
> +	
> +	/* If a POST request was passed to fetch, we must send
> +	 * any pipelined bytes to the backend as well */
> +	if (!strcmp(http_GetReq(sp->http), "POST")) {
> +		sprintf(hdr, "%ccontent-length:", 15);
> +		assert(http_GetHdr(sp->http, hdr, &ptr));
> +		content_length = atoi(ptr);
> +		if (sp->htc->pipeline.b != NULL && content_length > 0)
> +			WRK_Write(w, sp->htc->pipeline.b, content_length);
> +	}
> +	
>  	if (WRK_Flush(w)) {
>  		VBE_UpdateHealth(sp, vc, -1);
>  		VBE_ClosedFd(sp->wrk, vc);
>

This should not be predicated on the request method being POST, but
rather on the presence of a Content-Length header.

atoi() is not safe, BTW, as it gives no error indication.  Use
strto*() instead.

Your code does not check that there is enough data in the pipeline,
and will not handle large requests (like a file upload) where we might
have to refill the pipeline several times to get the entire body.

DES
-- 
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no



More information about the varnish-commit mailing list