You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Brian Behlendorf <br...@hyperreal.com> on 1996/10/22 22:38:14 UTC
cvs commit: apache/src mod_fastcgi.c
brian 96/10/22 13:38:13
Modified: src mod_fastcgi.c
Log:
Reviewed by: Alexei Kosut
Submitted by: Mark Brown <mb...@OpenMarket.com>
Here is a patch to make mod_fastcgi work properly with Apache 1.2dev
(using get_client_block and its friends.)
Revision Changes Path
1.2 +14 -18 apache/src/mod_fastcgi.c
Index: mod_fastcgi.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_fastcgi.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C3 -r1.1 -r1.2
*** mod_fastcgi.c 1996/09/27 22:11:14 1.1
--- mod_fastcgi.c 1996/10/22 20:38:11 1.2
***************
*** 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);
/*