Commit Diff


commit - 3ced9adc82b7b84e9901e32013122f99ff703070
commit + 40e36ce5301442ff9172f57a80b91e1ca8bfd426
blob - df49986c584e5a1f45a0def6d23843ddbdc8ef91
blob + 98b144aa064f722540e70cb344a42e3e59abf96e
--- gotwebd/fcgi.c
+++ gotwebd/fcgi.c
@@ -449,21 +449,23 @@ int
 fcgi_send_response(struct request *c, int type, const void *data,
     size_t len)
 {
+	size_t		 avail;
+
 	if (c->client_status == CLIENT_DISCONNECT)
 		return -1;
 
-	while (len > FCGI_CONTENT_SIZE) {
-		if (send_response(c, type, data, len) == -1)
-			return -1;
+	while (len > 0) {
+		avail = len;
+		if (avail > FCGI_CONTENT_SIZE)
+			avail = FCGI_CONTENT_SIZE;
 
-		data += FCGI_CONTENT_SIZE;
-		len -= FCGI_CONTENT_SIZE;
+		if (send_response(c, type, data, avail) == -1)
+			return -1;
+		data += avail;
+		len -= avail;
 	}
 
-	if (len == 0)
-		return 0;
-
-	return send_response(c, type, data, len);
+	return 0;
 }
 
 int