Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-06-02 19:46:00


Author: drrngrvy
Date: 2008-06-02 19:45:59 EDT (Mon, 02 Jun 2008)
New Revision: 46067
URL: http://svn.boost.org/trac/boost/changeset/46067

Log:
Reverted fcgi hello_world example.
Text files modified:
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/hello_world/main.cpp | 64 ++++++++++------------------------------
   1 files changed, 16 insertions(+), 48 deletions(-)

Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/hello_world/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/hello_world/main.cpp (original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/hello_world/main.cpp 2008-06-02 19:45:59 EDT (Mon, 02 Jun 2008)
@@ -12,52 +12,21 @@
 // The simplest FastCGI program, outputs only "Hello there, universe."
 //
 
-#include <iomanip>
-#include <fstream>
 #include <boost/cgi/fcgi.hpp>
 #include <boost/cgi.hpp>
-#include <boost/asio.hpp>
-#include <sys/socket.h>
 
 using namespace std;
 using namespace boost::fcgi;
 
-template<typename Request, typename Response>
-int handle_request(Request& req, Response& resp)
-{
- // This is a minimal response. The content_type(...) may go before or after
- // the response text.
- resp<< content_type("text/plain")
- << "Hello there, universe.";
-
- return_(resp, req, 0);
-}
-
-/// Handle a vanilla CGI request
-int handle_request()
-{
- boost::cgi::request req;
- response resp;
- return handle_request(req,resp);
-}
-
+=======
 /// Handle a FastCGI request
 template<typename Acceptor>
 int handle_request(Acceptor& a)
 {
- request req(a.protocol_service()); // Our request.
-
   int ret = 0;
   for (;;) // Handle requests until something goes wrong
            // (an exception will be thrown).
- {
- a.accept(req);
- response resp; // A response object to make our lives easier.
- ret = handle_request(req, resp);
- }
-
- return ret;
-}
+>>>>>>> .r46066
 
 int main()
 {
@@ -65,24 +34,23 @@
 {
   service s; // This becomes useful with async operations.
   acceptor a(s);
- ofstream file("/var/www/log/is_cgi.log", std::ios::app);
-
- if (a.is_cgi())
- {
- file<< "Is CGI" << endl;
- file.flush();
- handle_request();
- }
- else
+
+ for (;;)
   {
- file<< "Is FastCGI (probably)";
- file.flush();
- handle_request(a);
+ request req(s); // Our request.
+
+ for (;;) // Handle requests until something goes wrong
+ // (an exception will be thrown).
+ {
+ a.accept(req);
+ response resp; // A response object to make our lives easier.
+ ret = handle_request(req, resp);
+ if (ret) break; // Use a new request if something went wrong.
+ }
+ if (!a.is_open()) break; // Quit completely if the acceptor bails out.
   }
 
- file.flush();
-
- return 0;
+ return ret;
 }
 catch(boost::system::system_error& err)
 {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk