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. v0.9.2-361


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-361-ge7b8a7d
Date: Sun, 22 Aug 2010 17:10:46 +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  e7b8a7da029dae3a0694003c2c6bc0dfe7d6e087 (commit)
       via  837ab55a9c8aae3b3fdb956858aad6ccb1d00165 (commit)
       via  6e8af89c2f8feb43e617cee3347c9bba0966b4e7 (commit)
       via  e9704fe5d6ebb58dce60711fda91a72d6ae7ccb3 (commit)
       via  0a1df68dc8b7436723b7c319a317dd1e6140ed76 (commit)
       via  51c4a5fa2b6cafe41a6e36e93c767e484ef0b0fb (commit)
      from  3a43751716065260b0a009c7f9d890a603f5e862 (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 e7b8a7da029dae3a0694003c2c6bc0dfe7d6e087
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 19:09:51 2010 +0200

    Proxy: work properly with old clients not using keep-alive connections.

diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index 40366e1..c7672b7 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -215,9 +215,12 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
      client.  */
   checkDataChunks (td, &keepalive, &useChunks);
 
+  td->response.setValue ("Connection", keepalive ? "keep-alive" : "close");
+
   if (useChunks)
     td->response.setValue ("Transfer-encoding", "chunked");
-
+  else
+    td->response.clearValue ("Transfer-encoding");
 
   u_long hdrLen = HttpHeaders::buildHTTPResponseHeader (td->buffer->getBuffer 
(),
                                                         &td->response);
@@ -294,12 +297,15 @@ int Proxy::readPayLoad (HttpThreadContext* td,
     {
       if (!serverTransferEncoding->compare ("chunked"))
         {
+          size_t remainingChunkSize = 0;
           for (;;)
             {
-              HttpDataRead::readChunkedPostData (initBuffer, &inPos, 
initBufferSize,
-                                                 client, td->buffer->getBuffer 
(),
-                                                 td->buffer->getRealLength () 
- 1,
-                                                 &nbr, timeout, NULL, 1);
+              if (HttpDataRead::readChunkedPostData (initBuffer, &inPos, 
initBufferSize,
+                                                     client, 
td->buffer->getBuffer (),
+                                                     td->buffer->getRealLength 
() - 1,
+                                                     &nbr, timeout, NULL, 1,
+                                                     &remainingChunkSize) < 0)
+                return HttpDataHandler::RET_FAILURE;
 
               if (!nbr)
                 break;



commit 837ab55a9c8aae3b3fdb956858aad6ccb1d00165
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 19:09:25 2010 +0200

    HttpDataRead::readChunkedPostData: Support partial data chunks.

diff --git a/myserver/include/protocol/http/http_data_read.h 
b/myserver/include/protocol/http/http_data_read.h
index 14b95b5..4eee988 100644
--- a/myserver/include/protocol/http/http_data_read.h
+++ b/myserver/include/protocol/http/http_data_read.h
@@ -62,7 +62,8 @@ public:
                                   size_t *nbr,
                                   u_long timeout,
                                   Stream *out,
-                                  long maxChunks);
+                                  long maxChunks,
+                                  size_t *remainingChunk = NULL);
 
 };
 
diff --git a/myserver/src/protocol/http/http_data_read.cpp 
b/myserver/src/protocol/http/http_data_read.cpp
index 8fbfa97..9d1e14c 100644
--- a/myserver/src/protocol/http/http_data_read.cpp
+++ b/myserver/src/protocol/http/http_data_read.cpp
@@ -97,6 +97,7 @@ int HttpDataRead::readContiguousPrimitivePostData (const char 
*inBuffer,
   \param timeout Timeout value to use on the socket.
   \param out Output file, may be  a NULL pointer.
   \param maxChunks The maximum number of chunks to read.
+  \param remainingChunk Size of the previous remaining chunk.
   \return Return 0 on success.
   \return -1 on internal error.
   \return Any other value is the HTTP error code.
@@ -110,7 +111,8 @@ int HttpDataRead::readChunkedPostData (const char *inBuffer,
                                        size_t *outNbr,
                                        u_long timeout,
                                        Stream *out,
-                                       long maxChunks)
+                                       long maxChunks,
+                                       size_t *remainingChunk)
 {
   size_t nbr;
   *outNbr = 0;
@@ -120,41 +122,48 @@ int HttpDataRead::readChunkedPostData (const char 
*inBuffer,
       size_t chunkNbr;
       size_t dataToRead;
       size_t nbw;
+      size_t tmpNbr;
       u_long bufferlen;
       char buffer[20];
       char c;
-      bufferlen = 0;
-      buffer[0] = '\0';
-      for (;;)
-        {
-          int timedOut = readContiguousPrimitivePostData (inBuffer, 
inBufferPos,
-                                                          inBufferSize, 
inSocket,
-                                                          &c, 1, &nbr, 
timeout);
-          if (nbr != 1)
-            return -1;
 
-          if ((c != '\r') && (bufferlen < 19))
+      if (remainingChunk && *remainingChunk)
+        dataToRead = *remainingChunk;
+      else
+        {
+          bufferlen = 0;
+          buffer[0] = '\0';
+          for (;;)
             {
-              buffer[bufferlen++] = c;
-              buffer[bufferlen] = '\0';
-            }
-          else
-            break;
+              int timedOut = readContiguousPrimitivePostData (inBuffer, 
inBufferPos,
+                                                              inBufferSize, 
inSocket,
+                                                              &c, 1, &nbr, 
timeout);
+              if (nbr != 1)
+                return -1;
 
-          if (timedOut)
-            break;
-        }
+              if ((c != '\r') && (bufferlen < 19))
+                {
+                  buffer[bufferlen++] = c;
+                  buffer[bufferlen] = '\0';
+                }
+              else
+                break;
+
+              if (timedOut)
+                break;
+            }
 
-      /* Read the \n character too. */
-      if (readContiguousPrimitivePostData (inBuffer, inBufferPos, inBufferSize,
-                                           inSocket, &c, 1, &nbr, timeout))
-        return -1;
+          /* Read the \n character too. */
+          if (readContiguousPrimitivePostData (inBuffer, inBufferPos, 
inBufferSize,
+                                               inSocket, &c, 1, &nbr, timeout))
+            return -1;
 
-      dataToRead = (u_long) hexToInt (buffer);
+          dataToRead = (u_long) hexToInt (buffer);
 
-      /* The last chunk length is 0.  */
-      if (dataToRead == 0)
-        break;
+          /* The last chunk length is 0.  */
+          if (dataToRead == 0)
+            break;
+        }
 
       chunkNbr = 0;
 
@@ -172,32 +181,46 @@ int HttpDataRead::readChunkedPostData (const char 
*inBuffer,
 
           chunkNbr += nbr;
 
-          if (out && out->write (outBuffer, nbr, &nbw))
-            return -1;
+          if (out == NULL)
+            *outNbr += nbr;
+          else
+            {
+              if (out->write (outBuffer, nbr, &nbw))
+                return -1;
 
-          if (nbw != nbr)
-            return -1;
+              if (nbw != nbr)
+                return -1;
 
-          if (out)
-            *outNbr += nbw;
-          else
-            *outNbr += nbr;
+              *outNbr += nbw;
+            }
 
           if (timedOut)
             break;
 
-          if (readContiguousPrimitivePostData (inBuffer,
-                                               inBufferPos,
-                                               inBufferSize,
-                                               inSocket,
-                                               outBuffer,
-                                               2,
-                                               &nbr,
-                                               timeout))
+          char tmpBuf[2];
+          if (chunkNbr == dataToRead
+              && readContiguousPrimitivePostData (inBuffer,
+                                                  inBufferPos,
+                                                  inBufferSize,
+                                                  inSocket,
+                                                  tmpBuf,
+                                                  2,
+                                                  &nbr,
+                                                  timeout))
             return -1;
+
+          if (out == NULL)
+            {
+              if (remainingChunk)
+                *remainingChunk = dataToRead - chunkNbr;
+              return 0;
+            }
         }
 
     }
+
+  if (remainingChunk)
+    *remainingChunk = 0;
   return 0;
 }
 



commit 6e8af89c2f8feb43e617cee3347c9bba0966b4e7
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 19:07:59 2010 +0200

    HttpHeader: New method clearValue.

diff --git a/myserver/include/protocol/http/http_header.h 
b/myserver/include/protocol/http/http_header.h
index 3a61ce7..f004b8a 100644
--- a/myserver/include/protocol/http/http_header.h
+++ b/myserver/include/protocol/http/http_header.h
@@ -45,9 +45,10 @@ struct HttpHeader
     ~Entry ()
     {
     }
-
   };
 
+  void clearValue (const char *name);
+
   virtual string* getValue (const char *name, string *out);
   virtual string* setValue (const char *name, const char *in);
   virtual ~HttpHeader (){}
diff --git a/myserver/src/protocol/http/http_header.cpp 
b/myserver/src/protocol/http/http_header.cpp
index f27095b..f3f8123 100644
--- a/myserver/src/protocol/http/http_header.cpp
+++ b/myserver/src/protocol/http/http_header.cpp
@@ -68,3 +68,16 @@ string* HttpHeader::setValue (const char *name, const char 
*in)
 
   return NULL;
 }
+
+/*!
+  Remove a value from the collection.
+ */
+void HttpHeader::clearValue (const char *name)
+{
+  string key (name);
+  transform (key.begin (), key.end (), key.begin (), ::tolower);
+
+  Entry *e = other.remove (key);
+  if (e)
+    delete e;
+}



commit e9704fe5d6ebb58dce60711fda91a72d6ae7ccb3
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 18:17:07 2010 +0200

    If a host is not specified, remove the connection immediately.

diff --git a/myserver/src/server/clients_thread.cpp 
b/myserver/src/server/clients_thread.cpp
index 0d2eb0f..63c2cc3 100644
--- a/myserver/src/server/clients_thread.cpp
+++ b/myserver/src/server/clients_thread.cpp
@@ -306,13 +306,18 @@ int ClientsThread::controlConnections ()
       }
     else
       {
-        protocol = server->getProtocol (c->host->getProtocolName ());
-        if (protocol)
-          retcode = protocol->controlConnection (c, (char*) buffer.getBuffer 
(),
-                                                 (char*) 
auxiliaryBuffer.getBuffer (),
-                                                 buffer.getRealLength (),
-                                                 auxiliaryBuffer.getRealLength 
(),
-                                                 nBytesToRead, id);
+        if (c->host == NULL)
+          retcode = ClientsThread::DELETE_CONNECTION;
+        else
+          {
+            protocol = server->getProtocol (c->host->getProtocolName ());
+            if (protocol)
+              retcode = protocol->controlConnection (c, buffer.getBuffer (),
+                                                     auxiliaryBuffer.getBuffer 
(),
+                                                     buffer.getRealLength (),
+                                                     
auxiliaryBuffer.getRealLength (),
+                                                     nBytesToRead, id);
+          }
       }
   }
   catch (...)



commit 0a1df68dc8b7436723b7c319a317dd1e6140ed76
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 18:12:35 2010 +0200

    Proxy: Modify the response header after we read the information we need.

diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index 446d13c..40366e1 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -167,6 +167,7 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
   bool useChunks = false;
   bool keepalive = false;
 
+  td->response.free ();
   do
     {
       ret = client.recv (td->auxiliaryBuffer->getBuffer () + read,
@@ -185,8 +186,6 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
   if (read == 0)
     return td->http->raiseHTTPError (500);
 
-  checkDataChunks (td, &keepalive, &useChunks);
-
   string *tmp = td->request.getValue ("Host", NULL);
   const char *via = tmp ? tmp->c_str () : td->connection->getLocalIpAddr ();
 
@@ -212,6 +211,10 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
       transferEncoding.assign (*tmp);
     }
 
+  /* At this point we can modify the response struct before send it to the
+     client.  */
+  checkDataChunks (td, &keepalive, &useChunks);
+
   if (useChunks)
     td->response.setValue ("Transfer-encoding", "chunked");
 



commit 51c4a5fa2b6cafe41a6e36e93c767e484ef0b0fb
Author: Giuseppe Scrivano <address@hidden>
Date:   Sun Aug 22 18:10:08 2010 +0200

    Rename variable.

diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index 0cfb353..8054f79 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -232,7 +232,7 @@ int Http::putHTTPRESOURCE (string& filename, bool sysReq, 
bool onlyHeader,
 
 /*!
   Get the file permissions mask.
-  \param filename Resource to access.
+  \param resource Resource to access.
   \param directory Directory where the resource is.
   \param file The file specified by the resource.
   \param filenamePath Complete path to the file.
@@ -241,7 +241,7 @@ int Http::putHTTPRESOURCE (string& filename, bool sysReq, 
bool onlyHeader,
   \return Return 200 on success.
   \return Any other value is the HTTP error code.
  */
-int Http::getFilePermissions (string& filename, string& directory, string& 
file,
+int Http::getFilePermissions (string& resource, string& directory, string& 
file,
                               string &filenamePath, bool yetmapped, int* 
permissions)
 {
   try
@@ -252,7 +252,7 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
 
       td->securityToken.setVhost (td->connection->host);
 
-      FilesUtility::splitPath (filename, directory, file);
+      FilesUtility::splitPath (resource, directory, file);
       FilesUtility::completePath (directory);
 
       td->securityToken.setResource (&filenamePath);
@@ -265,7 +265,7 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
         If filename is already mapped on the file system don't map it again.
        */
       if (yetmapped)
-        filenamePath.assign (filename);
+        filenamePath.assign (resource);
       else
         {
           int ret;
@@ -273,12 +273,12 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
             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 (resource);
+          if ((resource[0] != '\0')
+              && (FilesUtility::getPathRecursionLevel (resource) < 1))
             return 401;
 
-          ret = getPath (filenamePath, filename, 0);
+          ret = getPath (filenamePath, resource, 0);
           if (ret != 200)
             return ret;
         }
@@ -393,7 +393,7 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
     {
       td->connection->host->warningsLogWrite (
                                  _E ("HTTP: cannot get permissions for %s"),
-                                 filename.c_str (), &e);
+                                 resource.c_str (), &e);
       return 500;
     }
 
@@ -411,14 +411,14 @@ int Http::getFilePermissions (string& filename, string& 
directory, string& file,
 
 /*!
   Preprocess a HTTP request.
-  \param filename Resource to access.
+  \param resource Resource to access.
   \param yetmapped Is the resource mapped to the localfilesystem?
   \param permissions Permission mask for this resource.
   \param system Is it a system request?
   \return Return 200 on success.
   \return Any other value is the HTTP error code.
  */
-int Http::preprocessHttpRequest (string& filename, bool yetmapped,
+int Http::preprocessHttpRequest (string &resource, bool yetmapped,
                                  int* permissions, bool systemrequest)
 {
   string directory;
@@ -433,7 +433,7 @@ int Http::preprocessHttpRequest (string& filename, bool 
yetmapped,
       if (td->request.isKeepAlive ())
         td->response.setValue ("connection", "keep-alive");
 
-      ret = getFilePermissions (filename, directory, file,
+      ret = getFilePermissions (resource, directory, file,
                                 td->filenamePath, yetmapped, permissions);
       if (ret != 200)
         return ret;

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

Summary of changes:
 myserver/include/protocol/http/http_data_read.h |    3 +-
 myserver/include/protocol/http/http_header.h    |    3 +-
 myserver/src/http_handler/proxy/proxy.cpp       |   23 ++++--
 myserver/src/protocol/http/http.cpp             |   24 +++---
 myserver/src/protocol/http/http_data_read.cpp   |  109 ++++++++++++++---------
 myserver/src/protocol/http/http_header.cpp      |   13 +++
 myserver/src/server/clients_thread.cpp          |   19 +++--
 7 files changed, 123 insertions(+), 71 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

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