myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-365-g6


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-365-g62e3287
Date: Fri, 06 Nov 2009 11:37:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  62e32877f1bbf2e92ecab11d88ff30eb3c5713cf (commit)
      from  8b2808f4556d1bf86af3708332d0f4e4ad599cf8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 62e32877f1bbf2e92ecab11d88ff30eb3c5713cf
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Nov 6 12:21:24 2009 +0100

    Define and use HttpDataHandler::{RET_FAILURE, RET_OK}.
    
    Now all HTTP handlers return these values instead of magic numbers.
    The responsibility to translate these codes to return values understood
    from the Protocol layer and by the connections scheduler is left to the
    Http class.

diff --git a/myserver/include/protocol/http/http_data_handler.h 
b/myserver/include/protocol/http/http_data_handler.h
index 9de3caa..16de99f 100644
--- a/myserver/include/protocol/http/http_data_handler.h
+++ b/myserver/include/protocol/http/http_data_handler.h
@@ -27,11 +27,18 @@
 
 
 /*!
- *Base class to handle HTTP data.
+ * Base class to handle HTTP data.
  */
 class HttpDataHandler
 {
 public:
+
+  enum
+    {
+      RET_OK = 0,
+      RET_FAILURE
+    };
+
   virtual int load ();
   virtual int unLoad ();
 
@@ -64,5 +71,4 @@ public:
 
 };
 
-
 #endif
diff --git a/myserver/src/http_handler/cgi/cgi.cpp 
b/myserver/src/http_handler/cgi/cgi.cpp
index 537d73a..209c397 100644
--- a/myserver/src/http_handler/cgi/cgi.cpp
+++ b/myserver/src/http_handler/cgi/cgi.cpp
@@ -340,7 +340,7 @@ int Cgi::sendData (HttpThreadContext* td, Pipe &stdOutFile, 
FiltersChain& chain,
     return ret;
 
   if (!nph && onlyHeader)
-    return 1;
+    return HttpDataHandler::RET_OK;
 
   /* Create the output filters chain.  */
   if (td->mime
@@ -378,7 +378,7 @@ int Cgi::sendData (HttpThreadContext* td, Pipe &stdOutFile, 
FiltersChain& chain,
       if (stdOutFile.read (td->secondaryBuffer->getBuffer (),
                            td->secondaryBuffer->getRealLength (),
                            &nBytesRead))
-        return 0;
+        return HttpDataHandler::RET_FAILURE;
 
       if (!aliveProcess && !nBytesRead)
         break;
@@ -391,19 +391,20 @@ int Cgi::sendData (HttpThreadContext* td, Pipe 
&stdOutFile, FiltersChain& chain,
                                                     &chain,
                                                     td->appendOutputs,
                                                     useChunks))
-        return 0;
+        return HttpDataHandler::RET_FAILURE;
 
       nbw += nBytesRead;
     }
 
     /* Send the last null chunk if needed.  */
     if (useChunks && chain.getStream ()->write ("0\r\n\r\n", 5, &nbw2))
-      return 0;
+        return HttpDataHandler::RET_FAILURE;
   }
 
   /* Update the Content-length field for logging activity.  */
   td->sentData += nbw;
-  return 1;
+
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -527,7 +528,7 @@ int Cgi::sendHeader (HttpThreadContext* td, Pipe 
&stdOutFile, FiltersChain& chai
           if (HttpHeaders::sendHeader (td->response, *chain.getStream (),
                                        *td->buffer, td))
             {
-              *ret = 0;
+              *ret = HttpDataHandler::RET_FAILURE;
               return 1;
             }
 
@@ -544,7 +545,10 @@ int Cgi::sendHeader (HttpThreadContext* td, Pipe 
&stdOutFile, FiltersChain& chai
                                                     &chain,
                                                     td->appendOutputs,
                                                     useChunks))
-        return 0;
+        {
+          *ret = HttpDataHandler::RET_FAILURE;
+          return 1;
+        }
 
       td->sentData += headerOffset - headerSize;
     }
diff --git a/myserver/src/http_handler/fastcgi/fastcgi.cpp 
b/myserver/src/http_handler/fastcgi/fastcgi.cpp
index 0927a23..c5d9adc 100644
--- a/myserver/src/http_handler/fastcgi/fastcgi.cpp
+++ b/myserver/src/http_handler/fastcgi/fastcgi.cpp
@@ -1,24 +1,24 @@
 /*
-MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
- *To get more info about the FastCGI protocol please visit the official
- *FastCGI site at: http://www.fastcgi.com.
- *On that site you can find samples and all the supported languages.
+  To get more info about the FastCGI protocol please visit the official
+  FastCGI site at: http://www.fastcgi.com.
+  On that site you can find samples and all the supported languages.
  */
 #include <include/http_handler/fastcgi/fastcgi.h>
 #include <include/protocol/http/env/env.h>
@@ -44,7 +44,6 @@ int FastCgi::timeout = MYSERVER_SEC (15);
 /*! Process server manager.  */
 ProcessServerManager *FastCgi::processServerManager = 0;
 
-
 struct FourChar
 {
   union
@@ -55,7 +54,7 @@ struct FourChar
 };
 
 /*!
- *Entry-Point to manage a FastCGI request.
+ * Entry-Point to manage a FastCGI request.
  */
 int FastCgi::send (HttpThreadContext* td, const char* scriptpath,
                    const char *cgipath, bool execute, bool onlyHeader)
@@ -89,14 +88,11 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   if (!(td->permissions & MYSERVER_PERMISSION_EXECUTE))
     return td->http->sendAuth ();
 
-
-  {
-    string tmp;
-    tmp.assign (cgipath);
-    FilesUtility::splitPath (tmp, td->cgiRoot, td->cgiFile);
-    tmp.assign (scriptpath);
-    FilesUtility::splitPath (tmp, td->scriptDir, td->scriptFile);
-  }
+  string tmp;
+  tmp.assign (cgipath);
+  FilesUtility::splitPath (tmp, td->cgiRoot, td->cgiFile);
+  tmp.assign (scriptpath);
+  FilesUtility::splitPath (tmp, td->scriptDir, td->scriptFile);
 
   chain.setProtocol (td->http);
   chain.setProtocolData (td);
@@ -131,10 +127,10 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
         subString = !subString;
     }
   /*!
-   *Save the cgi path and the possible arguments.
-   *the (x < len) case is when additional arguments are specified.
-   *If the cgipath is enclosed between " and " do not consider them
-   *when splitting directory and file name.
+    Save the cgi path and the possible arguments.
+    the (x < len) case is when additional arguments are specified.
+    If the cgipath is enclosed between " and " do not consider them
+    when splitting directory and file name.
    */
   if (len)
     {
@@ -221,7 +217,7 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   exit = 0;
 
   /*! Return 1 if keep the connection. A nonzero value also mean no errors. */
-  ret = 1;
+  ret = HttpDataHandler::RET_OK;
 
   initialTicks = getTicks ();
 
@@ -235,8 +231,7 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
       if (readHeader (&con, &header, initialTicks, timeout, id))
         {
           exit = 1;
-          ret = 1;
-          td->http->raiseHTTPError (500);
+          ret = td->http->raiseHTTPError (500);
           break;
         }
 
@@ -251,7 +246,7 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
       if (dim == 0)
         {
           exit = 1;
-          ret = 1;
+          ret = HttpDataHandler::RET_FAILURE;
         }
       else
         {
@@ -263,7 +258,7 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
               con.sock.close ();
               td->http->raiseHTTPError (501);
               exit = 1;
-              ret = 0;
+              ret = HttpDataHandler::RET_FAILURE;
               break;
             case FCGISTDOUT:
               headerCompleted = false;
@@ -276,7 +271,8 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
                   if (ret == 1)
                     responseCompleted = true;
                   else
-                    ret = 0;
+                    ret = HttpDataHandler::RET_FAILURE;
+
                   break;
                 }
 
@@ -310,7 +306,7 @@ int FastCgi::send (HttpThreadContext* td, const char* 
scriptpath,
               if (nbr == (u_long)-1)
                 {
                   exit = 1;
-                  ret = 0;
+                  ret = HttpDataHandler::RET_FAILURE;
                   break;
                 }
               toPad -= nbr;
@@ -662,16 +658,17 @@ int FastCgi::fastCgiRequest (FcgiContext* con, int id)
 
 
 /*!
- *Handle the STDOUT data received from the FastCGI server.
- *The FastCGI header must be read previously, only the payload is processed 
here.
- *\param con The current FastCGI context.
- *\param dim Size of the payload.
- *\param timeout Connection timeout to use.
- *\param chain Output chain where to send data.
- *\param responseCompleted Output value.  It is true when the response is 
completed.
- *\param onlyHeader Send only the HTTP header.
- *\return 0 on success.
- *\return 1 if a full response is sent to the client.
+  Handle the STDOUT data received from the FastCGI server.
+  The FastCGI header must be read previously, only the payload is processed 
here.
+  \param con The current FastCGI context.
+  \param dim Size of the payload.
+  \param timeout Connection timeout to use.
+  \param chain Output chain where to send data.
+  \param responseCompleted Output value.  It is true when the response is 
completed.
+  \param onlyHeader Send only the HTTP header.
+  \return 0 on success.
+  \return 1 if a full response is sent to the client.
+  \return -1 on error.
  */
 int FastCgi::sendData (FcgiContext* con, u_long dim, u_long timeout, 
FiltersChain* chain,
                        bool *responseCompleted, bool onlyHeader)
diff --git a/myserver/src/http_handler/http_dir/http_dir.cpp 
b/myserver/src/http_handler/http_dir/http_dir.cpp
index 89c9e32..25eb7ec 100644
--- a/myserver/src/http_handler/http_dir/http_dir.cpp
+++ b/myserver/src/http_handler/http_dir/http_dir.cpp
@@ -363,10 +363,10 @@ int HttpDir::send (HttpThreadContext* td,
 
   if (HttpHeaders::sendHeader (td->response, *td->connection->socket,
                                *td->buffer, td))
-    return 1;
+    return HttpDataHandler::RET_FAILURE;
 
   if (onlyHeader)
-    return 0;
+    return HttpDataHandler::RET_OK;
 
   sortIndex = td->request.uriOpts.find ("sort=");
 
@@ -644,14 +644,13 @@ int HttpDir::send (HttpThreadContext* td,
 
   if (!td->appendOutputs && useChunks
       && chain.getStream ()->write ("0\r\n\r\n", 5, &nbw))
-    return 1;
+    return HttpDataHandler::RET_FAILURE;
 
   /* For logging activity.  */
   td->sentData += sentData;
 
   chain.clearAllFilters ();
-  return 1;
-
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index 407fdec..17ad2c9 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -1,21 +1,20 @@
 /*
-MyServer
-Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
 #include <include/protocol/http/http.h>
 #include <include/protocol/http/http_headers.h>
 #include <include/http_handler/http_file/http_file.h>
@@ -39,7 +38,7 @@ extern "C"
 }
 
 /*!
- * Main function to handle the HTTP PUT command.
+  Main function to handle the HTTP PUT command.
  */
 int HttpFile::putFile (HttpThreadContext* td,
                        string& filename)
@@ -98,7 +97,7 @@ int HttpFile::putFile (HttpThreadContext* td,
         file.close ();
 
         td->http->raiseHTTPError (200);
-        return keepalive;
+        return HttpDataHandler::RET_OK;
       }
     else
       {
@@ -139,7 +138,7 @@ int HttpFile::putFile (HttpThreadContext* td,
         file.close ();
 
         td->http->raiseHTTPError (201);
-        return 1;
+        return HttpDataHandler::RET_OK;
       }
   }
   catch (...)
@@ -358,7 +357,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             file->close ();
             delete file;
             chain.clearAllFilters ();
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
           }
         memStream.refresh ();
         dataSent += nbw;
@@ -426,25 +425,25 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
         file->close ();
         delete file;
         chain.clearAllFilters ();
-        return 1;
+        return HttpDataHandler::RET_FAILURE;
       }
 
     /*
-     * If is requested only the header exit from the function;
-     * used by the HEAD request.
-     */
+      If is requested only the header exit from the function;
+      used by the HEAD request.
+    */
     if (onlyHeader)
       {
         file->close ();
         delete file;
         chain.clearAllFilters ();
-        return 0;
+        return HttpDataHandler::RET_OK;
       }
 
     /*
-     * Check if there are all the conditions to use a direct copy from the
-     * file to the socket.
-     */
+      Check if there are all the conditions to use a direct copy from the
+      file to the socket.
+    */
     if (!useChunks && chain.isEmpty () && !td->appendOutputs
         && !(td->http->getProtocolOptions () & Protocol::SSL))
       {
@@ -459,7 +458,10 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
 
         td->sentData += nbw;
 
-        return ret;
+        if (ret)
+          return HttpDataHandler::RET_FAILURE;
+        else
+          return HttpDataHandler::RET_OK;
       }
 
     if (td->appendOutputs)
@@ -468,10 +470,10 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       chain.setStream (td->connection->socket);
 
     /*
-     * Flush initial data.  This is data that filters could have added
-     * and we have to send before the file itself, for example the gzip
-     * filter add a header to file.
-     */
+      Flush initial data.  This is data that filters could have added
+      and we have to send before the file itself, for example the gzip
+      filter add a header to file.
+    */
     if (memStream.availableToRead ())
       {
         if (memStream.read (td->buffer->getBuffer (),
@@ -480,7 +482,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             file->close ();
             delete file;
             chain.clearAllFilters ();
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
           }
 
         memStream.refresh ();
@@ -493,8 +495,8 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             file->close ();
             delete file;
             chain.clearAllFilters ();
-            return 1;
             dataSent += nbw;
+            return HttpDataHandler::RET_FAILURE;
           }
       } /* memStream.availableToRead ().  */
 
@@ -540,11 +542,11 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             else
               {
                 /*
-                 * Replace the final stream before the flush and write to a
-                 * memory buffer, after all the data is flushed from the
-                 * chain we can replace the stream with the original one and
-                 * write there the HTTP data chunk.
-                 */
+                  Replace the final stream before the flush and write to a
+                  memory buffer, after all the data is flushed from the
+                  chain we can replace the stream with the original one and
+                  write there the HTTP data chunk.
+                */
                 Stream* tmpStream = chain.getStream ();
                 chain.setStream (&memStream);
                 memStream.refresh ();
@@ -585,36 +587,40 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
   /* For logging activity.  */
   td->sentData += dataSent;
   chain.clearAllFilters ();
-  return !ret;
+
+  if (ret)
+  return HttpDataHandler::RET_FAILURE;
+  else
+    return HttpDataHandler::RET_OK;
 }
 
 /*!
- * Constructor for the class.
- */
+  Constructor for the class.
+*/
 HttpFile::HttpFile ()
 {
 
 }
 
 /*!
- * Destroy the object.
- */
+  Destroy the object.
+*/
 HttpFile::~HttpFile ()
 {
 
 }
 
 /*!
- * Load the static elements.
- * \param confFile Not used.
- */
+  Load the static elements.
+  \param confFile Not used.
+*/
 int HttpFile::load ()
 {
   return 0;
 }
 
 /*!
- * Unload the static elements.
+  Unload the static elements.
  */
 int HttpFile::unLoad ()
 {
diff --git a/myserver/src/http_handler/isapi/isapi.cpp 
b/myserver/src/http_handler/isapi/isapi.cpp
index 4283296..9c96057 100644
--- a/myserver/src/http_handler/isapi/isapi.cpp
+++ b/myserver/src/http_handler/isapi/isapi.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, 
Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "stdafx.h"
@@ -53,7 +53,7 @@ BOOL WINAPI ISAPI_ServerSupportFunctionExport (HCONN hConn, 
DWORD dwHSERRequest,
   if (ConnInfo == NULL)
     {
       Server::getInstance ()->log ("isapi::ServerSupportFunctionExport: 
invalid hConn");
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
 
   switch (dwHSERRequest)
@@ -81,6 +81,7 @@ BOOL WINAPI ISAPI_ServerSupportFunctionExport (HCONN hConn, 
DWORD dwHSERRequest,
       mapInfo->dwFlags = HSE_URL_FLAGS_WRITE | HSE_URL_FLAGS_SCRIPT
         | HSE_URL_FLAGS_EXECUTE;
       break;
+
     case HSE_REQ_MAP_URL_TO_PATH:
       if (((char*)lpvBuffer)[0])
         strcpy (uri,(char*)lpvBuffer);
@@ -88,52 +89,58 @@ BOOL WINAPI ISAPI_ServerSupportFunctionExport (HCONN hConn, 
DWORD dwHSERRequest,
         lstrcpyn (uri,ConnInfo->td->request.uri.c_str (),
                  (int)ConnInfo->td->request.uri.length 
()-ConnInfo->td->pathInfo.length () +1);
       ret = ConnInfo->td->http->getPath (tmp ,uri,0);
-      if (ret!=200)
+      if (ret != 200)
         {
           if (buffer)
             delete [] buffer;
-          return 1;
+          return HttpDataHandler::RET_FAILURE;
         }
 
       if (tmp.length () >= *lpdwSize)
         {
           SetLastError (ERROR_INSUFFICIENT_BUFFER);
-          return 0;
+          return HttpDataHandler::RET_FAILURE;
         }
       strcpy ((char*)lpvBuffer, tmp.c_str ());
       if (FilesUtility::completePath ((char**)&lpvBuffer,(int*)lpdwSize,  1))
         {
           SetLastError (ERROR_INSUFFICIENT_BUFFER);
-          return 0;
+          return HttpDataHandler::RET_FAILURE;
         }
       *lpdwSize=(DWORD)strlen ((char*)lpvBuffer);
       break;
+
     case HSE_REQ_SEND_URL_REDIRECT_RESP:
       return ((Isapi*)ConnInfo->isapi)->Redirect (ConnInfo->td,
                                                  ConnInfo->connection,(char 
*)lpvBuffer);
       break;
+
     case HSE_REQ_SEND_URL:
       return ((Isapi*)ConnInfo->isapi)->Senduri (ConnInfo->td,
                                                 ConnInfo->connection,(char 
*)lpvBuffer);
       break;
+
     case HSE_REQ_SEND_RESPONSE_HEADER:
       return ((Isapi*)ConnInfo->isapi)->SendHeader (ConnInfo->td,
                                                    ConnInfo->connection,(char 
*)lpvBuffer);
       break;
+
     case HSE_REQ_DONE_WITH_SESSION:
       ConnInfo->td->response.httpStatus=*(DWORD*)lpvBuffer;
       SetEvent (ConnInfo->ISAPIDoneEvent);
       break;
+
     case HSE_REQ_IS_KEEP_CONN:
       if (ConnInfo->td->request.isKeepAlive ())
         *((BOOL*)lpvBuffer)=1;
       else
         *((BOOL*)lpvBuffer)=0;
       break;
+
     default:
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
-  return 1;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -197,23 +204,24 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
   u_long nbw=0;
 
   if (*lpdwBytes == 0)
-    return 1;
+    return HttpDataHandler::RET_FAILURE;
 
   Isapi::isapiMutex->lock ();
   ConnInfo = Isapi::HConnRecord (hConn);
   Isapi::isapiMutex->unlock ();
 
   if (ConnInfo == NULL)
-    return 1;
-  buffer=(char*)ConnInfo->td->buffer->getBuffer ();
+    return HttpDataHandler::RET_FAILURE;
+
+  buffer= (char*)ConnInfo->td->buffer->getBuffer ();
   HttpRequestHeader::Entry *connection = ConnInfo->td->request.other.get 
("Connection");
 
   if (ConnInfo == NULL)
   {
     ((Vhost*)(ConnInfo->td->connection->host))->warningsLogWrite (_("ISAPI: 
internal error"));
-    return 0;
+    return HttpDataHandler::RET_FAILURE;
   }
-  keepalive =connection && (!stringcmpi (connection->value->c_str (), 
"keep-alive")) ;
+  keepalive = connection && (!stringcmpi (connection->value->c_str (), 
"keep-alive")) ;
 
   /*If the HTTP header was sent do not send it again. */
   if (!ConnInfo->headerSent)
@@ -285,7 +293,7 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
 
               if (HttpHeaders::sendHeader (ConnInfo->td->response, 
*td->connection->socket,
                                            *ConnInfo->td->secondaryBuffer, 
ConnInfo->td))
-                return 1;
+                return HttpDataHandler::RET_FAILURE;
             }
           /*! Save the headerSent status. */
           ConnInfo->headerSent=1;
@@ -304,21 +312,21 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
                   sprintf (chunkSize, "%x\r\n", len);
                   if (ConnInfo->chain.getStream ()->write (chunkSize,
                                                            (int)strlen 
(chunkSize), &nbw))
-                    return 0;
+                    return HttpDataHandler::RET_FAILURE;
                 }
 
               if (ConnInfo->td->appendOutputs)
                 {
                   if (ConnInfo->td->outputData.writeToFile ((char*)(buffer + 
headerSize),
                                                             len, &nbw))
-                    return 0;
+                    return HttpDataHandler::RET_FAILURE;
                   ConnInfo->dataSent += nbw;
                 }
               else
                 {
                   if (ConnInfo->chain.write ((char*)(buffer + headerSize),
                                              len, &nbw))
-                    return 0;
+                    return HttpDataHandler::RET_FAILURE;
                   ConnInfo->dataSent += nbw;
                 }
 
@@ -326,7 +334,7 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
               if (keepalive && (!ConnInfo->td->appendOutputs))
                 {
                   if (ConnInfo->chain.getStream ()->write ("\r\n", 2, &nbw))
-                    return 0;
+                    return HttpDataHandler::RET_FAILURE;
                 }
             }
         }
@@ -343,19 +351,19 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
           nbw = ConnInfo->connection->socket->send (chunkSize,
                                                     (int)strlen (chunkSize), 
0);
           if ((nbw == (u_long)-1) || (!nbw))
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
         }
 
       if (ConnInfo->td->appendOutputs)
         {
           if (ConnInfo->td->outputData.writeToFile ((char*)Buffer,*lpdwBytes, 
&nbw))
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
           ConnInfo->dataSent += nbw;
         }
       else
         {
           if (ConnInfo->chain.write ((char*)Buffer,*lpdwBytes, &nbw))
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
           ConnInfo->dataSent += nbw;
         }
 
@@ -363,7 +371,7 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
         {
           nbw = ConnInfo->connection->socket->send ("\r\n", 2, 0);
           if ((nbw == (u_long)-1) || (!nbw))
-            return 0;
+            return HttpDataHandler::RET_FAILURE;
         }
     }
 
@@ -371,7 +379,7 @@ BOOL WINAPI ISAPI_WriteClientExport (HCONN hConn, LPVOID 
Buffer, LPDWORD lpdwByt
 
   ConnInfo->td->sentData += ConnInfo->dataSent;
 
-  return (nbw != -1) ? 1 : 0;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -389,21 +397,19 @@ BOOL WINAPI ISAPI_ReadClientExport (HCONN hConn, LPVOID 
lpvBuffer,
   if (ConnInfo == NULL)
   {
     ((Vhost*)(ConnInfo->td->connection->host))->warningsLogWrite (_("ISAPI: 
internal error"));
-    return 0;
+    return HttpDataHandler::RET_FAILURE;
   }
 
   ConnInfo->td->inputData.read ((char*)lpvBuffer, *lpdwSize, &NumRead);
 
   if (NumRead == -1)
-  {
-    *lpdwSize = 0;
-    return 0;
-  }
-  else
-  {
-    *lpdwSize = (DWORD)NumRead;
-    return 1;
-  }
+    {
+      *lpdwSize = 0;
+      return HttpDataHandler::RET_FAILURE;
+    }
+
+  *lpdwSize = (DWORD)NumRead;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -415,15 +421,17 @@ BOOL WINAPI ISAPI_GetServerVariableExport (HCONN hConn,
                                            LPDWORD lpdwSize)
 {
   ConnTableRecord *ConnInfo;
-  BOOL ret = 1;
+  BOOL ret = HttpDataHandler::RET_OK;
+
   Isapi::isapiMutex->lock ();
   ConnInfo = Isapi::HConnRecord (hConn);
   Isapi::isapiMutex->unlock ();
+
   if (ConnInfo == NULL)
     {
       Server::getInstance ()->log (
                             "Isapi::GetServerVariableExport: invalid hConn");
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
 
   if (!strcmp (lpszVariableName, "ALL_HTTP"))
@@ -431,12 +439,9 @@ BOOL WINAPI ISAPI_GetServerVariableExport (HCONN hConn,
 
       if (Isapi::buildAllHttpHeaders (ConnInfo->td,ConnInfo->connection,
                                       lpvBuffer, lpdwSize))
-        ret = 1;
-
-      else
         {
           SetLastError (ERROR_INSUFFICIENT_BUFFER);
-          ret = 0;
+          ret = HttpDataHandler::RET_FAILURE;
         }
 
     }
@@ -444,13 +449,10 @@ BOOL WINAPI ISAPI_GetServerVariableExport (HCONN hConn,
     {
       if (Isapi::buildAllRawHeaders (ConnInfo->td,ConnInfo->connection,
                                      lpvBuffer, lpdwSize))
-        ret = 1;
-      else
         {
           SetLastError (ERROR_INSUFFICIENT_BUFFER);
-          ret = 0;
+          ret = HttpDataHandler::RET_FAILURE;
         }
-
     }
   else
     {
@@ -496,13 +498,13 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
     valLen += sprintf (&ValStr[valLen],"HTTP_ACCEPT:%s\n",
                        accept->value->c_str ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (cache && cache->value->length () && (valLen+30<maxLen))
     valLen += sprintf (&ValStr[valLen], "HTTP_CACHE_CONTROL:%s\n",
                        cache->value->c_str ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if ((td->request.rangeByteBegin || td->request.rangeByteEnd) &&
       (valLen + 30 < maxLen))
@@ -525,17 +527,16 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen], "HTTP_ACCEPT_ENCODING:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
-
   {
     HttpRequestHeader::Entry* e = td->request.other.get ("Accept-Language");
     if (e && (valLen + 30 < maxLen))
       valLen += sprintf (&ValStr[valLen],"HTTP_ACCEPT_LANGUAGE:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
 
@@ -545,7 +546,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_ACCEPT_CHARSET:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -554,7 +555,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_PRAGMA:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -563,7 +564,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_CONNECTION:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -572,7 +573,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_COOKIE:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -581,7 +582,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_HOST:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -590,7 +591,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_DATE:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -599,7 +600,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_IF_MODIFIED_SINCE:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -608,7 +609,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_REFERER:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -617,7 +618,7 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_USER_AGENT:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
   {
@@ -626,10 +627,10 @@ BOOL Isapi::buildAllHttpHeaders (HttpThreadContext* td, 
ConnectionPtr /*!a*/,
       valLen += sprintf (&ValStr[valLen],"HTTP_FROM:%s\n",
                          e->value->c_str ());
     else if (valLen + 30 < maxLen)
-      return 0;
+      return 1;
   }
 
-  return 1;
+  return 0;
 }
 
 /*!
@@ -641,71 +642,71 @@ BOOL Isapi::buildAllRawHeaders (HttpThreadContext* 
td,ConnectionPtr a,
   DWORD valLen = 0;
   DWORD maxLen = *dwMaxLen;
   char *ValStr = (char*)output;
-  if (buildAllHttpHeaders (td, a, output, dwMaxLen) == 0)
-    return 0;
+  if (buildAllHttpHeaders (td, a, output, dwMaxLen))
+    return 1;
   valLen = (DWORD)strlen (ValStr);
 
   if (td->pathInfo.length () && (valLen + 30 < maxLen))
     valLen += sprintf (&ValStr[valLen], "PATH_INFO:%s\n",
                        td->pathInfo.c_str ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->pathTranslated.length () && (valLen + 30 < maxLen))
     valLen += sprintf (&ValStr[valLen], "PATH_INFO:%s\n",
                        td->pathTranslated.c_str ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->request.uriOpts[0] && (valLen + 30 < maxLen))
     valLen += sprintf (&ValStr[valLen], "QUERY_STRING:%s\n",
                        td->request.uriOpts[0]);
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->request.cmd[0] && (valLen + 30 < maxLen))
     valLen += sprintf (&ValStr[valLen], "REQUEST_METHOD:%s\n",
                        td->request.cmd[0]);
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->filenamePath.length () && (valLen + 30 < maxLen))
     valLen += sprintf (&ValStr[valLen], "SCRIPT_FILENAME:%s\n",
                        td->filenamePath[0]);
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (valLen + 30 < maxLen)
     valLen += sprintf (&ValStr[valLen], "SERVER_PORT:%u\n",
                        td->connection->getLocalPort ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (valLen + 30 < maxLen)
     valLen += sprintf (&ValStr[valLen],
                        "SERVER_SIGNATURE:<address>%s</address>\n",
                        MYSERVER_VERSION);
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->connection->getIpAddr ()[0] && valLen + 30 < maxLen)
     valLen += sprintf (&ValStr[valLen], "REMOTE_ADDR:\n",
                        td->connection->getIpAddr ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (td->connection->getPort () && valLen + 30 < maxLen)
     valLen += sprintf (&ValStr[valLen], "REMOTE_PORT:%u\n",
                        td->connection->getPort ());
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (valLen + 30 < maxLen)
     valLen += sprintf (&ValStr[valLen], "SERVER_ADMIN:%s\n",
                        td->securityToken.getData ("server.admin", 
MYSERVER_VHOST_CONF |
                                                   MYSERVER_SERVER_CONF, ""));
   else if (valLen + 30 < maxLen)
-    return 0;
+    return 1;
 
   if (valLen + MAX_PATH < maxLen)
     {
@@ -716,8 +717,9 @@ BOOL Isapi::buildAllRawHeaders (HttpThreadContext* 
td,ConnectionPtr a,
       valLen += (DWORD)sprintf (&ValStr[valLen],"\n");
     }
   else if (valLen + 30 < maxLen)
-    return 0;
-  return 1;
+    return 1;
+
+  return 0;
 }
 
 #endif
@@ -745,17 +747,15 @@ int Isapi::send (HttpThreadContext* td,
   /*! Under windows there is MAX_PATH then we can use it. */
   char fullpath[MAX_PATH * 2 + 5];
 
-  if (!execute)
+  if (execute)
+    sprintf (fullpath, "%s", cgipath);
+  else
     {
       if (cgipath && strlen (cgipath))
         sprintf (fullpath, "%s \"%s\"", cgipath, td->filenamePath.c_str ());
       else
         sprintf (fullpath, "%s", td->filenamePath.c_str ());
     }
-  else
-    {
-      sprintf (fullpath, "%s", cgipath);
-    }
 
   if (!(td->permissions & MYSERVER_PERMISSION_EXECUTE))
     return td->http->sendAuth ();
@@ -828,6 +828,7 @@ int Isapi::send (HttpThreadContext* td,
       connTable[connIndex].chain.clearAllFilters ();
       return td->http->raiseHTTPError (500);
     }
+
   if (!GetExtensionVersion (&Ver))
     {
       td->connection->host->warningsLogWrite (_("ISAPI: internal error"));
@@ -835,6 +836,7 @@ int Isapi::send (HttpThreadContext* td,
       connTable[connIndex].chain.clearAllFilters ();
       return td->http->raiseHTTPError (500);
     }
+
   if (Ver.dwExtensionVersion > MAKELONG (HSE_VERSION_MINOR,
                                          HSE_VERSION_MAJOR))
     {
@@ -843,14 +845,11 @@ int Isapi::send (HttpThreadContext* td,
       connTable[connIndex].chain.clearAllFilters ();
       return td->http->raiseHTTPError (500);
     }
-  /*!
-   *Store the environment string in the secondaryBuffer.
-   */
+
+  /* Store the environment string in the secondaryBuffer.  */
   connTable[connIndex].envString=td->secondaryBuffer->getBuffer ();
 
-  /*!
-   *Build the environment string.
-   */
+  /* Build the environment string.  */
   td->scriptPath.assign (scriptpath);
 
   string tmp;
@@ -882,12 +881,10 @@ int Isapi::send (HttpThreadContext* td,
   ExtCtrlBlk.cbTotalBytes = td->inputData.getFileSize ();
   ExtCtrlBlk.cbAvailable = 0;
   ExtCtrlBlk.lpbData = 0;
-  {
-    HttpRequestHeader::Entry *content =
-      td->request.other.get ("Content-type");
-    ExtCtrlBlk.lpszContentType = content ? (char*)content->value->c_str ()
-      : 0;
-  }
+
+
+  HttpRequestHeader::Entry *content = td->request.other.get ("Content-type");
+  ExtCtrlBlk.lpszContentType = content ? (char*)content->value->c_str () : 
NULL;
 
   connTable[connIndex].td->buffer->setLength (0);
   connTable[connIndex].td->buffer->getAt (0)='\0';
@@ -915,13 +912,14 @@ int Isapi::send (HttpThreadContext* td,
   switch (Ret)
     {
     case HSE_STATUS_SUCCESS_AND_KEEP_CONN:
-      retvalue = 1;
+      retvalue = HttpDataHandler::RET_OK;
       break;
+
     case 0:
     case HSE_STATUS_SUCCESS:
     case HSE_STATUS_ERROR:
     default:
-      retvalue = 0;
+      retvalue = HttpDataHandler::RET_FAILURE;
       break;
     }
 
@@ -961,34 +959,35 @@ int Isapi::load ()
     return 0;
 
   isapiMutex = new Mutex;
-  maxConnections = nThreads ? nThreads : 20 ;
+  maxConnections = nThreads ? nThreads : 20;
 
   if (connTable)
     free (connTable);
 
   connTable = new ConnTableRecord[maxConnections];
-  for (int i=0;i<maxConnections; i++)
+  for (int i = 0; i < maxConnections; i++)
     {
-      connTable[i].Allocated=0;
-      connTable[i].onlyHeader=0;
-      connTable[i].headerSent=0;
-      connTable[i].headerSize=0;
-      connTable[i].td=0;
-      connTable[i].dataSent=0;
-      connTable[i].envString=0;
-      connTable[i].connection=0;
-      connTable[i].ISAPIDoneEvent=0;
-      connTable[i].isapi=0;
+      connTable[i].Allocated = 0;
+      connTable[i].onlyHeader = 0;
+      connTable[i].headerSent = 0;
+      connTable[i].headerSize = 0;
+      connTable[i].td = 0;
+      connTable[i].dataSent = 0;
+      connTable[i].envString = 0;
+      connTable[i].connection = 0;
+      connTable[i].ISAPIDoneEvent = 0;
+      connTable[i].isapi = 0;
     }
+
   InitializeCriticalSection (&GetTableEntryCritSec);
-  initialized=1;
+  initialized = 1;
 #endif
   return 0;
 }
 
 /*!
- * Cleanup the memory used by ISAPI.
- */
+  Cleanup the memory used by ISAPI.
+*/
 int Isapi::unLoad ()
 {
 #ifdef WIN32
diff --git a/myserver/src/http_handler/mscgi/mscgi.cpp 
b/myserver/src/http_handler/mscgi/mscgi.cpp
index a3d8995..d27cdde 100644
--- a/myserver/src/http_handler/mscgi/mscgi.cpp
+++ b/myserver/src/http_handler/mscgi/mscgi.cpp
@@ -32,23 +32,23 @@ using namespace std;
 DynamicLibrary MsCgi::mscgiModule;
 
 /*!
- * Entry-point for the MyServer CGI; differently from standard CGI this doesn't
- * need a new process to run making it faster.
- * \param td The HTTP thread context.
- * \param exec The script path.
- * \param cmdLine The command line.
- * \param execute Specify if the script has to be executed.
- * \param onlyHeader Specify if send only the HTTP header.
+  Entry-point for the MyServer CGI; differently from standard CGI this doesn't
+  need a new process to run making it faster.
+  \param td The HTTP thread context.
+  \param exec The script path.
+  \param cmdLine The command line.
+  \param execute Specify if the script has to be executed.
+  \param onlyHeader Specify if send only the HTTP header.
  */
 int MsCgi::send (HttpThreadContext* td, const char* exec, const char* cmdLine,
                  bool /*execute*/, bool onlyHeader)
 {
   /*
-   * This is the code for manage a .mscgi file.
-   * This files differently from standard CGI don't need a new process to run
-   * but are allocated in the caller process virtual space.
-   * Usually these files are faster than standard CGI.
-   * Actually myServerCGI (.mscgi) is only at an alpha status.
+    This is the code for manage a .mscgi file.
+    This files differently from standard CGI don't need a new process to run
+    but are allocated in the caller process virtual space.
+    Usually these files are faster than standard CGI.
+    Actually myServerCGI (.mscgi) is only at an alpha status.
    */
   ostringstream tmpStream;
   string outDataPath;
@@ -139,17 +139,17 @@ int MsCgi::send (HttpThreadContext* td, const char* exec, 
const char* cmdLine,
 
   if (!td->appendOutputs && data.useChunks && !data.error
       && chain.getStream ()->write ("0\r\n\r\n", 5, &nbw))
-    return 0;
+    return HttpDataHandler::RET_FAILURE;
 
   if (!data.error)
-    return 0;
+    return HttpDataHandler::RET_FAILURE;
 
   ostringstream tmp;
   tmp << td->sentData;
   td->response.contentLength.assign (tmp.str ());
 
   chain.clearAllFilters ();
-  return 1;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -201,8 +201,8 @@ int MsCgi::sendHeader (MsCgiData* mcd)
 }
 
 /*!
- * Map the library in the application address space.
- * \param confFile The xml parser with configuration.
+  Map the library in the application address space.
+  \param confFile The xml parser with configuration.
  */
 int MsCgi::load ()
 {
@@ -210,7 +210,7 @@ int MsCgi::load ()
 }
 
 /*!
- * Free the memory allocated by the MSCGI library.
+  Free the memory allocated by the MSCGI library.
  */
 int MsCgi::unLoad ()
 {
diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index 2276e67..846aaed 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2009 Free Software Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "stdafx.h"
@@ -32,13 +32,13 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 #include <sstream>
 
 /*
- *Forward the HTTP requesto to another server.
- *
- *\param td The HTTP thread context.
- *\param scriptpath Not used.
- *\param exec The remote server Url.
- *\param execute Not used.
- *\param onlyHeader Specify if send only the HTTP header.
+  Forward the HTTP requesto to another server.
+
+  \param td The HTTP thread context.
+  \param scriptpath Not used.
+  \param exec The remote server Url.
+  \param execute Not used.
+  \param onlyHeader Specify if send only the HTTP header.
  */
 int Proxy::send (HttpThreadContext *td,
                  const char* scriptpath,
@@ -95,7 +95,7 @@ int Proxy::send (HttpThreadContext *td,
                                *td->secondaryBuffer, td))
     {
       chain.clearAllFilters ();
-      return 1;
+      return HttpDataHandler::RET_FAILURE;
     }
 
   if (td->request.uriOptsPtr &&
@@ -143,19 +143,18 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
 
   do
     {
-      ret = client.recv (td->secondaryBuffer->getBuffer () + read,
-                         td->secondaryBuffer->getRealLength () - read,
-                         0,
-                         td->http->getTimeout ());
-
-      if (ret == 0)
+      if (client.recv (td->secondaryBuffer->getBuffer () + read,
+                       td->secondaryBuffer->getRealLength () - read,
+                       0,
+                       td->http->getTimeout () == 0))
         return td->http->raiseHTTPError (500);
 
       read += ret;
 
-      ret = HttpHeaders::buildHTTPResponseHeaderStruct 
(td->secondaryBuffer->getBuffer (),
-                                                        &td->response,
-                                                        &headerLength);
+      if (HttpHeaders::buildHTTPResponseHeaderStruct 
(td->secondaryBuffer->getBuffer (),
+                                                      &td->response,
+                                                      &headerLength))
+      ret = HttpDataHandler::RET_FAILURE;
     }
   while (ret == -1);
 
@@ -197,8 +196,7 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
     return 0;
 
   if (onlyHeader)
-    return keepalive;
-
+    ret = HttpDataHandler::RET_OK;
 
   ret = readPayLoad (td,
                      &td->response,
@@ -211,29 +209,30 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
                      keepalive,
                      hasTransferEncoding ? &transferEncoding : NULL);
 
-  if (ret != -1)
-    td->sentData += ret;
+  if (ret == -1)
+    return HttpDataHandler::RET_FAILURE;
 
-  return ret == -1 ? 0 : keepalive;
+  td->sentData += ret;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
- *Forward the message payload to the client.
- *
- *\param td The current HTTP thread context.
- *\param res Response obtained by the server.
- *\param out The client chain.
- *\param initBuffer Initial read data.
- *\param initBufferSize Size of initial data.
- *\param timeout Connection timeout.
- *\param useChunks Use chunked transfer encoding
- *with the client.
- *\param keepalive The connection is keep-alive.
- *\param serverTransferEncoding Transfer-Encoding
- *used by the server.
- *
- *\return -1 on error.
- *\return Otherwise the number of bytes transmitted.
+  Forward the message payload to the client.
+
+  \param td The current HTTP thread context.
+  \param res Response obtained by the server.
+  \param out The client chain.
+  \param initBuffer Initial read data.
+  \param initBufferSize Size of initial data.
+  \param timeout Connection timeout.
+  \param useChunks Use chunked transfer encoding
+  with the client.
+  \param keepalive The connection is keep-alive.
+  \param serverTransferEncoding Transfer-Encoding
+  used by the server.
+
+  \return -1 on error.
+  \return Otherwise the number of bytes transmitted.
  */
 int Proxy::readPayLoad (HttpThreadContext* td,
                         HttpResponseHeader* res,
@@ -252,16 +251,15 @@ int Proxy::readPayLoad (HttpThreadContext* td,
   u_long bufferDataSize = 0;
   u_long written = 0;
 
-
   /* Only the chunked transfer encoding is supported.  */
   if (serverTransferEncoding && serverTransferEncoding->compare ("chunked"))
-    return -1;
+    return HttpDataHandler::RET_FAILURE;
 
   if (res->contentLength.length ())
     {
       contentLength = atol (res->contentLength.c_str ());
       if (contentLength < 0)
-        return -1;
+        return HttpDataHandler::RET_FAILURE;
     }
 
   length = contentLength;
@@ -287,7 +285,7 @@ int Proxy::readPayLoad (HttpThreadContext* td,
                                                  timeout,
                                                  NULL,
                                                  1))
-            return -1;
+            return HttpDataHandler::RET_FAILURE;
 
           if (!nbr)
             break;
@@ -299,7 +297,7 @@ int Proxy::readPayLoad (HttpThreadContext* td,
                                                         out,
                                                         td->appendOutputs,
                                                         useChunks))
-            return -1;
+            return HttpDataHandler::RET_FAILURE;
 
           written += nbr;
         }
@@ -325,9 +323,7 @@ int Proxy::readPayLoad (HttpThreadContext* td,
                                                       len,
                                                       &nbr,
                                                       timeout))
-    {
-      return -1;
-    }
+      return HttpDataHandler::RET_FAILURE;
 
     if (contentLength == 0 && nbr == 0)
       break;
@@ -342,7 +338,7 @@ int Proxy::readPayLoad (HttpThreadContext* td,
                                                          out,
                                                          td->appendOutputs,
                                                          useChunks))
-      return -1;
+      return HttpDataHandler::RET_FAILURE;
 
     written += nbr;
 
@@ -351,7 +347,7 @@ int Proxy::readPayLoad (HttpThreadContext* td,
   }
 
   if (useChunks && out->getStream ()->write ("0\r\n\r\n", 5, &nbw))
-    return -1;
+    return HttpDataHandler::RET_FAILURE;
 
   return written;
 }
diff --git a/myserver/src/http_handler/scgi/scgi.cpp 
b/myserver/src/http_handler/scgi/scgi.cpp
index 6b85719..1923405 100644
--- a/myserver/src/http_handler/scgi/scgi.cpp
+++ b/myserver/src/http_handler/scgi/scgi.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include <include/http_handler/scgi/scgi.h>
 #include <include/protocol/http/env/env.h>
@@ -34,10 +34,9 @@ int Scgi::initialized = 0;
 /*! Process server manager.  */
 ProcessServerManager *Scgi::processServerManager = 0;
 
-
 /*!
- *Entry-Point to manage a SCGI request.
- */
+  Entry-Point to manage a SCGI request.
+*/
 int Scgi::send (HttpThreadContext* td, const char* scriptpath,
                const char *cgipath, bool execute, bool onlyHeader)
 {
@@ -90,7 +89,7 @@ int Scgi::send (HttpThreadContext* td, const char* scriptpath,
   td->secondaryBuffer->getAt (0) = '\0';
 
   {
-    /*! Do not modify the text between " and ".  */
+    /* Do not modify the text between " and ".  */
     int i;
     int subString = cgipath[0] == '"';
     int len = strlen (cgipath);
@@ -103,10 +102,10 @@ int Scgi::send (HttpThreadContext* td, const char* 
scriptpath,
         subString = !subString;
     }
     /*!
-     *Save the cgi path and the possible arguments.
-     *the (x < len) case is when additional arguments are specified.
-     *If the cgipath is enclosed between " and " do not consider them
-     *when splitting directory and file name.
+      Save the cgi path and the possible arguments.
+      the (x < len) case is when additional arguments are specified.
+      If the cgipath is enclosed between " and " do not consider them
+      when splitting directory and file name.
      */
     if (len)
     {
@@ -204,7 +203,7 @@ int Scgi::send (HttpThreadContext* td, const char* 
scriptpath,
     }
   }
 
-  ret = !sendResponse (&con, onlyHeader, &chain);
+  ret = sendResponse (&con, onlyHeader, &chain);
 
 
   chain.clearAllFilters ();
@@ -242,7 +241,7 @@ int Scgi::sendResponse (ScgiContext* ctx, int onlyHeader, 
FiltersChain* chain)
         }
 
       if (!ctx->sock.bytesToRead ())
-        return -1;
+        return HttpDataHandler::RET_FAILURE;
 
       nbr = ctx->sock.recv (td->secondaryBuffer->getBuffer () + read,
                             td->secondaryBuffer->getRealLength () - read,
@@ -273,10 +272,10 @@ int Scgi::sendResponse (ScgiContext* ctx, int onlyHeader, 
FiltersChain* chain)
 
   if (HttpHeaders::sendHeader (td->response, *td->connection->socket,
                                *td->secondaryBuffer, td))
-    return 1;
+    return HttpDataHandler::RET_FAILURE;
 
   if (onlyHeader)
-    return 0;
+    return HttpDataHandler::RET_OK;
 
   if (read - headerSize)
     if (appendDataToHTTPChannel (td, td->secondaryBuffer->getBuffer () + 
headerSize,
@@ -285,7 +284,7 @@ int Scgi::sendResponse (ScgiContext* ctx, int onlyHeader, 
FiltersChain* chain)
                                  chain,
                                  td->appendOutputs,
                                  useChunks))
-      return -1;
+      return HttpDataHandler::RET_FAILURE;
 
   sentData += read - headerSize;
 
@@ -306,7 +305,7 @@ int Scgi::sendResponse (ScgiContext* ctx, int onlyHeader, 
FiltersChain* chain)
                                        chain,
                                        td->appendOutputs,
                                        useChunks))
-            return -1;
+            return HttpDataHandler::RET_FAILURE;
 
           sentData += nbr;
         }
@@ -314,13 +313,13 @@ int Scgi::sendResponse (ScgiContext* ctx, int onlyHeader, 
FiltersChain* chain)
       if (!td->appendOutputs && useChunks)
         {
           if (chain->getStream ()->write ("0\r\n\r\n", 5, &nbw))
-            return -1;
+            return HttpDataHandler::RET_FAILURE;
         }
     }
   /* For logging activity.  */
   td->sentData += sentData;
 
-  return 0;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
diff --git a/myserver/src/http_handler/wincgi/wincgi.cpp 
b/myserver/src/http_handler/wincgi/wincgi.cpp
index ca29171..cac7388 100644
--- a/myserver/src/http_handler/wincgi/wincgi.cpp
+++ b/myserver/src/http_handler/wincgi/wincgi.cpp
@@ -1,18 +1,18 @@
 /*
-MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  MyServer
+  Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, 
Inc.
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "stdafx.h"
@@ -33,6 +33,7 @@ extern "C"
 #ifdef WIN32
 # include <direct.h>
 #endif
+
 #include <string.h>
 }
 
@@ -42,7 +43,7 @@ using namespace std;
 
 
 /*!
- * Constructor for the wincgi class.
+  Constructor for the wincgi class.
  */
 WinCgi::WinCgi ()
 {
@@ -50,7 +51,7 @@ WinCgi::WinCgi ()
 }
 
 /*!
- * Destructor for the wincgi class.
+  Destructor for the wincgi class.
  */
 WinCgi::~WinCgi ()
 {
@@ -58,7 +59,7 @@ WinCgi::~WinCgi ()
 }
 
 /*!
- * Send the WinCGI data.
+  Send the WinCGI data.
  */
 int WinCgi::send (HttpThreadContext* td, const char* scriptpath,
                   const char *cgipath, bool /*execute*/, bool onlyHeader)
@@ -67,8 +68,8 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   FiltersChain chain;
   Process proc;
   u_long nbr;
-  char  dataFilePath[MAX_PATH];/*! Use MAX_PATH under windows. */
-  char outFilePath[MAX_PATH];  /*! Use MAX_PATH under windows. */
+  char  dataFilePath[MAX_PATH];
+  char outFilePath[MAX_PATH];
   char *buffer;
   File DataFileHandle, OutFileHandle;
   StartProcInfo spi;
@@ -77,9 +78,8 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   int bias;
 
   int ret;
-  char execname[MAX_PATH];/*! Use MAX_PATH under windows. */
-  char pathname[MAX_PATH];/*! Use MAX_PATH under windows. */
-
+  char execname[MAX_PATH];
+  char pathname[MAX_PATH];
   u_long nBytesRead = 0;
   u_long headerSize = 0;
   u_long nbw = 0;
@@ -107,9 +107,10 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   if (td->mime)
     {
       u_long nbw2;
-      if (td->mime && Server::getInstance ()->getFiltersFactory ()->chain 
(&chain,
-                                                                         
td->mime->filters,
-                                                                         
td->connection->socket, &nbw2, 1))
+      if (td->mime
+          && Server::getInstance ()->getFiltersFactory ()->chain (&chain,
+                                                       td->mime->filters,
+                                        td->connection->socket, &nbw2, 1))
         {
           td->connection->host->warningsLogWrite (_("WinCGI: internal error"));
           chain.clearAllFilters ();
@@ -117,10 +118,7 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
         }
     }
 
-
-  /*!
-   *The WinCGI protocol uses a .ini file to send data to the new process.
-   */
+  /* The WinCGI protocol uses a .ini file to send data to the new process.  */
   ret = DataFileHandle.openFile (dataFilePath, File::FILE_CREATE_ALWAYS
                                  | File::WRITE);
   if (ret)
@@ -352,7 +350,7 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
           FilesUtility::deleteFile (outFilePath);
           FilesUtility::deleteFile (dataFilePath);
           chain.clearAllFilters ();
-          return 1;
+          return HttpDataHandler::RET_FAILURE;
         }
 
       if (onlyHeader)
@@ -361,12 +359,9 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
           FilesUtility::deleteFile (outFilePath);
           FilesUtility::deleteFile (dataFilePath);
           chain.clearAllFilters ();
-          return 1;
+          return HttpDataHandler::RET_OK;
         }
 
-      /*!
-       * Send other data in the buffer.
-       */
       chain.write ((char*)(buffer + headerSize), nBytesRead - headerSize,
                    &nbw2);
       nbw += nbw2;
@@ -379,7 +374,7 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
       if (onlyHeader)
         {
           chain.clearAllFilters ();
-          return 1;
+          return HttpDataHandler::RET_OK;
         }
 
       td->outputData.writeToFile ((char*)(buffer + headerSize),
@@ -407,7 +402,7 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
                       FilesUtility::deleteFile (outFilePath);
                       FilesUtility::deleteFile (dataFilePath);
                       chain.clearAllFilters ();
-                      return 0;
+                      return HttpDataHandler::RET_FAILURE;
                     }
                 }
               else
@@ -420,7 +415,7 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
                       FilesUtility::deleteFile (outFilePath);
                       FilesUtility::deleteFile (dataFilePath);
                       chain.clearAllFilters ();
-                      return 0;
+                      return HttpDataHandler::RET_FAILURE;
                     }
                 }
             }
@@ -435,12 +430,9 @@ int WinCgi::send (HttpThreadContext* td, const char* 
scriptpath,
   OutFileHandle.close ();
   FilesUtility::deleteFile (outFilePath);
   FilesUtility::deleteFile (dataFilePath);
-  return 1;
+
+  return HttpDataHandler::RET_OK;
 #else
-  /*
-   * WinCGI is available only under windows. Raise the right error
-   * when it is used under another architecture.
-   */
   td->connection->host->warningsLogWrite (_("WinCGI: not implemented"));
 
   return td->http->raiseHTTPError (501);
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index c4ac163..56cb45b 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -523,8 +523,9 @@ u_long Http::checkDigest ()
   u_long digestCount;
 
   /* Return 0 if the password is different.  */
-  if (td->request.digestOpaque[0] && strcmp (td->request.digestOpaque,
-                                             ((HttpUserData*) 
td->connection->protocolBuffer)->opaque))
+  if (td->request.digestOpaque[0]
+      && strcmp (td->request.digestOpaque,
+                 ((HttpUserData*) td->connection->protocolBuffer)->opaque))
     return 0;
 
   /*! If is not equal return 0.  */
@@ -540,7 +541,8 @@ u_long Http::checkDigest ()
 
   md5.init ();
   td->secondaryBuffer->setLength (0);
-  *td->secondaryBuffer << td->request.digestUsername << ":" << 
td->request.digestRealm
+  *td->secondaryBuffer << td->request.digestUsername << ":"
+                       << td->request.digestRealm
                        << ":" << td->securityToken.getNeededPassword ();
 
   md5.update ((char const*) td->secondaryBuffer->getBuffer (),
@@ -670,7 +672,7 @@ Http::sendHTTPResource (string& uri, int systemrequest, int 
onlyHeader,
       return raiseHTTPError (500);
     };
 
-  return ret;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -751,7 +753,7 @@ int Http::logHTTPaccess ()
     }
   catch (...)
     {
-      return 1;
+      return HttpDataHandler::RET_FAILURE;
     };
   return 0;
 }
@@ -762,8 +764,7 @@ int Http::logHTTPaccess ()
 int Http::controlConnection (ConnectionPtr a, char*, char*, u_long, u_long,
                              u_long nbtr, u_long id)
 {
-  int retvalue = -1;
-  int ret = 0;
+  int ret = -1;
   int validRequest;
 
   /* Dimension of the POST data. */
@@ -805,7 +806,7 @@ int Http::controlConnection (ConnectionPtr a, char*, char*, 
u_long, u_long,
       td->response.httpStatus = 200;
 
       /*
-       * If the connection must be removed, remove it.
+       * The connection should be removed.
        */
       if (td->connection->getToRemove ())
         {
@@ -813,11 +814,12 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
             {
               /* Remove the connection from the list.  */
             case Connection::REMOVE_OVERLOAD:
-              retvalue = raiseHTTPError (503);
+              ret = raiseHTTPError (503);
               logHTTPaccess ();
               return ClientsThread::DELETE_CONNECTION;
 
             default:
+              logHTTPaccess ();
               return ClientsThread::DELETE_CONNECTION;
             }
         }
@@ -839,7 +841,7 @@ int Http::controlConnection (ConnectionPtr a, char*, char*, 
u_long, u_long,
       /* If the validRequest cointains an error code send it to the user.  */
       if (validRequest != 200)
         {
-          retvalue = raiseHTTPError (validRequest);
+          ret = raiseHTTPError (validRequest);
           logHTTPaccess ();
           return ClientsThread::DELETE_CONNECTION;
         }
@@ -881,7 +883,6 @@ int Http::controlConnection (ConnectionPtr a, char*, char*, 
u_long, u_long,
           (!td->request.cmd.compare ("PUT")) ||
           (dynamicCommand && dynamicCommand->acceptData ()))
         {
-          int ret;
           int httpErrorCode;
 
           /* Be sure that the client can handle the 100 status code.  */
@@ -905,12 +906,7 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
             }
           else if (ret)
             {
-              int retvalue = raiseHTTPError (httpErrorCode);
-
-              logHTTPaccess ();
-
-              return retvalue ? ClientsThread::KEEP_CONNECTION
-                      : ClientsThread::DELETE_CONNECTION;
+              ret = raiseHTTPError (httpErrorCode);
             }
         }
       else
@@ -920,7 +916,7 @@ int Http::controlConnection (ConnectionPtr a, char*, char*, 
u_long, u_long,
         }
 
       /* If return value is not configured propertly.  */
-      if (retvalue == -1)
+      if (ret < 0)
         {
           /*
            * How is expressly said in the RFC2616 a client that sends an
@@ -1035,55 +1031,38 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
            *Check if there is a limit for the number of connections in the
            *virtual host A value of zero means no limit.
            */
-          {
-            const char* val = td->securityToken.getData ("MAX_CONNECTIONS",
-                                                    MYSERVER_VHOST_CONF
-                                                   | MYSERVER_SERVER_CONF,
-                                                         NULL);
-
-            if (val)
-              {
-                u_long limit = (u_long) atoi (val);
-                if (limit && (u_long) a->host->getRef () >= limit)
-                  {
-                    retvalue = raiseHTTPError (500);
-                    logHTTPaccess ();
-                    return retvalue ? ClientsThread::KEEP_CONNECTION
-                                    : ClientsThread::DELETE_CONNECTION;
-                  }
-              }
-          }
+          const char* val = td->securityToken.getData ("MAX_CONNECTIONS",
+                                                       MYSERVER_VHOST_CONF
+                                                       | MYSERVER_SERVER_CONF,
+                                                       NULL);
+          if (val)
+            {
+              u_long limit = (u_long) atoi (val);
+              if (limit && (u_long) a->host->getRef () >= limit)
+                ret = raiseHTTPError (500);
+            }
 
-          if (!td->request.isKeepAlive ())
-            retvalue = ClientsThread::DELETE_CONNECTION;
-          else
+          /* Support for HTTP pipelining.  */
+          if (contentLength == 0)
             {
-              /* Support for HTTP pipelining.  */
-              if (contentLength == 0)
-                {
-                  /*  connectionBuffer is 8 KB, so don't copy more bytes.  */
-                  u_long bufferStrLen = strlen (td->buffer->getBuffer ());
-                  u_long remainingData = 0;
+              /*  connectionBuffer is 8 KB, so don't copy more bytes.  */
+              u_long bufferStrLen = strlen (td->buffer->getBuffer ());
+              u_long remainingData = 0;
 
-                  if (bufferStrLen - td->nHeaderChars >= MYSERVER_KB (8))
-                    remainingData = MYSERVER_KB (8);
-                  else
-                    remainingData = bufferStrLen - td->nHeaderChars;
+              if (bufferStrLen - td->nHeaderChars >= MYSERVER_KB (8))
+                remainingData = MYSERVER_KB (8);
+              else
+                remainingData = bufferStrLen - td->nHeaderChars;
 
-                  if (remainingData)
-                    {
-                      const char *data = (td->buffer->getBuffer ()
-                                          + td->nHeaderChars);
-                      u_long toCopy = nbtr - td->nHeaderChars;
+              if (remainingData)
+                {
+                  const char *data = (td->buffer->getBuffer ()
+                                      + td->nHeaderChars);
+                  u_long toCopy = nbtr - td->nHeaderChars;
 
-                      a->getConnectionBuffer ()->setBuffer (data, toCopy);
-                      retvalue = ClientsThread::INCOMPLETE_REQUEST_NO_WAIT;
-                    }
-                  else
-                    retvalue = ClientsThread::KEEP_CONNECTION;
+                  a->getConnectionBuffer ()->setBuffer (data, toCopy);
+                  return ClientsThread::INCOMPLETE_REQUEST_NO_WAIT;
                 }
-              else
-                retvalue = ClientsThread::KEEP_CONNECTION;
             }
 
           /*
@@ -1106,50 +1085,41 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
                   {
                     int handlerRet = (*handlers)[i]->updateMulticast 
(getStaticData (),
                                                                       msg, td);
-                    if (handlerRet == 1)
+
+                    if (handlerRet == ClientsThread::DELETE_CONNECTION)
                       {
-                        ret = 1;
-                        retvalue = ClientsThread::DELETE_CONNECTION;
+                        ret = ClientsThread::DELETE_CONNECTION;
                         break;
                       }
-                    else if (handlerRet == 2)
+                    else if (handlerRet == ClientsThread::KEEP_CONNECTION)
                       {
-                        ret = 1;
-                        retvalue = ClientsThread::KEEP_CONNECTION;
+                        ret = ClientsThread::KEEP_CONNECTION;
                         break;
                       }
-
                   }
               }
           }
 
-          if (!ret)
+          if (ret < 0)
             {
               if (!allowMethod (td->request.cmd.c_str ()))
                 return raiseHTTPError (401);
 
-              /* GET REQUEST.  */
               if (!td->request.cmd.compare ("GET"))
                 ret = sendHTTPResource (td->request.uri);
-                /* POST REQUEST.  */
               else if (!td->request.cmd.compare ("POST"))
                 ret = sendHTTPResource (td->request.uri);
-                /* HEAD REQUEST.  */
               else if (!td->request.cmd.compare ("HEAD"))
                 {
                   td->onlyHeader = 1;
                   ret = sendHTTPResource (td->request.uri, 0, 1);
                 }
-                /* DELETE REQUEST.  */
               else if (!td->request.cmd.compare ("DELETE"))
                 ret = deleteHTTPRESOURCE (td->request.uri, 0, 1);
-                /* PUT REQUEST.  */
               else if (!td->request.cmd.compare ("PUT"))
                 ret = putHTTPRESOURCE (td->request.uri, 0, 1);
-                /* OPTIONS REQUEST.  */
               else if (!td->request.cmd.compare ("OPTIONS"))
                 ret = optionsHTTPRESOURCE (td->request.uri, 0);
-                /* TRACE REQUEST.  */
               else if (!td->request.cmd.compare ("TRACE"))
                 ret = traceHTTPRESOURCE (td->request.uri, 0);
               else
@@ -1161,13 +1131,10 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
                   if (!dynamicCommand)
                     ret = raiseHTTPError (501);
                   else
-                    retvalue = dynamicCommand->send (td, a, td->request.uri, 0,
-                                                     0, 0)
-                      ? ClientsThread::KEEP_CONNECTION
-                      : ClientsThread::DELETE_CONNECTION;
+                    ret = dynamicCommand->send (td, a, td->request.uri, 0,
+                                                0, 0);
                 }
             }
-          logHTTPaccess ();
         }
 
       /* If the inputData file was not closed close it.  */
@@ -1184,22 +1151,24 @@ int Http::controlConnection (ConnectionPtr a, char*, 
char*, u_long, u_long,
           FilesUtility::deleteFile (td->outputDataPath);
         }
 
+      bool keepalive = false;
       HttpRequestHeader::Entry *connection = td->request.other.get
                                                        ("Connection");
       if (connection)
-        ret &= !stringcmpi (connection->value->c_str (), "keep-alive");
+        keepalive = !stringcmpi (connection->value->c_str (), "keep-alive");
+
+      logHTTPaccess ();
+
+      if (ret == HttpDataHandler::RET_OK && keepalive)
+        return ClientsThread::KEEP_CONNECTION;
       else
-        ret = 0;
+        return ClientsThread::DELETE_CONNECTION;
 
-      return (ret && retvalue != ClientsThread::DELETE_CONNECTION)
-              ? retvalue
-              : ClientsThread::DELETE_CONNECTION;
     }
   catch (...)
     {
-
       td->connection->host->warningsLogWrite (_("HTTP: internal error"));
-      return raiseHTTPError (500);
+      raiseHTTPError (500);
       logHTTPaccess ();
       return ClientsThread::DELETE_CONNECTION;
     }
@@ -1252,7 +1221,7 @@ int Http::requestAuthorization ()
           if (!td->connection->protocolBuffer)
             {
               sendHTTPhardError500 ();
-              return 0;
+              return HttpDataHandler::RET_FAILURE;
             }
           ((HttpUserData*) (td->connection->protocolBuffer))->reset ();
         }
@@ -1311,9 +1280,10 @@ int Http::requestAuthorization ()
                                     td->secondaryBuffer->getLength (), 0) == 
-1)
     {
       td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
-  return 1;
+
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -1413,7 +1383,6 @@ int Http::raiseHTTPError (int ID)
             td->connection->host->warningsLogWrite (
                _("HTTP: The specified error page: %s does not exist"),
                errorFile.str ().c_str ());
-
         }
 
       HttpErrors::getErrorMessage (ID, errorMessage);
@@ -1441,22 +1410,22 @@ int Http::raiseHTTPError (int ID)
 
       if (HttpHeaders::sendHeader (td->response, *td->connection->socket,
                                    *td->buffer, td))
-        return 0;
+        return 1;
 
       if (errorBodyLength
           && (td->connection->socket->send (errorBodyMessage.str ().c_str (),
                                             errorBodyLength, 0) < 0))
         {
           td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-          return 0;
+          return HttpDataHandler::RET_FAILURE;
         }
 
-      return 1;
+      return HttpDataHandler::RET_OK;
     }
   catch (...)
     {
       td->connection->host->warningsLogWrite (_("HTTP: internal error"));
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
 }
 
@@ -1507,12 +1476,14 @@ Internal Server Error\n\
   *td->secondaryBuffer << "\r\n\r\n";
 
   if (td->connection->socket->send (td->secondaryBuffer->getBuffer (),
-                                    (u_long) td->secondaryBuffer->getLength 
(), 0) != -1)
-    {
-      if (!td->onlyHeader)
-        td->connection->socket->send (hardHTML, (u_long) strlen (hardHTML), 0);
-    }
-  return 0;
+                                    (u_long) td->secondaryBuffer->getLength (),
+                                    0) < 0)
+    return HttpDataHandler::RET_FAILURE;
+
+  if (!td->onlyHeader)
+    td->connection->socket->send (hardHTML, (u_long) strlen (hardHTML), 0);
+
+  return HttpDataHandler::RET_FAILURE;
 }
 
 /*!
@@ -1649,12 +1620,7 @@ int Http::processDefaultFile (string& uri, int 
permissions, int onlyHeader)
                 nUrl << "?" << td->request.uriOpts;
 
               /* Send a redirect to the new location.  */
-              if (sendHTTPRedirect (nUrl.str ().c_str ()))
-                ret = 1;
-              else
-                ret = 0;
-
-              return ret;
+              return sendHTTPRedirect (nUrl.str ().c_str ());
             }
         }
     }
@@ -1695,14 +1661,13 @@ int Http::sendHTTPRedirect (const char *newURL)
   *td->secondaryBuffer << time
           << "\r\n\r\n";
   if (td->connection->socket->send (td->secondaryBuffer->getBuffer (),
-                                    (int) td->secondaryBuffer->getLength (), 
0) == -1)
+                                    (int) td->secondaryBuffer->getLength (), 
0) < 0)
     {
       td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
 
-
-  return 1;
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -1728,12 +1693,13 @@ int Http::sendHTTPNonModified ()
   *td->secondaryBuffer << "Date: " << time << "\r\n\r\n";
 
   if (td->connection->socket->send (td->secondaryBuffer->getBuffer (),
-                                    (int) td->secondaryBuffer->getLength (), 
0) == -1)
+                                    (int) td->secondaryBuffer->getLength (), 
0) < 0)
     {
       td->connection->host->warningsLogWrite (_("HTTP: socket error"));
-      return 0;
+      return HttpDataHandler::RET_FAILURE;
     }
-  return 1;
+
+  return HttpDataHandler::RET_OK;
 }
 
 /*!
@@ -1742,9 +1708,7 @@ int Http::sendHTTPNonModified ()
 int Http::sendAuth ()
 {
   if (td->connection->getnTries () > 2)
-    {
-      return raiseHTTPError (401);
-    }
+    return raiseHTTPError (401);
   else
     {
       td->connection->incnTries ();

-----------------------------------------------------------------------

Summary of changes:
 myserver/include/protocol/http/http_data_handler.h |   10 +-
 myserver/src/http_handler/cgi/cgi.cpp              |   18 +-
 myserver/src/http_handler/fastcgi/fastcgi.cpp      |   93 ++++----
 myserver/src/http_handler/http_dir/http_dir.cpp    |    9 +-
 myserver/src/http_handler/http_file/http_file.cpp  |  102 +++++----
 myserver/src/http_handler/isapi/isapi.cpp          |  239 ++++++++++----------
 myserver/src/http_handler/mscgi/mscgi.cpp          |   36 ++--
 myserver/src/http_handler/proxy/proxy.cpp          |  120 +++++-----
 myserver/src/http_handler/scgi/scgi.cpp            |   59 +++---
 myserver/src/http_handler/wincgi/wincgi.cpp        |   76 +++----
 myserver/src/protocol/http/http.cpp                |  200 +++++++----------
 11 files changed, 462 insertions(+), 500 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]