Commit 30238c1c authored by Dag Erling Smørgrav's avatar Dag Erling Smørgrav

Simplify


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2125 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c60ff636
...@@ -260,9 +260,8 @@ Fetch(struct sess *sp) ...@@ -260,9 +260,8 @@ Fetch(struct sess *sp)
struct bereq *bereq; struct bereq *bereq;
int mklen, is_head; int mklen, is_head;
struct http_conn htc[1]; struct http_conn htc[1];
int i; unsigned long content_length;
int content_length, content_written; int i, read;
int read;
char *ptr, *endp; char *ptr, *endp;
char *p = NULL; char *p = NULL;
...@@ -297,18 +296,18 @@ Fetch(struct sess *sp) ...@@ -297,18 +296,18 @@ Fetch(struct sess *sp)
* pipelined bytes to the backend as well * pipelined bytes to the backend as well
*/ */
if (http_GetHdr(sp->http, H_Content_Length, &ptr)) { if (http_GetHdr(sp->http, H_Content_Length, &ptr)) {
endp = ptr + strlen(ptr); content_length = strtoul(ptr, &endp, 10);
content_length = (int)strtol(ptr, &endp, 10); /* XXX should check result of conversion */
content_written = 0; while (content_length) {
while (content_written < content_length) {
p = malloc(content_length); p = malloc(content_length);
read = HTC_Read(sp->htc, p, content_length); read = HTC_Read(sp->htc, p, content_length);
content_written += WRK_Write(w, p, read); WRK_Write(w, p, read);
if (WRK_Flush(w)) { if (WRK_Flush(w)) {
VBE_UpdateHealth(sp, vc, -1); VBE_UpdateHealth(sp, vc, -1);
VBE_ClosedFd(sp->wrk, vc); VBE_ClosedFd(sp->wrk, vc);
return (__LINE__); return (__LINE__);
} }
content_length -= read;
free(p); free(p);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment