/*\r
* A simple FastCGI application example in C++.\r
* \r
- * $Id: echo-cpp.cpp,v 1.3 2001/11/21 16:54:13 robs Exp $\r
+ * $Id: echo-cpp.cpp,v 1.4 2001/11/21 20:18:46 robs Exp $\r
* \r
* Copyright (c) 2001 Rob Saccoccio and Chelsea Networks\r
* All rights reserved.\r
clen = cin.gcount();\r
\r
// chew up any remaining stdin - this shouldn't be necessary\r
- // but it is because mod_fastcgi doesn't handle it correctly\r
+ // but is because mod_fastcgi doesn't handle it correctly\r
do cin.ignore(1024); while (! cin.eof());\r
\r
return clen;\r
long pid = getpid();\r
\r
FCGX_Request request;\r
-\r
+ \r
FCGX_Init();\r
FCGX_InitRequest(&request, 0, 0);\r
\r
while (FCGX_Accept_r(&request) == 0) \r
{\r
+ // Note that the default bufsize (0) will cause the use of iostream\r
+ // methods that require positioning (such as peek(), seek(), \r
+ // unget() and putback()) to fail (in favour of more efficient IO).\r
fcgi_streambuf fin(request.in);\r
fcgi_streambuf fout(request.out);\r
fcgi_streambuf ferr(request.err);\r
- \r
+\r
#ifdef _WIN32\r
cin = &fin;\r
cout = &fout;\r
if (clen) cout.write(content, clen);\r
\r
if (content) delete []content;\r
+\r
+ // If the output streambufs had non-zero bufsizes and\r
+ // were constructed outside of the accept loop (i.e.\r
+ // their destructor won't be called here), they would\r
+ // have to be flushed here.\r
}\r
\r
return 0;\r