myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [3069] Default filenames for HTTP are stored using a D


From: Giuseppe Scrivano
Subject: [myserver-commit] [3069] Default filenames for HTTP are stored using a DEFINE list.
Date: Sun, 03 May 2009 11:42:13 +0000

Revision: 3069
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3069
Author:   gscrivano
Date:     2009-05-03 11:42:12 +0000 (Sun, 03 May 2009)
Log Message:
-----------
Default filenames for HTTP are stored using a DEFINE list.

Modified Paths:
--------------
    trunk/myserver/binaries/myserver.default.windows.xml
    trunk/myserver/binaries/myserver.default.xml
    trunk/myserver/documentation/directory_listing.texi
    trunk/myserver/include/protocol/http/http.h
    trunk/myserver/include/server/server.h
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/server/server.cpp

Modified: trunk/myserver/binaries/myserver.default.windows.xml
===================================================================
--- trunk/myserver/binaries/myserver.default.windows.xml        2009-05-03 
10:55:49 UTC (rev 3068)
+++ trunk/myserver/binaries/myserver.default.windows.xml        2009-05-03 
11:42:12 UTC (rev 3069)
@@ -25,12 +25,12 @@
        <!--DEFAULT FILENAME TO SEND IN A DIRECTORY
                        IF THE FILE ISN'T IN THE PATH THEN THE DIRECTORY
                        CONTENT IS SENT -->
-       <DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>default.php</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.php</DEFAULT_FILENAME>
+  <DEFINE name="http.default_file">
+    <DEFINE value="default.html"/>
+    <DEFINE value="default.htm"/>
+    <DEFINE value="index.html"/>
+    <DEFINE value="index.htm"/>
+  </DEFINE>
 
        <!--TIMEOUT OF EVERY CLIENTS CONNECTED TO THE SERVER.
                        IF THE CLIENT DOESN'T REQUEST ANYTHING FOR N

Modified: trunk/myserver/binaries/myserver.default.xml
===================================================================
--- trunk/myserver/binaries/myserver.default.xml        2009-05-03 10:55:49 UTC 
(rev 3068)
+++ trunk/myserver/binaries/myserver.default.xml        2009-05-03 11:42:12 UTC 
(rev 3069)
@@ -25,12 +25,12 @@
        <!--DEFAULT FILENAME TO SEND IN A DIRECTORY
                        IF THE FILE ISN'T IN THE PATH THEN THE DIRECTORY
                        CONTENT IS SENT -->
-       <DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>default.php</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-       <DEFAULT_FILENAME>index.php</DEFAULT_FILENAME>
+  <DEFINE name="http.default_file">
+    <DEFINE value="default.html"/>
+    <DEFINE value="default.htm"/>
+    <DEFINE value="index.html"/>
+    <DEFINE value="index.htm"/>
+  </DEFINE>
 
        <!--TIMEOUT OF EVERY CLIENTS CONNECTED TO THE SERVER.
                        IF THE CLIENT DOESN'T REQUEST ANYTHING FOR N

Modified: trunk/myserver/documentation/directory_listing.texi
===================================================================
--- trunk/myserver/documentation/directory_listing.texi 2009-05-03 10:55:49 UTC 
(rev 3068)
+++ trunk/myserver/documentation/directory_listing.texi 2009-05-03 11:42:12 UTC 
(rev 3069)
@@ -9,16 +9,19 @@
 In the @file{myserver.xml} file it is possible to set the default file
 to send instead of the directory content.
 
-Default files are defined using the @code{DEFAULT_FILENAME} element
-and they are checked in the specified order until one is found.
+Default files are defined using a list called @code{http.default_file}
+element and they are checked in the specified order until one is
+found.
 If a default file can't be found in the directory then its content is
 listed.
 
 @example
-<DEFAULT_FILENAME>default.htm</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>index.htm</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>default.html</DEFAULT_FILENAME>
-<DEFAULT_FILENAME>index.html</DEFAULT_FILENAME>
+<DEFINE name="http.default_file">
+        <DEFINE value="default.html"/>
+        <DEFINE value="default.htm"/>
+        <DEFINE value="index.html"/>
+        <DEFINE value="index.htm"/>
+</DEFINE>
 @end example
 
 The previous lines define the order of files that are checked by the

Modified: trunk/myserver/include/protocol/http/http.h
===================================================================
--- trunk/myserver/include/protocol/http/http.h 2009-05-03 10:55:49 UTC (rev 
3068)
+++ trunk/myserver/include/protocol/http/http.h 2009-05-03 11:42:12 UTC (rev 
3069)
@@ -57,7 +57,6 @@
     clearMulticastRegistry();
   }
 
-  vector<string> defaultFilename;
   int cgiTimeout;
   int allowVhostMime;
 
@@ -111,7 +110,6 @@
 {
 public:
   int requestAuthorization();
-  const char *getDefaultFilenamePath(u_long ID);
 
   int sendHTTPResource(string& filename,
                        int systemrequest = 0, 

Modified: trunk/myserver/include/server/server.h
===================================================================
--- trunk/myserver/include/server/server.h      2009-05-03 10:55:49 UTC (rev 
3068)
+++ trunk/myserver/include/server/server.h      2009-05-03 11:42:12 UTC (rev 
3069)
@@ -118,7 +118,12 @@
   const char *getAddresses();
   const char *getPath();
   u_long getNumThreads();
-  const char *getDefaultFilenamePath(u_long ID = 0);
+
+  NodeTree<string>* getNodeTree (string& key)
+  {
+    return hashedData.get (key);
+  }
+
   const char *getServerName();
   u_long getVerbosity();
   int getMaxLogFileSize();

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp   2009-05-03 10:55:49 UTC (rev 
3068)
+++ trunk/myserver/src/protocol/http/http.cpp   2009-05-03 11:42:12 UTC (rev 
3069)
@@ -1707,48 +1707,53 @@
 {
   int i;
   int ret;
+  string key ("http.default_file");
+  NodeTree<string> *node = Server::getInstance()->getNodeTree (key);
 
-  for(i = 0;; i++)
+  if (node)
     {
-      const char *defaultFileNamePath = getDefaultFilenamePath(i);
-      ostringstream defaultFileName;
-      defaultFileName.clear();
-      if(defaultFileNamePath)
+      list<NodeTree<string>*> *children = node->getChildren ();
+
+      for(list<NodeTree<string>*>::iterator it = children->begin ();
+          it != children->end ();
+          it++)
         {
-          defaultFileName << td->filenamePath << "/" << defaultFileNamePath;
-        }
-      else
-          break;
-      
-      if(FilesUtility::fileExists(defaultFileName.str().c_str()))
-        {
-          ostringstream nUrl;
-          
-          if(td->request.uriEndsWithSlash)
-              nUrl << defaultFileNamePath;
-          else
+          ostringstream defaultFileName;
+          const string *file = (*it)->getValue ();
+          defaultFileName.clear();
+          defaultFileName << td->filenamePath << "/" << *file;
+
+          if(FilesUtility::fileExists (defaultFileName.str ().c_str ()))
             {
-              u_long lastSlashOffset = uri.length();
-              while(lastSlashOffset && uri[lastSlashOffset] != '/')
-                --lastSlashOffset;
-              
-              nUrl << &(uri.c_str()[lastSlashOffset < uri.length() ?
-                                    lastSlashOffset + 1 : 0])
-                   << "/" << defaultFileNamePath;
-            }
-          
-          if(td->pathInfo.length())
-            nUrl << "/" << td->pathInfo;
+              ostringstream nUrl;
 
-          if(td->request.uriOpts.length())
-            nUrl << "?" << td->request.uriOpts;
+              if (td->request.uriEndsWithSlash)
+                nUrl << *file;
+              else
+                {
+                  u_long lastSlashOffset = uri.length();
+                  while (lastSlashOffset && uri[lastSlashOffset] != '/')
+                    --lastSlashOffset;
 
-          /*! Send a redirect to the new location.  */
-          if(sendHTTPRedirect(nUrl.str().c_str()))
-            ret = 1;
-          else
-            ret = 0;
-          return ret;
+                  nUrl << &(uri.c_str ()[lastSlashOffset < uri.length() ?
+                                         lastSlashOffset + 1 : 0])
+                       << "/" << *file;
+                }
+
+              if (td->pathInfo.length())
+                nUrl << "/" << td->pathInfo;
+
+              if (td->request.uriOpts.length())
+                nUrl << "?" << td->request.uriOpts;
+
+              /*! Send a redirect to the new location.  */
+              if (sendHTTPRedirect(nUrl.str().c_str()))
+                ret = 1;
+              else
+                ret = 0;
+
+              return ret;
+            }
         }
     }
 
@@ -1843,7 +1848,6 @@
 int Http::loadProtocolStatic(XmlParser* languageParser)
 {
   char *data = 0;
-  int  nDefaultFilename = 0;
   XmlParser *configurationFileManager = 
Server::getInstance()->getConfiguration();
   string pluginsResource(Server::getInstance()->getExternalPath());
   xmlDocPtr xmlDoc = configurationFileManager->getDoc();
@@ -1903,36 +1907,6 @@
   WinCgi::setTimeout(staticHttp.cgiTimeout);
   Isapi::setTimeout(staticHttp.cgiTimeout);
 
-  nDefaultFilename = 0;
-  staticHttp.defaultFilename.clear();
-
-
-  for(xmlNode *node = xmlDoc->children; node; node = node->next)
-  {
-
-    if(!xmlStrcmp(node->name, (const xmlChar *)"MYSERVER"))
-    {
-      for(node = node->children; node; node = node->next)
-      {
-        if(!xmlStrncmp(node->name, (const xmlChar *)"DEFAULT_FILENAME", 
xmlStrlen((const xmlChar *)"DEFAULT_FILENAME")))
-        {
-          staticHttp.defaultFilename.push_back((char*)node->children->content);
-          nDefaultFilename++;
-        }
-      }
-      break;
-    }
-  }
-
-  /*!
-   *Copy the right values in the buffer.
-   */
-  if(nDefaultFilename == 0)
-  {
-    staticHttp.defaultFilename.push_back("default.html");
-    nDefaultFilename++;
-  }
-
   return 1;
 }
 
@@ -1960,25 +1934,12 @@
 
   HttpDir::unLoad();
 
-  staticHttp.defaultFilename.clear();
-
   staticHttp.clear();
 
   return 1;
 }
 
 /*!
- *Returns the default filename.
- */
-const char *Http::getDefaultFilenamePath (u_long ID)
-{
-  if(staticHttp.defaultFilename.size() <= ID)
-    return 0;
-
-  return staticHttp.defaultFilename[ID].c_str();
-}
-
-/*!
  *Returns the name of the protocol. If an out buffer
  *is defined fullfill it with the name too.
  */

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp        2009-05-03 10:55:49 UTC (rev 
3068)
+++ trunk/myserver/src/server/server.cpp        2009-05-03 11:42:12 UTC (rev 
3069)
@@ -187,7 +187,6 @@
   return 0;
 }
 
-
 /*!
  *Copy a configuration file from the default one.
  *Return nonzero on errors.





reply via email to

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