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-389-g2


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9-389-g2097cd7
Date: Mon, 09 Nov 2009 00:20:17 +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  2097cd7f32fbc307be958b8e3b154200fdbf230c (commit)
       via  9f1188cfd7c8eb17c4f3a62410ea1473b1344b73 (commit)
      from  3219a6e85467821e68315666a67b987abe6af7cc (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 2097cd7f32fbc307be958b8e3b154200fdbf230c
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Nov 9 01:01:29 2009 +0100

    Handle correctly HTTP headers facilities return values in the Proxy handler.

diff --git a/myserver/documentation/security.texi 
b/myserver/documentation/security.texi
index 3280c7a..4246dc9 100644
--- a/myserver/documentation/security.texi
+++ b/myserver/documentation/security.texi
@@ -103,7 +103,7 @@ It is computed by the function: MD5 
(username:realm:password).
 @end example
 
 The realm value used by MyServer is the virtual host name, including
-the port number, i.e. @example{localhost:8080}.
+the port number, i.e. @code{localhost:8080}.
 The A1 password can be computed using the following shell command, be
 sure to use the right user, realm and password values.
 
diff --git a/myserver/documentation/virtual_hosts.texi 
b/myserver/documentation/virtual_hosts.texi
index 5637bf0..33c8351 100644
--- a/myserver/documentation/virtual_hosts.texi
+++ b/myserver/documentation/virtual_hosts.texi
@@ -97,7 +97,7 @@ The following line, for example, set the maximum transfer 
rate to 1
 KByte/second:
 
 @example
-    <DEFINE name="connection.throttling" value="1024"/>
+<DEFINE name="connection.throttling" value="1024"/>
 @end example
 
 @subsection Connections data pool
@@ -117,8 +117,8 @@ Any other element passed after the location will be part of 
the
 @code{PATH_INFO} variable.
 
 @example
-    <LOCATION path="foo/bar" mime="text/html" handler="CGI"
-              param="/usr/local/bin/handler" />
+<LOCATION path="foo/bar" mime="text/html" handler="CGI"
+          param="/usr/local/bin/handler" />
 @end example
 
 In the previous example, the CGI process @file{/usr/local/bin/handler}
diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index bb4cc54..9166e5b 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -52,18 +52,19 @@ int Proxy::send (HttpThreadContext *td,
   HttpRequestHeader req;
   u_long nbw;
 
-  for (HashMap<string, HttpRequestHeader::Entry*>::Iterator it = 
td->request.begin ();
-       it != td->request.end ();
-       it++)
+  for (HashMap<string, HttpRequestHeader::Entry*>::Iterator it =
+         td->request.begin (); it != td->request.end (); it++)
     {
       HttpRequestHeader::Entry *e = *it;
       req.setValue (e->name->c_str (), e->value->c_str ());
     }
 
-  if (destUrl.getProtocol ().compare ("http") && destUrl.getProtocol 
().compare ("HTTP"))
+  if (destUrl.getProtocol ().compare ("http")
+      && destUrl.getProtocol ().compare ("HTTP"))
     {
-      td->connection->host->warningsLogWrite ("Proxy: %s is not a known 
protocol",
-                                              destUrl.getProtocol ().c_str ());
+      td->connection->host->warningsLogWrite
+        ("Proxy: %s is not a supported protocol",
+         destUrl.getProtocol ().c_str ());
       return td->http->raiseHTTPError (500);
     }
 
@@ -91,8 +92,12 @@ int Proxy::send (HttpThreadContext *td,
   if (sock.connect (destUrl.getHost ().c_str (), destUrl.getPort ()))
     return td->http->raiseHTTPError (500);
 
-  if (HttpHeaders::sendHeader (td->response, *td->connection->socket,
-                               *td->auxiliaryBuffer, td))
+  u_long hdrLen =
+    HttpHeaders::buildHTTPRequestHeader (td->auxiliaryBuffer->getBuffer (),
+                                         &req);
+
+
+  if (sock.write (td->auxiliaryBuffer->getBuffer (), hdrLen, &nbw))
     {
       chain.clearAllFilters ();
       return HttpDataHandler::RET_FAILURE;
@@ -107,11 +112,12 @@ int Proxy::send (HttpThreadContext *td,
 
   chain.setStream (td->connection->socket);
 
-  if (td->mime && Server::getInstance ()->getFiltersFactory ()->chain (&chain,
-                                                            td->mime->filters,
-                                                       td->connection->socket,
-                                                                       &nbw,
-                                                                       1))
+  if (td->mime
+      && Server::getInstance ()->getFiltersFactory ()->chain (&chain,
+                                                              
td->mime->filters,
+                                                         
td->connection->socket,
+                                                              &nbw,
+                                                              1))
     {
       sock.close ();
       return td->http->raiseHTTPError (500);
@@ -144,17 +150,16 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
       if (client.recv (td->auxiliaryBuffer->getBuffer () + read,
                        td->auxiliaryBuffer->getRealLength () - read,
                        0,
-                       td->http->getTimeout () == 0))
+                       td->http->getTimeout ()) < 0)
         return td->http->raiseHTTPError (500);
 
       read += ret;
 
-      if (HttpHeaders::buildHTTPResponseHeaderStruct 
(td->auxiliaryBuffer->getBuffer (),
-                                                      &td->response,
-                                                      &headerLength))
-      ret = HttpDataHandler::RET_FAILURE;
+      if (HttpHeaders::buildHTTPResponseHeaderStruct
+          (td->auxiliaryBuffer->getBuffer (), &td->response, &headerLength))
+        break;
     }
-  while (ret == -1);
+  while (ret);
 
   checkDataChunks (td, &keepalive, &useChunks);
 
@@ -180,7 +185,6 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
       transferEncoding.assign (*tmp);
     }
 
-
   if (useChunks)
     td->response.setValue ("Transfer-Encoding", "chunked");
 
@@ -191,10 +195,10 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
   if (out.getStream ()->write (td->buffer->getBuffer (),
                                hdrLen,
                                &nbw))
-    return 0;
+    return HttpDataHandler::RET_FAILURE;
 
   if (onlyHeader)
-    ret = HttpDataHandler::RET_OK;
+    return HttpDataHandler::RET_OK;
 
   ret = readPayLoad (td,
                      &td->response,
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 0348e6f..b0df006 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -519,7 +519,8 @@ int Http::preprocessHttpRequest (string& filename, int 
yetmapped, int* permissio
           if (next >= filenamePathLen)
             break;
 
-          if (mimeLoc || !FilesUtility::isDirectory (curr.c_str ()))
+          if (mimeLoc || (FilesUtility::fileExists (curr.c_str ())
+                          && !FilesUtility::isDirectory (curr.c_str ())))
             {
               td->pathInfo.assign (&(td->filenamePath.c_str ()[next]));
               td->filenamePath.erase (next);



commit 9f1188cfd7c8eb17c4f3a62410ea1473b1344b73
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Nov 9 00:08:50 2009 +0100

    Remove a not used variable plus re-indentation.

diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index ee56185..7bc4be4 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -41,20 +41,15 @@ extern "C"
 /*!
   Main function to handle the HTTP PUT command.
  */
-int HttpFile::putFile (HttpThreadContext* td,
-                       string& filename)
+int HttpFile::putFile (HttpThreadContext* td, string& filename)
 {
   u_long firstByte = td->request.rangeByteBegin;
-  int keepalive = 0;
   int ret;
 
   try
   {
     if (td->request.isKeepAlive ())
-      {
-        td->response.setValue ("Connection", "keep-alive");
-        keepalive = 1;
-      }
+      td->response.setValue ("Connection", "keep-alive");
 
     if (!(td->permissions & MYSERVER_PERMISSION_WRITE))
       return td->http->sendAuth ();
@@ -62,8 +57,8 @@ int HttpFile::putFile (HttpThreadContext* td,
     if (FilesUtility::fileExists (td->filenamePath.c_str ()))
       {
         File file;
-        if (file.openFile (td->filenamePath.c_str (), File::OPEN_IF_EXISTS |
-                           File::WRITE))
+        if (file.openFile (td->filenamePath.c_str (), File::OPEN_IF_EXISTS
+                           | File::WRITE))
           return td->http->raiseHTTPError (500);
 
         file.seek (firstByte);
@@ -105,8 +100,8 @@ int HttpFile::putFile (HttpThreadContext* td,
         /* The file doesn't exist.  */
         File file;
         if (file.openFile (td->filenamePath.c_str (),
-                         File::FILE_CREATE_ALWAYS |
-                         File::WRITE))
+                           File::FILE_CREATE_ALWAYS
+                           | File::WRITE))
           return td->http->raiseHTTPError (500);
 
         for (;;)
@@ -190,7 +185,6 @@ void HttpFile::generateEtag (string & etag, u_long mtime, 
u_long fsize)
 #define ROL(x, y) ((x << y) | (x >> (32 - y)))
   /* Do a bit rotation to have less significative bits in the middle.  */
   u_long x = ROL (mtime, 16) | fsize;
-
   char buf[16];
   sprintf (buf, "%u", x);
   etag.assign (buf);
@@ -230,38 +224,38 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
   u_long dataSent = 0;
 
   try
-  {
+    {
 
-    if (!td->request.cmd.compare ("PUT"))
-      return putFile (td, td->filenamePath);
+      if (!td->request.cmd.compare ("PUT"))
+        return putFile (td, td->filenamePath);
 
-    if (!td->request.cmd.compare ("DELETE"))
-      return deleteFile (td, td->filenamePath);
+      if (!td->request.cmd.compare ("DELETE"))
+        return deleteFile (td, td->filenamePath);
 
-    if (!(td->permissions & MYSERVER_PERMISSION_READ))
-      return td->http->sendAuth ();
+      if (!(td->permissions & MYSERVER_PERMISSION_READ))
+        return td->http->sendAuth ();
 
-    if (!FilesUtility::fileExists (filenamePath))
-      return td->http->raiseHTTPError (404);
+      if (!FilesUtility::fileExists (filenamePath))
+        return td->http->raiseHTTPError (404);
 
-    lastMT = FilesUtility::getLastModTime (td->filenamePath.c_str ());
+      lastMT = FilesUtility::getLastModTime (td->filenamePath.c_str ());
 
-    if (lastMT == -1)
-      return td->http->raiseHTTPError (500);
+      if (lastMT == -1)
+        return td->http->raiseHTTPError (500);
 
-    getRFC822GMTTime (lastMT, tmpTime, 32);
-    td->response.setValue ("Last-Modified", tmpTime.c_str ());
+      getRFC822GMTTime (lastMT, tmpTime, 32);
+      td->response.setValue ("Last-Modified", tmpTime.c_str ());
 
-    HttpRequestHeader::Entry *ifModifiedSince =
-      td->request.other.get ("Last-Modified");
+      HttpRequestHeader::Entry *ifModifiedSince =
+        td->request.other.get ("Last-Modified");
 
-    if (ifModifiedSince && ifModifiedSince->value->length () &&
-        !ifModifiedSince->value->compare (tmpTime))
-      return td->http->sendHTTPNonModified ();
+      if (ifModifiedSince && ifModifiedSince->value->length () &&
+          !ifModifiedSince->value->compare (tmpTime))
+        return td->http->sendHTTPNonModified ();
 
-    file = Server::getInstance ()->getCachedFiles ()->open (filenamePath);
-    if (!file)
-      return td->http->raiseHTTPError (500);
+      file = Server::getInstance ()->getCachedFiles ()->open (filenamePath);
+      if (!file)
+        return td->http->raiseHTTPError (500);
 
     /*
      * Check how many bytes are ready to be send.
@@ -276,16 +270,16 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       return td->http->sendHTTPNonModified ();
     else
       {
-      HttpResponseHeader::Entry *e = td->response.other.get ("Etag");
-      if (e)
-        e->value->assign (etag);
-      else
-        {
-          e = new HttpResponseHeader::Entry ();
-          e->name->assign ("Etag");
+        HttpResponseHeader::Entry *e = td->response.other.get ("Etag");
+        if (e)
           e->value->assign (etag);
-          td->response.other.put (*(e->name), e);
-        }
+        else
+          {
+            e = new HttpResponseHeader::Entry ();
+            e->name->assign ("Etag");
+            e->value->assign (etag);
+            td->response.other.put (*(e->name), e);
+          }
       }
 
     bytesToSend = filesize;
@@ -348,10 +342,10 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
         HttpRequestHeader::Entry* e = td->request.other.get 
("Accept-encoding");
         if (td->mime &&
             Server::getInstance ()->getFiltersFactory ()->chain (&chain,
-                                                            td->mime->filters,
-                                                            &memStream,
+                                                                 
td->mime->filters,
+                                                                 &memStream,
                                                                  &nbw, 0,
-                                                     e ? e->value : NULL))
+                                                                 e ? e->value 
: NULL))
           {
             file->close ();
             delete file;
@@ -394,28 +388,28 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
           }
         /* Do not use chunked transfer with old HTTP/1.0 clients.  */
         if (keepalive)
-         useChunks = true;
+          useChunks = true;
       }
 
     if (useChunks)
       {
-       HttpResponseHeader::Entry *e;
-       e = td->response.other.get ("Transfer-encoding");
-       if (e)
-         e->value->assign ("chunked");
-       else
-         {
-           e = new HttpResponseHeader::Entry ();
-           e->name->assign ("Transfer-encoding");
-           e->value->assign ("chunked");
-           td->response.other.put (*(e->name), e);
-         }
+        HttpResponseHeader::Entry *e;
+        e = td->response.other.get ("Transfer-encoding");
+        if (e)
+          e->value->assign ("chunked");
+        else
+          {
+            e = new HttpResponseHeader::Entry ();
+            e->name->assign ("Transfer-encoding");
+            e->value->assign ("chunked");
+            td->response.other.put (*(e->name), e);
+          }
       }
     else
       {        HttpResponseHeader::Entry *e;
-       e = td->response.other.remove ("Transfer-encoding");
-       if (e)
-         delete e;
+        e = td->response.other.remove ("Transfer-encoding");
+        if (e)
+          delete e;
       }
 
     if (HttpHeaders::sendHeader (td->response, *td->connection->socket,
@@ -476,7 +470,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
     if (memStream.availableToRead ())
       {
         if (memStream.read (td->buffer->getBuffer (),
-                           td->buffer->getRealLength (), &nbr))
+                            td->buffer->getRealLength (), &nbr))
           {
             file->close ();
             delete file;
@@ -485,11 +479,12 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
           }
 
         memStream.refresh ();
-       if (nbr && HttpDataHandler::appendDataToHTTPChannel (td,
-                                       td->buffer->getBuffer (),
-                                       nbr, &(td->outputData),
-                                       &chain, td->appendOutputs,
-                                       useChunks))
+        if (nbr
+            && HttpDataHandler::appendDataToHTTPChannel (td,
+                                                      td->buffer->getBuffer (),
+                                                     nbr, &(td->outputData),
+                                                     &chain, td->appendOutputs,
+                                                         useChunks))
           {
             file->close ();
             delete file;
@@ -510,9 +505,9 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
           {
             /* Read from the file the bytes to send.  */
             if (ret = file->read (td->buffer->getBuffer (),
-                  std::min (static_cast<u_long> (bytesToSend),
-                  static_cast<u_long> (td->buffer->getRealLength () / 2)),
-                  &nbr))
+                                  std::min (static_cast<u_long> (bytesToSend),
+                      static_cast<u_long> (td->buffer->getRealLength () / 2)),
+                                  &nbr))
               break;
 
             if (nbr == 0)
@@ -524,8 +519,8 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             bytesToSend -= nbr;
 
             if (ret = appendDataToHTTPChannel (td, td->buffer->getBuffer (),
-                     nbr, &(td->outputData), &chain, td->appendOutputs,
-                     useChunks, td->buffer->getRealLength (), &memStream))
+                           nbr, &(td->outputData), &chain, td->appendOutputs,
+                          useChunks, td->buffer->getRealLength (), &memStream))
               break;
 
             dataSent += nbr;
@@ -554,22 +549,22 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
 
                 chain.setStream (tmpStream);
                 if (ret = memStream.read (td->buffer->getBuffer (),
-                    td->buffer->getRealLength (), &nbr))
+                                          td->buffer->getRealLength (), &nbr))
                   break;
 
                 if (ret = HttpDataHandler::appendDataToHTTPChannel (td,
-                    td->buffer->getBuffer (), nbr, &(td->outputData),
-                    &chain, td->appendOutputs, useChunks))
+                        td->buffer->getBuffer (), nbr, &(td->outputData),
+                                   &chain, td->appendOutputs, useChunks))
                   break;
 
                 ret = HttpDataHandler::appendDataToHTTPChannel (td, 0, 0,
-                                         &(td->outputData), &chain,
-                                         td->appendOutputs, useChunks);
+                                               &(td->outputData), &chain,
+                                            td->appendOutputs, useChunks);
                 break;
               }
           }
         memStream.refresh ();
-    }/* End for loop.  */
+      }/* End for loop.  */
 
     file->close ();
     delete file;
@@ -588,7 +583,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
   chain.clearAllFilters ();
 
   if (ret)
-  return HttpDataHandler::RET_FAILURE;
+    return HttpDataHandler::RET_FAILURE;
   else
     return HttpDataHandler::RET_OK;
 }
@@ -620,7 +615,7 @@ int HttpFile::load ()
 
 /*!
   Unload the static elements.
- */
+*/
 int HttpFile::unLoad ()
 {
   return 0;

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

Summary of changes:
 myserver/documentation/security.texi              |    2 +-
 myserver/documentation/virtual_hosts.texi         |    6 +-
 myserver/src/http_handler/http_file/http_file.cpp |  155 ++++++++++-----------
 myserver/src/http_handler/proxy/proxy.cpp         |   48 ++++---
 myserver/src/protocol/http/http.cpp               |    3 +-
 5 files changed, 107 insertions(+), 107 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

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