httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Brown <mbr...@OpenMarket.com>
Subject mod_fastcgi for 1.2dev
Date Fri, 11 Oct 1996 01:24:06 GMT

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);
      /*



Mime
View raw message