print OUT while <DATA>;
close OUT;
__END__
-/* $Id: FCGI.PL,v 1.17 2000/11/01 14:27:49 skimo Exp $ */
+/* $Id: FCGI.PL,v 1.18 2000/11/01 15:12:26 skimo Exp $ */
#include "EXTERN.h"
#include "perl.h"
}
}
-static int
-FCGI_Accept(FCGP_Request* request)
+static int
+FCGI_IsFastCGI(FCGP_Request* request)
{
static int isCGI = -1; /* -1: not checked; 0: FCGI; 1: CGI */
- int req_isCGI =
- request->requestPtr->listen_sock == FCGI_LISTENSOCK_FILENO ?
- isCGI : 0;
+ if (request->requestPtr->listen_sock == FCGI_LISTENSOCK_FILENO) {
+ if (isCGI == -1)
+ isCGI = FCGX_IsCGI();
+ return !isCGI;
+ }
+
+ /* A explicit socket is being used -> assume FastCGI */
+ return 1;
+}
+static int
+FCGI_Accept(FCGP_Request* request)
+{
dTHX;
- if(req_isCGI == -1) {
- /*
- * First call to FCGI_Accept. Is application running
- * as FastCGI or as CGI?
- */
- req_isCGI = isCGI = FCGX_IsCGI();
- } else if(req_isCGI) {
+ if (!FCGI_IsFastCGI(request)) {
+ static int been_here = 0;
+
/*
* Not first call to FCGI_Accept and running as CGI means
* application is done.
*/
- return(EOF);
- }
- if(!req_isCGI) {
+ if (been_here)
+ return EOF;
+
+ been_here = 1;
+ } else {
#ifdef USE_SFIO
int i;
#endif
typedef GV* GLOBREF;
typedef HV* HASHREF;
-MODULE = FCGI PACKAGE = FCGI
+MODULE = FCGI PACKAGE = FCGI PREFIX = FCGI_
BOOT:
FCGI_Init();
close(socket);
int
-Accept(request)
+FCGI_Accept(request)
FCGI request;
PROTOTYPE: $
- CODE:
- RETVAL = FCGI_Accept(request);
-
- OUTPUT:
- RETVAL
-
-
void
-Finish(request)
-
+FCGI_Finish(request)
FCGI request;
PROTOTYPE: $
- CODE:
- {
- /*
- * Finish the request.
- */
- FCGI_Finish(request);
- }
-
-
void
-Flush(request)
-
+FCGI_Flush(request)
FCGI request;
PROTOTYPE: $
- CODE:
- FCGI_Flush(request);
-
HV *
GetEnvironment(request)
FCGI request;
PPCODE:
EXTEND(sp,3);
for (i = 0; i < 3; ++i)
- PUSHs(sv_2mortal(newRV(request->gv[i])));
+ PUSHs(sv_2mortal(newRV((SV *) request->gv[i])));
+
+int
+FCGI_IsFastCGI(request)
+ FCGI request;
+
+ PROTOTYPE: $
void
Detach(request)
int
-StartFilterData(request)
+FCGI_StartFilterData(request)
FCGI request;
PROTOTYPE: $
- CODE:
- RETVAL = FCGI_StartFilterData(request);
-
- OUTPUT:
- RETVAL
-
void
DESTROY(request)
FCGI request;
-# $Id: FCGI.pm,v 1.13 2000/11/01 14:27:49 skimo Exp $
+# $Id: FCGI.pm,v 1.14 2000/11/01 15:12:27 skimo Exp $
package FCGI;
Returns the file handle parameters passed to FCGI::Request.
+=item $isfcgi = $req->IsFastCGI()
+
+Returns whether or not the program was run as a FastCGI.
+
=back
=head1 AUTHOR