From c76035f592ad509ceef236b6916108954fab9ed7 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Thu, 29 Sep 2005 12:29:04 +0000 Subject: [PATCH] fixed preparation of the content if we have to get the content from 2 network packets git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@747 152afb58-edef-0310-8abb-c4023f1b3aa9 --- src/mod_fastcgi.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index c8d88066..de6993cd 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -2105,14 +2105,19 @@ static int fastcgi_get_packet(server *srv, handler_ctx *hctx, fastcgi_response_p offset = sizeof(*header); /* ->b should only be the content */ - buffer_reset(packet->b); + buffer_copy_string(packet->b, ""); /* used == 1 */ if (packet->len) { /* copy the content */ for (; c && (packet->b->used < packet->len + 1); c = c->next) { - toread = c->mem->used - c->offset - offset - 1 > packet->len ? packet->len : c->mem->used - c->offset - offset - 1; - - buffer_append_string_len(packet->b, c->mem->ptr + c->offset + offset, toread); + size_t weWant = packet->len - (packet->b->used - 1); + size_t weHave = c->mem->used - c->offset - offset - 1; + + if (weHave > weWant) weHave = weWant; + + buffer_append_string_len(packet->b, c->mem->ptr + c->offset + offset, weHave); + + /* we only skipped the first 8 bytes as they are the fcgi header */ offset = 0; }