myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [2909] Added possibility to register a handler on a sp


From: Giuseppe Scrivano
Subject: [myserver-commit] [2909] Added possibility to register a handler on a specific URI.
Date: Sun, 26 Oct 2008 12:01:41 +0000

Revision: 2909
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2909
Author:   gscrivano
Date:     2008-10-26 12:01:40 +0000 (Sun, 26 Oct 2008)

Log Message:
-----------
Added possibility to register a handler on a specific URI.  It misses 
documentation.

Modified Paths:
--------------
    trunk/myserver/include/conf/mime/mime_manager.h
    trunk/myserver/include/conf/vhost/vhost.h
    trunk/myserver/include/conf/vhost/vhost_manager.h
    trunk/myserver/src/conf/mime/mime_manager.cpp
    trunk/myserver/src/conf/vhost/vhost.cpp
    trunk/myserver/src/conf/vhost/vhost_manager.cpp
    trunk/myserver/src/http_handler/cgi/cgi.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/protocol/http/http.cpp

Modified: trunk/myserver/include/conf/mime/mime_manager.h
===================================================================
--- trunk/myserver/include/conf/mime/mime_manager.h     2008-10-26 10:59:22 UTC 
(rev 2908)
+++ trunk/myserver/include/conf/mime/mime_manager.h     2008-10-26 12:01:40 UTC 
(rev 2909)
@@ -79,8 +79,9 @@
        void clean ();
        int addRecord (MimeRecord *record);
 
+  static MimeRecord *readRecord (xmlNodePtr node);
+
 protected:
-  MimeRecord *readRecord (xmlNodePtr node);
        const char *getFilename ();
        void clearRecords ();
 private:

Modified: trunk/myserver/include/conf/vhost/vhost.h
===================================================================
--- trunk/myserver/include/conf/vhost/vhost.h   2008-10-26 10:59:22 UTC (rev 
2908)
+++ trunk/myserver/include/conf/vhost/vhost.h   2008-10-26 12:01:40 UTC (rev 
2909)
@@ -193,6 +193,8 @@
 
   /*! Set the protocol data. */
   void setProtocolData(VhostProtocolData* data){protocolData = data;}
+
+  MimeRecord* getLocationMime (string& loc){return locationsMime.get (loc);}
 private:
   VhostProtocolData*  protocolData;
   HashMap<string, string*> hashedData;
@@ -200,6 +202,8 @@
   Mutex refMutex;
   LogManager* logManager;
 
+  HashMap<string, MimeRecord*> locationsMime;
+
   MimeManager mimeManager;
 
   /*! The default priority for the connections scheduler.  */

Modified: trunk/myserver/include/conf/vhost/vhost_manager.h
===================================================================
--- trunk/myserver/include/conf/vhost/vhost_manager.h   2008-10-26 10:59:22 UTC 
(rev 2908)
+++ trunk/myserver/include/conf/vhost/vhost_manager.h   2008-10-26 12:01:40 UTC 
(rev 2909)
@@ -60,9 +60,6 @@
   /*! Load the virtual hosts list from a xml configuration file.  */
   int loadXMLConfigurationFile(const char *);
        
-  /*! Save the virtual hosts list to a xml configuration file.  */
-  int saveXMLConfigurationFile(const char *);
-       
   /*! Set the right owner for the log locations.  */
   void changeLocationsOwner ();
 private:

Modified: trunk/myserver/src/conf/mime/mime_manager.cpp
===================================================================
--- trunk/myserver/src/conf/mime/mime_manager.cpp       2008-10-26 10:59:22 UTC 
(rev 2908)
+++ trunk/myserver/src/conf/mime/mime_manager.cpp       2008-10-26 12:01:40 UTC 
(rev 2909)
@@ -123,10 +123,6 @@
   xmlNodePtr lcur = node->children;
   xmlAttr *attrs;
 
-  if(xmlStrcmp(node->name, (const xmlChar *)"MIME"))
-    return NULL;
-
-
   MimeRecord *rc = new MimeRecord;
 
   for (attrs = node->properties; attrs; attrs = attrs->next)
@@ -210,6 +206,9 @@
 
   for(; node; node = node->next )
   {
+    if(xmlStrcmp(node->name, (const xmlChar *)"MIME"))
+      continue;
+
     MimeRecord *rc = readRecord (node);
 
     if (rc)

Modified: trunk/myserver/src/conf/vhost/vhost.cpp
===================================================================
--- trunk/myserver/src/conf/vhost/vhost.cpp     2008-10-26 10:59:22 UTC (rev 
2908)
+++ trunk/myserver/src/conf/vhost/vhost.cpp     2008-10-26 12:01:40 UTC (rev 
2909)
@@ -67,6 +67,16 @@
   clearIPList();
   freeSSL();
   freeHashedData();
+
+  HashMap<string, MimeRecord*>::Iterator it = locationsMime.begin ();
+
+  while (it != locationsMime.end ())
+    {
+      delete *it;
+      it++;
+    }
+
+
   refMutex.destroy();
   documentRoot.assign("");
   systemRoot.assign("");

Modified: trunk/myserver/src/conf/vhost/vhost_manager.cpp
===================================================================
--- trunk/myserver/src/conf/vhost/vhost_manager.cpp     2008-10-26 10:59:22 UTC 
(rev 2908)
+++ trunk/myserver/src/conf/vhost/vhost_manager.cpp     2008-10-26 12:01:40 UTC 
(rev 2909)
@@ -16,6 +16,7 @@
 */
 #include <include/conf/vhost/vhost_manager.h>
 #include <include/conf/vhost/vhost.h>
+#include <include/conf/mime/mime_manager.h>
 #include <include/server/server.h>
 #include <include/base/file/files_utility.h>
 
@@ -427,8 +428,7 @@
           if(!xmlStrcmp(lcur->name, (const xmlChar *)"HOST"))
             {
               int useRegex = 0;
-              xmlAttr *attrs = lcur->properties;
-              while(attrs)
+              for (xmlAttr *attrs = lcur->properties; attrs; attrs = 
attrs->next)
                 {
                   if(!xmlStrcmp(attrs->name, (const xmlChar *)"isRegex"))
                     {
@@ -439,7 +439,6 @@
                           useRegex = 1;
                         }
                     }
-                  attrs = attrs->next;
                 }
 
               vh->addHost((const char*)lcur->children->content, useRegex);
@@ -448,6 +447,18 @@
             {
               vh->setName((char*)lcur->children->content);
             }
+          else if(!xmlStrcmp(lcur->name, (const xmlChar *)"LOCATION"))
+            {
+              string loc (vh->getDocumentRoot ());
+              loc.append ("/");
+              for (xmlAttr *attrs = lcur->properties; attrs; attrs = 
attrs->next)
+                {
+                  if(!xmlStrcmp (attrs->name, (const xmlChar *)"path"))
+                    loc.append ((const char*) attrs->children->content);
+                }
+              MimeRecord *rc = MimeManager::readRecord (lcur);
+              vh->locationsMime.put (loc, rc);
+            }
           else if(!xmlStrcmp(lcur->name, (const xmlChar *)"SSL_PRIVATEKEY"))
             {
               string pk((char*)lcur->children->content);
@@ -624,143 +635,6 @@
 }
 
 /*!
- *Save the virtual hosts to a XML configuration file.
- *\param filename The filename where write the XML file.
- */
-int VhostManager::saveXMLConfigurationFile(const char *filename)
-{
-  File out;
-  u_long nbw;
-
-  mutex.lock();
-
-  if(extSource)
-    {
-      int ret = extSource->save();
-      mutex.unlock();
-      return ret;
-    }
-
-  out.openFile(filename, File::MYSERVER_CREATE_ALWAYS | 
File::MYSERVER_OPEN_WRITE);
-  out.writeToFile("<?xml version=\"1.0\"?>\r\n<VHOSTS>\r\n", 33, &nbw);
-
-  try
-    {
-      list<Vhost*>::iterator i = hostList.begin();
-      for( ; i != hostList.end() ; i++)
-        {
-          char port[6];
-          list<Vhost::StringRegex*>::iterator il = (*i)->getIpList()->begin();
-          list<Vhost::StringRegex*>::iterator hl = 
(*i)->getHostList()->begin();
-          out.writeToFile("<VHOST>\r\n",9,&nbw);
-      
-          out.writeToFile("<NAME>",6,&nbw);
-          out.writeToFile((*i)->getName(), strlen((*i)->getName()), &nbw);
-          out.writeToFile("</NAME>\r\n",9,&nbw);
-       
-          for(; il != (*i)->getIpList()->end(); il++)
-            {
-              string *n = &((*il)->name);
-              out.writeToFile("<IP>",4,&nbw);
-              out.writeToFile(n->c_str(), n->length(), &nbw);
-              out.writeToFile("</IP>\r\n",7,&nbw);
-            }
-
-          for(; hl != (*i)->getHostList()->end(); hl++)
-            {
-              string *n = &((*hl)->name);
-              out.writeToFile("<HOST>",6,&nbw);
-              out.writeToFile(n->c_str(), n->length(), &nbw);
-              out.writeToFile("</HOST>\r\n",9,&nbw);
-            }
-
-          out.writeToFile("<PORT>",6,&nbw);
-          sprintf(port,"%i", (*i)->getPort());
-          out.writeToFile(port,(u_long)strlen(port),&nbw);
-          out.writeToFile("</PORT>\r\n",9,&nbw);
-
-          if((*i)->getVhostSSLContext()->getPrivateKeyFile().length())
-            {
-              string &pk = (*i)->getVhostSSLContext()->getPrivateKeyFile();
-              out.writeToFile("<SSL_PRIVATEKEY>",16,&nbw);
-              out.writeToFile(pk.c_str(), pk.length(),&nbw);
-              out.writeToFile("</SSL_PRIVATEKEY>\r\n",19,&nbw);
-            }
-      
-          if((*i)->getVhostSSLContext()->getCertificateFile().length())
-            {
-              string &certificate = 
(*i)->getVhostSSLContext()->getCertificateFile();
-              out.writeToFile("<SSL_CERTIFICATE>", 17, &nbw);
-              out.writeToFile(certificate.c_str(), 
(u_long)certificate.length(), 
-                              &nbw);
-              out.writeToFile("</SSL_CERTIFICATE>\r\n", 20, &nbw);
-            }
-
-          if((*i)->getVhostSSLContext()->getPassword().length())
-            {
-              string& pw = (*i)->getVhostSSLContext()->getPassword();
-              out.writeToFile("<SSL_PASSWORD>", 14, &nbw);
-              out.writeToFile(pw.c_str(), pw.length(), &nbw);
-              out.writeToFile("</SSL_PASSWORD>\r\n", 17, &nbw);
-            }
-
-          out.writeToFile("<PROTOCOL>", 10, &nbw);
-          out.writeToFile((*i)->getProtocolName(), 
-                          strlen((*i)->getProtocolName()), &nbw);
-
-          out.writeToFile("</PROTOCOL>\r\n", 13, &nbw);
-      
-          out.writeToFile("<DOCROOT>", 9, &nbw);
-          out.writeToFile((*i)->getDocumentRoot().c_str(), 
-                          (*i)->getDocumentRoot().length(), &nbw);
-          out.writeToFile("</DOCROOT>\r\n", 12, &nbw);
-      
-          out.writeToFile("<SYSFOLDER>", 11, &nbw);
-          out.writeToFile((*i)->getSystemRoot().c_str(), 
-                          (*i)->getSystemRoot().length(), &nbw);
-      
-          out.writeToFile("</SYSFOLDER>\r\n", 14, &nbw);
-      
-          out.writeToFile("<ACCESSLOG>", 13, &nbw);
-
-          string accessData = saveXMLlogData ("ACCESSLOG", *i);
-          string warningData = saveXMLlogData ("WARNINGLOG", *i);
-
-          out.writeToFile (accessData.c_str (), accessData.size (), &nbw);
-          
-          out.writeToFile("</ACCESSLOG>\r\n", 16, &nbw);
-      
-          out.writeToFile("<WARNINGLOG>", 12, &nbw);
-
-          out.writeToFile (warningData.c_str (), warningData.size (), &nbw);
-          
-          out.writeToFile("</WARNINGLOG>\r\n", 15, &nbw);
-      
-          {
-            HashMap<string, string*>::Iterator it = (*i)->hashedData.begin();
-            for(; it != (*i)->hashedData.end(); it++)
-              {
-                ostringstream outString;
-                outString << "<" << it.getKey() << ">" << (*it)  << "</" 
-                          << it.getKey() << ">" << endl;
-                
out.writeToFile(outString.str().c_str(),outString.str().size(),&nbw);
-              }
-            out.writeToFile("</VHOST>\r\n", 10, &nbw);
-          }
-        }
-      out.writeToFile("</VHOSTS>\r\n", 11, &nbw);
-      out.close();
-      mutex.unlock();
-    }
-  catch(...)
-    {
-      mutex.unlock();
-    };
-
-  return 0;
-}
-
-/*!
  *Get a virtual host by its position in the list.
  *Zero based list.
  *\param n The virtual host id.

Modified: trunk/myserver/src/http_handler/cgi/cgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/cgi/cgi.cpp 2008-10-26 10:59:22 UTC (rev 
2908)
+++ trunk/myserver/src/http_handler/cgi/cgi.cpp 2008-10-26 12:01:40 UTC (rev 
2909)
@@ -197,18 +197,7 @@
       return td->http->raiseHTTPError(500);
 
     }
-    
 
-     /* Check if the CGI executable exists.  */
-    if(!FilesUtility::fileExists(tmpScriptPath.c_str()))
-    {
-      td->scriptPath.assign("");
-      td->scriptFile.assign("");
-      td->scriptDir.assign("");
-      chain.clearAllFilters(); 
-      return td->http->raiseHTTPError(500);
-    }
-
     spi.arg.assign(moreArg);
     spi.arg.append(" ");
     spi.arg.append(td->scriptFile);    
@@ -437,7 +426,8 @@
     
     term = stdOutFile.pipeTerminated();
 
-    if (stdOutFile.waitForData ((cgiTimeout - ticks) / 1000, (cgiTimeout - 
ticks) % 1000) == 0)
+    if (!term && 
+        stdOutFile.waitForData ((cgiTimeout - ticks) / 1000, (cgiTimeout - 
ticks) % 1000) == 0)
     {
       ostringstream msg;
       msg << "Cgi: timeout for process " << cgiProc.getPid ();
@@ -455,8 +445,9 @@
       
     if (nBytesRead == 0 && term)
     {
-      *ret = td->http->raiseHTTPError(500);
-      return 1;
+      headerCompleted = true;
+      headerSize = 0;
+      break;
     }
 
     headerOffset += nBytesRead;

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-10-26 10:59:22 UTC 
(rev 2908)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-10-26 12:01:40 UTC 
(rev 2909)
@@ -772,9 +772,6 @@
     }
   }
 
-  if (headerSize == 0)
-    return 0;
-
   HttpHeaders::buildHTTPResponseHeaderStruct(con->td->buffer->getBuffer(),
                                              &con->td->response, 
                                              &(con->td->nBytesToRead));

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp   2008-10-26 10:59:22 UTC (rev 
2908)
+++ trunk/myserver/src/protocol/http/http.cpp   2008-10-26 12:01:40 UTC (rev 
2909)
@@ -350,13 +350,13 @@
 int Http::getFilePermissions(string& filename, string& directory, string& 
file, 
                              string &filenamePath, int yetmapped, int* 
permissions)
 {
-  td->securityToken.setServer (Server::getInstance ());
-  td->securityToken.setSysDirectory 
((string*)&(td->connection->host->getSystemRoot ()));
-
-  td->securityToken.setVhost (td->connection->host);
-
   try
   {
+    td->securityToken.setServer (Server::getInstance ());
+    td->securityToken.setSysDirectory 
((string*)&(td->connection->host->getSystemRoot ()));
+    
+    td->securityToken.setVhost (td->connection->host);
+
     FilesUtility::splitPath (filename, directory, file);
     FilesUtility::completePath (directory);
 
@@ -369,9 +369,9 @@
      *systemrequest is 1 if the file is in the system directory.
      *If filename is already mapped on the file system don't map it again.
      */
-    if(yetmapped)
+    if (yetmapped)
     {
-      filenamePath.assign(filename);
+      filenamePath.assign (filename);
     }
     else
     {
@@ -380,39 +380,39 @@
        *If the client tries to access files that aren't in the web directory
        *send a HTTP 401 error page.
        */
-      translateEscapeString(filename);
-      if((filename[0] != '\0') &&
-         (FilesUtility::getPathRecursionLevel(filename) < 1))
+      translateEscapeString (filename);
+      if ((filename[0] != '\0') &&
+          (FilesUtility::getPathRecursionLevel(filename) < 1))
       {
         return 401;
       }
 
-      ret = getPath(filenamePath, filename, 0);
+      ret = getPath (filenamePath, filename, 0);
 
-      if(ret != 200)
+      if (ret != 200)
         return ret;
     }
 
-    if(FilesUtility::isLink(td->filenamePath.c_str()))
+    if (FilesUtility::isLink (td->filenamePath.c_str()))
     {
       const char *perm = td->connection->host->getHashedData("FOLLOW_LINKS");
       if(!perm || strcmpi(perm, "YES"))
         return raiseHTTPError(401);
     }
 
-    if(FilesUtility::isDirectory(filenamePath.c_str()))
+    if (FilesUtility::isDirectory (filenamePath.c_str()))
     {
       directory.assign(filenamePath);
     }
     else
     {
-      FilesUtility::splitPath(filenamePath, directory, file);
+      FilesUtility::splitPath (filenamePath, directory, file);
     }
 
-    if(td->connection->protocolBuffer == 0)
+    if (td->connection->protocolBuffer == 0)
     {
       td->connection->protocolBuffer = new HttpUserData;
-      if(!td->connection->protocolBuffer)
+      if (!td->connection->protocolBuffer)
       {
         return 500;
       }
@@ -535,7 +535,7 @@
     if (ret != 200)
       return ret;
 
-    /*!
+    /*
      *Get the PATH_INFO value.
      *Use dirscan as a buffer for put temporary directory scan.
      *When an '/' character is present check if the path up to '/' character
@@ -546,9 +546,11 @@
     filenamePathLen = (int)td->filenamePath.length();
     dirscan.assign("");
 
-    for(u_long i = 0; i < filenamePathLen ; )
+    MimeRecord* mimeLoc = NULL;
+
+    for(u_long i = 0;; )
     {
-      /*!
+      /*
        *http://host/path/to/file/file.txt/PATH_INFO_VALUE?QUERY_INFO_VALUE
        *When a request has this form send the file file.txt with the
        *environment string PATH_INFO equals to PATH_INFO_VALUE and QUERY_INFO
@@ -559,12 +561,30 @@
 
       u_long next = td->filenamePath.find ('/', i + 1);
 
-      if (next == string::npos)
+      string curr = td->filenamePath.substr (0, next);
+
+      mimeLoc = td->connection->host ? td->connection->host->getLocationMime 
(curr) : NULL;
+
+      if(mimeLoc)
+      {
+        if (next != string::npos)
+        {
+          td->pathInfo.assign (&(td->filenamePath.c_str ()[next]));
+          td->filenamePath.erase (next);
+        }
+        else
+        {
+          td->pathInfo.assign ("");
+        }
+
         break;
+      }
 
-      const char *curr = td->filenamePath.substr (0, next).c_str ();
+      if (next >= filenamePathLen)
+        break;
 
-      if(!FilesUtility::isDirectory (curr))
+      if(mimeLoc ||
+         !FilesUtility::isDirectory (curr.c_str ()))
       {
         td->pathInfo.assign (&(td->filenamePath.c_str ()[next]));
         td->filenamePath.erase (next);
@@ -574,29 +594,27 @@
       i = next;
     }
 
-    /*!
-     *If there is a PATH_INFO value the get the PATH_TRANSLATED too.
+    /*
      *PATH_TRANSLATED is the local filesystem mapped version of PATH_INFO.
      */
-    if(td->pathInfo.length() > 1)
+    if(td->pathInfo.length () > 1)
     {
       int ret;
-      /*!
-       *Start from the second character because the first is a
-       *slash character.
-       */
-      ret = getPath(td->pathTranslated, &((td->pathInfo.c_str())[1]), 0);
+      /* Omit the first slash character.  */
+      ret = getPath (td->pathTranslated, &((td->pathInfo.c_str())[1]), 0);
 
-      if(ret != 200)
-        td->pathTranslated.assign("");
+      if (ret != 200)
+        td->pathTranslated.assign ("");
       else
-        FilesUtility::completePath(td->pathTranslated);
+        FilesUtility::completePath (td->pathTranslated);
     }
     else
     {
-      td->pathTranslated.assign("");
+      td->pathTranslated.assign ("");
     }
-    FilesUtility::completePath(td->filenamePath);
+    FilesUtility::completePath (td->filenamePath);
+
+    td->mime = mimeLoc ? mimeLoc : getMIME (td->filenamePath);
   }
   catch(...)
   {
@@ -792,7 +810,7 @@
      *2)We send the directory content.
      *3)We send an error.
      */
-    if(FilesUtility::isDirectory(td->filenamePath.c_str()))
+    if(!td->mime && FilesUtility::isDirectory(td->filenamePath.c_str()))
     {
       int i;
       if(!(permissions & MYSERVER_PERMISSION_BROWSE))
@@ -851,41 +869,24 @@
                            onlyHeader);
     }
 
-    if(!FilesUtility::fileExists(td->filenamePath.c_str()))
-    {
-      if(systemrequest)
-      {
-        string error;
-        error.assign("Http: cannot find system request file ");
-        error.append(td->filenamePath);
+    data.assign("");
 
-        td->connection->host->warningsLogWrite(error.c_str());
-      }
+    td->response.contentType[0] = '\0';
 
-      return raiseHTTPError(404);
+    /* If not specified differently, set the default content type to 
text/html.  */
+    if(td->mime)
+    {
+      td->response.contentType.assign(td->mime->mimeType);
+      data.assign(td->mime->cgiManager);
     }
-
-    /*!
-     *getMIME returns the type of command registered by the extension.
-     */
-    data.assign("");
+    else
     {
-      td->response.contentType[0] = '\0';
-      td->mime = getMIME(td->filenamePath);
-      /*! Set the default content type, this can be changed later. */
-      if(td->mime)
-      {
-        td->response.contentType.assign(td->mime->mimeType);
-        data.assign(td->mime->cgiManager);
-      }
-      else
-      {
-        td->response.contentType.assign("text/html");
-        data.assign("");
-      }
+      td->response.contentType.assign("text/html");
+      data.assign("");
     }
 
-    if(!td->mime->cmdName.compare ("RUNCGI"))
+
+    if(td->mime && !td->mime->cmdName.compare ("RUNCGI"))
     {
       int allowCgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_CGI");
@@ -905,7 +906,7 @@
                       data.c_str(), 0,  onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("EXECUTE"))
+    else if(td->mime && !td->mime->cmdName.compare ("EXECUTE"))
     {
       int allowCgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_CGI");
@@ -925,7 +926,7 @@
                       data.c_str(), 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("RUNISAPI"))
+    else if(td->mime && !td->mime->cmdName.compare ("RUNISAPI"))
     {
       int allowIsapi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_ISAPI");
@@ -945,7 +946,7 @@
       return ret;
 
     }
-    else if(!td->mime->cmdName.compare ("EXECUTEISAPI"))
+    else if(td->mime && !td->mime->cmdName.compare ("EXECUTEISAPI"))
     {
       if(!(permissions & MYSERVER_PERMISSION_EXECUTE))
       {
@@ -955,7 +956,7 @@
                         data.c_str(), 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("RUNMSGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("RUNMSGI"))
     {
       char* target;
       int allowMscgi = 1;
@@ -981,7 +982,7 @@
                         target, 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("EXECUTEWINCGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("EXECUTEWINCGI"))
     {
       ostringstream cgipath;
       int allowWincgi = 1;
@@ -1010,7 +1011,7 @@
                          0, 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("RUNFASTCGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("RUNFASTCGI"))
     {
       int allowFastcgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_FASTCGI");
@@ -1029,7 +1030,7 @@
                           data.c_str(), 0, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("EXECUTEFASTCGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("EXECUTEFASTCGI"))
     {
       int allowFastcgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_FASTCGI");
@@ -1048,7 +1049,7 @@
                           data.c_str(), 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("RUNSCGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("RUNSCGI"))
     {
       int allowScgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_SCGI");
@@ -1067,7 +1068,7 @@
                        data.c_str(), 0, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("EXECUTESCGI"))
+    else if(td->mime && !td->mime->cmdName.compare ("EXECUTESCGI"))
     {
       int allowScgi = 1;
       const char *dataH = td->connection->host->getHashedData("ALLOW_SCGI");
@@ -1086,7 +1087,7 @@
                        data.c_str(), 1, onlyHeader);
       return ret;
     }
-    else if(!td->mime->cmdName.compare ("SENDLINK"))
+    else if(td->mime && !td->mime->cmdName.compare ("SENDLINK"))
     {
       u_long nbr;
       char* linkpath;
@@ -1162,7 +1163,7 @@
       delete [] pathInfo;
       return ret;
     }
-    else if ((manager = 
staticHttp.dynManagerList.getPlugin(td->mime->cmdName)))
+    else if (td->mime && (manager = 
staticHttp.dynManagerList.getPlugin(td->mime->cmdName)))
     {
       int allowExternal = 1;
       const char *dataH =
@@ -1203,7 +1204,6 @@
       }
     }
 
-    /*! By default try to send the file as it is.  */
     if(!(permissions & MYSERVER_PERMISSION_READ))
     {
       return sendAuth();
@@ -2141,7 +2141,7 @@
 int Http::getPath(HttpThreadContext* td, string& filenamePath, const char 
*filename,
                   int systemrequest)
 {
-  /*!
+  /*
    *If it is a system request, search the file in the system directory.
    */
   if(systemrequest)
@@ -2156,7 +2156,7 @@
       filenamePath.append("/");
     filenamePath.append(filename);
   }
-  /*!
+  /*
    *Else the file is in the web directory.
    */
   else
@@ -2164,7 +2164,7 @@
     if(filename[0])
     {
       const char *root;
-      /*!
+      /*
        *uri starting with a /sys/ will use the system directory as
        *the root path. Be sure to don't allow access to the system root
        *but only to subdirectories.
@@ -2173,7 +2173,7 @@
          && filename[3] == 's' && filename[4] == '/')
       {
         root = td->getVhostSys();
-        /*!
+        /*
          *Do not allow access to the system directory root but only
          *to subdirectories.
          */
@@ -2188,8 +2188,10 @@
         root = td->getVhostDir();
       }
       filenamePath.assign(root);
+
       if(filename[0] != '/')
         filenamePath.append("/");
+
       filenamePath.append(filename);
     }
     else






reply via email to

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