Received: by taz.hyperreal.com (8.7.6/V2.0) id SAA19264; Thu, 10 Oct 1996 18:24:42 -0700 (PDT) Received: from relay.openmarket.com by taz.hyperreal.com (8.7.6/V2.0) with SMTP id SAA19257; Thu, 10 Oct 1996 18:24:39 -0700 (PDT) Received: from breckenridge.openmarket.com (breckenridge.openmarket.com [199.170.183.71]) by relay.openmarket.com (8.6.10/8.6.6) with ESMTP id VAA00453 for ; Thu, 10 Oct 1996 21:24:07 -0400 Received: from OpenMarket.com (mbrown@localhost [127.0.0.1]) by breckenridge.openmarket.com (8.6.9/8.6.6) with ESMTP id VAA00482 for ; Thu, 10 Oct 1996 21:24:07 -0400 Message-Id: <199610110124.VAA00482@breckenridge.openmarket.com> X-Mailer: exmh version 1.6.5 12/11/95 To: new-httpd@hyperreal.com Subject: mod_fastcgi for 1.2dev Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 10 Oct 1996 21:24:06 -0400 From: Mark Brown Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com Here is a patch to make mod_fastcgi work properly with Apache 1.2dev (using get_client_block and its friends.) --mark *** mod_fastcgi.c.orig Fri Sep 27 18:11:14 1996 --- mod_fastcgi.c Thu Oct 10 21:12:02 1996 *************** *** 1748,1754 **** Buffer *reqInbufPtr; /* client input buffer */ Buffer *reqOutbufPtr; /* client output buffer */ char *errorMsg; /* error message from failed request */ ! int contentLengthRemaining; /* bytes still expected from client */ DString *header; DString *errorOut; int parseHeader; /* TRUE iff parsing response headers */ --- 1748,1754 ---- Buffer *reqInbufPtr; /* client input buffer */ Buffer *reqOutbufPtr; /* client output buffer */ char *errorMsg; /* error message from failed request */ ! int expectingClientContent; /* >0 => more content, <=0 => no more */ DString *header; DString *errorOut; int parseHeader; /* TRUE iff parsing response headers */ *************** *** 2876,2882 **** * in the output buffer, indicate EOF. */ if(movelen == in_len ! && infoPtr->contentLengthRemaining <= 0 && BufferFree(infoPtr->outbufPtr) >= sizeof(FCGI_Header)) { SendPacketHeader(infoPtr, FCGI_STDIN, 0); infoPtr->eofSent = TRUE; --- 2876,2882 ---- * in the output buffer, indicate EOF. */ if(movelen == in_len ! && infoPtr->expectingClientContent <= 0 && BufferFree(infoPtr->outbufPtr) >= sizeof(FCGI_Header)) { SendPacketHeader(infoPtr, FCGI_STDIN, 0); infoPtr->eofSent = TRUE; *************** *** 3415,3427 **** * When FillOutbuf returns, either * both reqInbuf and outbuf are full * or ! * contentLengthRemaining <= 0 and either * reqInbuf is empty or outbuf is full. * * "outbuf full" means "at most sizeof(FCGI_Header) bytes free." * * In case of an error reading from the client, sets ! * contentLengthRemaining == -1. * *---------------------------------------------------------------------- */ --- 3415,3427 ---- * When FillOutbuf returns, either * both reqInbuf and outbuf are full * or ! * expectingClientContent <= 0 and either * reqInbuf is empty or outbuf is full. * * "outbuf full" means "at most sizeof(FCGI_Header) bytes free." * * In case of an error reading from the client, sets ! * expectingClientContent == -1. * *---------------------------------------------------------------------- */ *************** *** 3432,3453 **** while(BufferFree(infoPtr->reqInbufPtr) > 0 || BufferFree(infoPtr->outbufPtr) > 0) { ClientToCgiBuffer(infoPtr); ! if(infoPtr->contentLengthRemaining <= 0) { break; } BufferPeekExpand(infoPtr->reqInbufPtr, &end, &count); - count = min(count, infoPtr->contentLengthRemaining); if(count == 0) { break; } ! countRead = read_client_block(reqPtr, end, count); if(countRead > 0) { - infoPtr->contentLengthRemaining -= countRead; BufferExpand(infoPtr->reqInbufPtr, countRead); } else if (countRead == 0) { ! infoPtr->contentLengthRemaining = 0; } else { ! infoPtr->contentLengthRemaining = -1; } } } --- 3432,3451 ---- while(BufferFree(infoPtr->reqInbufPtr) > 0 || BufferFree(infoPtr->outbufPtr) > 0) { ClientToCgiBuffer(infoPtr); ! if(infoPtr->expectingClientContent <= 0) { break; } BufferPeekExpand(infoPtr->reqInbufPtr, &end, &count); if(count == 0) { break; } ! countRead = get_client_block(reqPtr, end, count); if(countRead > 0) { BufferExpand(infoPtr->reqInbufPtr, countRead); } else if (countRead == 0) { ! infoPtr->expectingClientContent = 0; } else { ! infoPtr->expectingClientContent = -1; } } } *************** *** 3675,3680 **** --- 3673,3682 ---- reqPtr->filename, reqPtr); return NOT_FOUND; } + status = setup_client_block(reqPtr); + if(status != OK) { + return status; + } /* * Allocate and initialize FastCGI private data to augment the request * structure. *************** *** 3700,3713 **** infoPtr->requestId = 1; /* anything but zero is OK here */ infoPtr->eofSent = FALSE; infoPtr->fd = -1; ! { ! char *lenp = table_get(reqPtr->headers_in, "Content-length"); ! int contentLength = (lenp) ? strtol(lenp, NULL, 10) : 0; ! if (contentLength <= 0) { ! contentLength = 0; ! } ! infoPtr->contentLengthRemaining = contentLength; ! } SendBeginRequest(infoPtr); SendEnvironment(reqPtr, infoPtr); /* --- 3702,3709 ---- infoPtr->requestId = 1; /* anything but zero is OK here */ infoPtr->eofSent = FALSE; infoPtr->fd = -1; ! infoPtr->expectingClientContent = (should_client_block(reqPtr) != 0); ! SendBeginRequest(infoPtr); SendEnvironment(reqPtr, infoPtr); /*