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-489


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-489-g7fc18d7
Date: Mon, 25 Apr 2011 13:44:25 +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  7fc18d70ec79a6d373880e930c1869f676c143ea (commit)
       via  fcb1ab716e0fe94fff2d659d56e0b52f26e2c6b5 (commit)
       via  b44cfa9bd85d91393720255d19a0100fe68a2453 (commit)
       via  9374898daecdbc59e683ace0102f3de8e4d9fad5 (commit)
       via  277a02215b8befe7479a4fffbd2d0ebf6ae00b84 (commit)
      from  8539d2f58209a68e932680002527bef816bdb199 (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 7fc18d70ec79a6d373880e930c1869f676c143ea
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Apr 25 15:13:50 2011 +0200

    HttpDataHandler: skip chunks with size 0.

diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index 24c89de..fc30836 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -148,29 +148,36 @@ int Proxy::send (HttpThreadContext *td, const char* 
scriptpath,
 /*!
   Flush the server reply to the client.
  */
-int Proxy::flushToClient (HttpThreadContext* td, Socket& client,
+int Proxy::flushToClient (HttpThreadContext* td, Socket &client,
                           FiltersChain &out, bool onlyHeader, bool *kaClient)
 {
   size_t read = 0;
   size_t headerLength;
   int ret;
   size_t nbw;
-
+  bool validResponse = false;
   td->response.free ();
-  do
+
+  for (;;)
     {
       ret = client.recv (td->auxiliaryBuffer->getBuffer () + read,
-                         td->auxiliaryBuffer->getRealLength () - read,
+                         td->auxiliaryBuffer->getRealLength () - read - 1,
                          0,
                          td->http->getTimeout ());
 
+      if (ret == 0)
+        break;
+
       read += ret;
 
-      if (HttpHeaders::buildHTTPResponseHeaderStruct
-          (td->auxiliaryBuffer->getBuffer (), &td->response, &headerLength))
+      td->auxiliaryBuffer->getBuffer ()[read] = '\0';
+
+      validResponse = HttpHeaders::buildHTTPResponseHeaderStruct
+        (td->auxiliaryBuffer->getBuffer (), &td->response, &headerLength);
+
+      if (validResponse)
         break;
     }
-  while (ret);
 
   if (read == 0)
     return td->http->raiseHTTPError (500);
@@ -200,7 +207,6 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
       transferEncoding.assign (*tmp);
     }
 
-
   char tmpBuf[1024];
   MemBuf memBuf;
   MemoryStream memStream (&memBuf);
@@ -210,7 +216,6 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
 
   /* At this point we can modify the response struct before send it to the
      client.  */
-
   chooseEncoding (td, td->response.contentLength.length ());
   HttpHeaders::sendHeader (td->response, *out.getStream (), *td->buffer, td);
 
@@ -285,9 +290,10 @@ int Proxy::readPayLoad (HttpThreadContext* td,
               if (!nbr)
                 break;
 
-              td->sentData += HttpDataHandler::appendDataToHTTPChannel (td,
-                                                       td->buffer->getBuffer 
(),
-                                                       nbr);
+              td->sentData +=
+                HttpDataHandler::appendDataToHTTPChannel (td,
+                                                      td->buffer->getBuffer (),
+                                                          nbr);
             }
         }
     }
@@ -306,8 +312,8 @@ int Proxy::readPayLoad (HttpThreadContext* td,
 
           int timedOut =
             HttpDataRead::readContiguousPrimitivePostData (initBuffer, &inPos,
-                                                           initBufferSize, 
client,
-                                                           
td->buffer->getBuffer (),
+                                                       initBufferSize, client,
+                                                     td->buffer->getBuffer (),
                                                            len, &nbr, timeout);
 
           if (contentLength == 0 && nbr == 0)
diff --git a/myserver/src/protocol/http/http.cpp 
b/myserver/src/protocol/http/http.cpp
index df48dea..74292a1 100644
--- a/myserver/src/protocol/http/http.cpp
+++ b/myserver/src/protocol/http/http.cpp
@@ -744,8 +744,7 @@ Http::sendHTTPResource (string& uri, bool systemrequest, 
bool onlyHeader,
 int Http::logHTTPaccess ()
 {
   char tmpStrInt[12];
-
-  string time;
+  char time[32];
 
   try
     {
diff --git a/myserver/src/protocol/http/http_data_handler.cpp 
b/myserver/src/protocol/http/http_data_handler.cpp
index 8a2bada..2409da0 100644
--- a/myserver/src/protocol/http/http_data_handler.cpp
+++ b/myserver/src/protocol/http/http_data_handler.cpp
@@ -134,6 +134,12 @@ HttpDataHandler::appendDataToHTTPChannel 
(HttpThreadContext *td,
 {
   size_t tmp, nbw = 0;
 
+  /* In the chunked transfer encoding, a chunk of size 0 has a special meaning,
+     just skip it.  */
+  if (td->transferEncoding == HttpThreadContext::TRANSFER_ENCODING_CHUNKED
+      && size == 0)
+    return 0;
+
   if (td->transferEncoding == HttpThreadContext::TRANSFER_ENCODING_CHUNKED)
     {
       ostringstream chunkHeader;
diff --git a/myserver/src/protocol/http/http_data_read.cpp 
b/myserver/src/protocol/http/http_data_read.cpp
index 03b6f89..44d4f97 100644
--- a/myserver/src/protocol/http/http_data_read.cpp
+++ b/myserver/src/protocol/http/http_data_read.cpp
@@ -171,7 +171,7 @@ int HttpDataRead::readChunkedPostData (const char *inBuffer,
 
       while (chunkNbr < dataToRead)
         {
-          u_long rs = min (outBufferSize , dataToRead - chunkNbr);
+          u_long rs = min (outBufferSize, dataToRead - chunkNbr);
 
           int timedOut =
             readContiguousPrimitivePostData (inBuffer, inBufferPos,
diff --git a/myserver/src/protocol/http/http_headers.cpp 
b/myserver/src/protocol/http/http_headers.cpp
index 4198769..357c11e 100644
--- a/myserver/src/protocol/http/http_headers.cpp
+++ b/myserver/src/protocol/http/http_headers.cpp
@@ -954,7 +954,7 @@ int HttpHeaders::buildHTTPResponseHeaderStruct (const char 
*input,
   /* Control if the HTTP header is a valid header.  */
   if (input[0] == 0)
     return 0;
-  validResponse = validHTTPResponse (input,&nLines, &maxTotchars);
+  validResponse = validHTTPResponse (input, &nLines, &maxTotchars);
 
   if (validResponse)
   {



commit fcb1ab716e0fe94fff2d659d56e0b52f26e2c6b5
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Apr 25 13:32:07 2011 +0200

    Proxy: report correctly sent data.

diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index de04c5b..24c89de 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -224,7 +224,6 @@ int Proxy::flushToClient (HttpThreadContext* td, Socket& 
client,
                read - headerLength, td->http->getTimeout (),
                hasTransferEncoding ? &transferEncoding : NULL);
 
-  td->sentData += ret;
   return HttpDataHandler::RET_OK;
 }
 



commit b44cfa9bd85d91393720255d19a0100fe68a2453
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Apr 25 13:29:33 2011 +0200

    Gzip: code cleanup.

diff --git a/myserver/src/filter/gzip/gzip.cpp 
b/myserver/src/filter/gzip/gzip.cpp
index 8ccacdd..010c354 100644
--- a/myserver/src/filter/gzip/gzip.cpp
+++ b/myserver/src/filter/gzip/gzip.cpp
@@ -88,13 +88,13 @@ u_long Gzip::compress (const char* in, size_t sizeIn,
   u_long old_total_out = data.stream.total_out;
   u_long ret;
 
-  if (compressBound (sizeIn) > (u_long)sizeOut)
+  if (compressBound (sizeIn) > (u_long) sizeOut)
     return 0;
 
   data.stream.data_type = Z_BINARY;
-  data.stream.next_in = (Bytef*) in;
+  data.stream.next_in = (Bytef *) in;
   data.stream.avail_in = sizeIn;
-  data.stream.next_out = (Bytef*) out;
+  data.stream.next_out = (Bytef *) out;
   data.stream.avail_out = sizeOut;
   ret = deflate (&(data.stream), Z_FULL_FLUSH);
 
@@ -266,28 +266,17 @@ u_long Gzip::getHeader (char *buffer, size_t buffersize)
  */
 int Gzip::read (char* buffer, size_t len, size_t *nbr)
 {
-  char *tmp_buff;
-  size_t nbr_parent;
+  char tmpBuf[len / 2];
+  size_t nbrParent;
   if (!parent)
     return -1;
 
   if (!active)
     return parent->read (buffer, len, nbr);
 
-  tmp_buff = new char[len/2];
-
-  try
-    {
-      parent->read (tmp_buff, len/2, &nbr_parent);
-      *nbr = compress (tmp_buff, nbr_parent, buffer, len);
-    }
-  catch (...)
-    {
-      delete [] tmp_buff;
-      throw;
-    }
+  parent->read (tmpBuf, len / 2, &nbrParent);
+  *nbr = compress (tmpBuf, nbrParent, buffer, len);
 
-  delete [] tmp_buff;
   return 0;
 }
 



commit 9374898daecdbc59e683ace0102f3de8e4d9fad5
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Apr 25 13:28:21 2011 +0200

    Proxy: do not clear filters list.

diff --git a/myserver/src/http_handler/mscgi/mscgi.cpp 
b/myserver/src/http_handler/mscgi/mscgi.cpp
index 299f837..a0e83a1 100644
--- a/myserver/src/http_handler/mscgi/mscgi.cpp
+++ b/myserver/src/http_handler/mscgi/mscgi.cpp
@@ -103,7 +103,6 @@ int MsCgi::send (HttpThreadContext* td, const char* exec, 
const char* cmdLine,
         {
           td->connection->host->warningsLogWrite (_E ("MSCGI: cannot load %s"),
                                                   exec, &e);
-          chain.clearAllFilters ();
           /* Internal server error.  */
           return td->http->raiseHTTPError (500);
         }
@@ -122,7 +121,6 @@ int MsCgi::send (HttpThreadContext* td, const char* exec, 
const char* cmdLine,
 
       if (data.errorPage)
         {
-          chain.clearAllFilters ();
           return td->http->raiseHTTPError (data.errorPage);
         }
 
diff --git a/myserver/src/http_handler/proxy/proxy.cpp 
b/myserver/src/http_handler/proxy/proxy.cpp
index ec5c737..de04c5b 100644
--- a/myserver/src/http_handler/proxy/proxy.cpp
+++ b/myserver/src/http_handler/proxy/proxy.cpp
@@ -129,8 +129,6 @@ int Proxy::send (HttpThreadContext *td, const char* 
scriptpath,
 
       flushToClient (td, *sock, chain, onlyHeader, &keepalive);
 
-      chain.clearAllFilters ();
-
       addConnection (con, destUrl.getHost ().c_str (), destUrl.getPort (),
                      keepalive);
 
@@ -141,7 +139,6 @@ int Proxy::send (HttpThreadContext *td, const char* 
scriptpath,
       if (con)
         addConnection (con, destUrl.getHost ().c_str (), destUrl.getPort (),
                        false);
-      chain.clearAllFilters ();
       return HttpDataHandler::RET_FAILURE;
     }
 



commit 277a02215b8befe7479a4fffbd2d0ebf6ae00b84
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Apr 25 12:38:09 2011 +0200

    HttpThreadContext: enum transfer encodings.

diff --git a/myserver/include/protocol/http/http_data_handler.h 
b/myserver/include/protocol/http/http_data_handler.h
index eb06572..555c377 100644
--- a/myserver/include/protocol/http/http_data_handler.h
+++ b/myserver/include/protocol/http/http_data_handler.h
@@ -29,7 +29,6 @@
 # include <include/filter/memory_stream.h>
 # include <include/conf/mime/mime_manager.h>
 
-
 /*!
   Base class to handle HTTP data.
  */
@@ -60,12 +59,6 @@ public:
                                          const char *buffer,
                                          size_t size);
 
-  static size_t appendDataToHTTPChannel (HttpThreadContext* td,
-                                         const char *buffer,
-                                         size_t size,
-                                         FiltersChain &chain);
-
-
   static size_t beginHTTPResponse (HttpThreadContext *td,
                                    MemoryStream &memStream);
 
@@ -76,6 +69,12 @@ public:
                                       FiltersFactory *factory,
                                       MimeRecord *mime,
                                       MemoryStream &memStream);
+
+private:
+  static size_t appendDataToHTTPChannel (HttpThreadContext* td,
+                                         const char *buffer,
+                                         size_t size,
+                                         FiltersChain &chain);
 };
 
 #endif
diff --git a/myserver/include/protocol/http/http_thread_context.h 
b/myserver/include/protocol/http/http_thread_context.h
index 7a6800c..06b848d 100644
--- a/myserver/include/protocol/http/http_thread_context.h
+++ b/myserver/include/protocol/http/http_thread_context.h
@@ -21,6 +21,7 @@
 # define HTTP_THREAD_CONTEXT_H
 
 # include "myserver.h"
+# include <include/protocol/http/http_data_handler.h>
 # include <include/protocol/http/http_request.h>
 # include <include/protocol/http/http_response.h>
 # include <include/base/string/stringutils.h>
@@ -42,12 +43,11 @@
 # include <string>
 using namespace std;
 
-
 class Http;
 class MimeRecord;
 
 /*!
-  Structure used by the HTTP protocol parser to describe a thread.
+  Store thread specific data.
  */
 struct HttpThreadContext
 {
@@ -63,7 +63,12 @@ struct HttpThreadContext
   /*! Size of the request header in `buffer'. */
   size_t headerSize;
 
-  bool useChunks;
+  enum
+    {
+      TRANSFER_ENCODING_NONE = 0,
+      TRANSFER_ENCODING_CHUNKED
+    }
+  transferEncoding;
 
   bool keepalive;
 
diff --git a/myserver/src/http_handler/mscgi/mscgi.cpp 
b/myserver/src/http_handler/mscgi/mscgi.cpp
index 065d30e..299f837 100644
--- a/myserver/src/http_handler/mscgi/mscgi.cpp
+++ b/myserver/src/http_handler/mscgi/mscgi.cpp
@@ -157,8 +157,7 @@ int MsCgi::write (const char *data, size_t len, MsCgiData 
*mcd)
 
   mcd->td->sentData +=
     HttpDataHandler::appendDataToHTTPChannel (mcd->td,
-                                              data, len,
-                                              *mcd->filtersChain);
+                                              data, len);
   return 0;
 }
 
diff --git a/myserver/src/protocol/http/http_data_handler.cpp 
b/myserver/src/protocol/http/http_data_handler.cpp
index ca9e556..8a2bada 100644
--- a/myserver/src/protocol/http/http_data_handler.cpp
+++ b/myserver/src/protocol/http/http_data_handler.cpp
@@ -134,7 +134,7 @@ HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext 
*td,
 {
   size_t tmp, nbw = 0;
 
-  if (td->useChunks)
+  if (td->transferEncoding == HttpThreadContext::TRANSFER_ENCODING_CHUNKED)
     {
       ostringstream chunkHeader;
       chunkHeader << hex << size << "\r\n";
@@ -145,7 +145,7 @@ HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext 
*td,
   if (size)
     chain.write (buffer, size, &nbw);
 
-  if (td->useChunks)
+  if (td->transferEncoding == HttpThreadContext::TRANSFER_ENCODING_CHUNKED)
     chain.getStream ()->write ("\r\n", 2, &tmp);
 
   return nbw;
@@ -161,14 +161,14 @@ void
 HttpDataHandler::chooseEncoding (HttpThreadContext *td, bool disableEncoding)
 {
   td->keepalive = td->request.isKeepAlive ();
-  td->useChunks = false;
+  td->transferEncoding = HttpThreadContext::TRANSFER_ENCODING_NONE;
 
   td->keepalive &= !td->request.ver.compare ("HTTP/1.1");
 
   if (!disableEncoding && td->keepalive)
     {
       td->response.setValue ("transfer-encoding", "chunked");
-      td->useChunks = true;
+      td->transferEncoding = HttpThreadContext::TRANSFER_ENCODING_CHUNKED;
     }
 }
 
@@ -188,6 +188,7 @@ HttpDataHandler::beginHTTPResponse (HttpThreadContext *td,
   */
   if (memStream.availableToRead ())
     {
+      FiltersChain directChain (td->outputChain.getStream ());
       for (;;)
         {
           size_t nbr;
@@ -195,7 +196,6 @@ HttpDataHandler::beginHTTPResponse (HttpThreadContext *td,
           if (nbr == 0)
             break;
 
-          FiltersChain directChain (td->outputChain.getStream ());
           ret += appendDataToHTTPChannel (td, tmpBuf, nbr, directChain);
         }
     }
@@ -213,10 +213,13 @@ HttpDataHandler::completeHTTPResponse (HttpThreadContext 
*td,
                                        MemoryStream &memStream)
 {
   size_t ret = 0;
+
   /* If we don't use chunks we can flush directly.  */
-  if (! td->useChunks)
-    td->outputChain.flush (&ret);
-  else
+  if (td->transferEncoding == HttpThreadContext::TRANSFER_ENCODING_NONE)
+    {
+      td->outputChain.flush (&ret);
+    }
+  else if (td->transferEncoding == 
HttpThreadContext::TRANSFER_ENCODING_CHUNKED)
     {
       /*
         Replace the final stream before the flush and write to a
diff --git a/myserver/src/protocol/http/http_data_read.cpp 
b/myserver/src/protocol/http/http_data_read.cpp
index 2a7289f..03b6f89 100644
--- a/myserver/src/protocol/http/http_data_read.cpp
+++ b/myserver/src/protocol/http/http_data_read.cpp
@@ -135,9 +135,10 @@ int HttpDataRead::readChunkedPostData (const char 
*inBuffer,
           buffer[0] = '\0';
           for (;;)
             {
-              int timedOut = readContiguousPrimitivePostData (inBuffer, 
inBufferPos,
-                                                              inBufferSize, 
inSocket,
-                                                              &c, 1, &nbr, 
timeout);
+              int timedOut =
+                readContiguousPrimitivePostData (inBuffer, inBufferPos,
+                                                 inBufferSize, inSocket,
+                                                 &c, 1, &nbr, timeout);
               if (nbr != 1)
                 return -1;
 
@@ -154,8 +155,9 @@ int HttpDataRead::readChunkedPostData (const char *inBuffer,
             }
 
           /* Read the \n character too. */
-          if (readContiguousPrimitivePostData (inBuffer, inBufferPos, 
inBufferSize,
-                                               inSocket, &c, 1, &nbr, timeout))
+          if (readContiguousPrimitivePostData (inBuffer, inBufferPos,
+                                               inBufferSize, inSocket,
+                                               &c, 1, &nbr, timeout))
             return -1;
 
           dataToRead = (u_long) hexToInt (buffer);
@@ -171,10 +173,11 @@ int HttpDataRead::readChunkedPostData (const char 
*inBuffer,
         {
           u_long rs = min (outBufferSize , dataToRead - chunkNbr);
 
-          int timedOut = readContiguousPrimitivePostData (inBuffer, 
inBufferPos,
-                                                          inBufferSize,
-                                                          inSocket, outBuffer,
-                                                          rs, &nbr, timeout);
+          int timedOut =
+            readContiguousPrimitivePostData (inBuffer, inBufferPos,
+                                             inBufferSize,
+                                             inSocket, outBuffer,
+                                             rs, &nbr, timeout);
 
           if (nbr == 0)
             return -1;
@@ -216,7 +219,6 @@ int HttpDataRead::readChunkedPostData (const char *inBuffer,
               return 0;
             }
         }
-
     }
 
   if (remainingChunk)
@@ -321,16 +323,17 @@ int HttpDataRead::readPostData (HttpThreadContext* td, 
int* httpRetCode)
     {
       if (encoding->value.compare ("chunked") == 0)
         {
-          int ret = readChunkedPostData (td->request.uriOptsPtr,
-                                         &inPos,
-                                         bufferDataSize,
-                                         td->connection->socket,
-                                         td->auxiliaryBuffer->getBuffer (),
-                                         td->auxiliaryBuffer->getRealLength () 
- 1,
-                                         &nbr,
-                                         timeout,
-                                         &(td->inputData),
-                                         0);
+          int ret =
+            readChunkedPostData (td->request.uriOptsPtr,
+                                 &inPos,
+                                 bufferDataSize,
+                                 td->connection->socket,
+                                 td->auxiliaryBuffer->getBuffer (),
+                                 td->auxiliaryBuffer->getRealLength () - 1,
+                                 &nbr,
+                                 timeout,
+                                 &(td->inputData),
+                                 0);
 
           if (ret < 0)
             {
@@ -382,8 +385,9 @@ int HttpDataRead::readPostData (HttpThreadContext* td, int* 
httpRetCode)
 
           td->auxiliaryBuffer->getBuffer ()[nbr] = '\0';
 
-          if (nbr && td->inputData.writeToFile (td->auxiliaryBuffer->getBuffer 
(),
-                                                nbr, &nbw))
+          if (nbr
+              && td->inputData.writeToFile (td->auxiliaryBuffer->getBuffer (),
+                                            nbr, &nbw))
             {
               td->inputData.close ();
               return -1;

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

Summary of changes:
 myserver/include/protocol/http/http_data_handler.h |   13 ++---
 .../include/protocol/http/http_thread_context.h    |   11 +++-
 myserver/src/filter/gzip/gzip.cpp                  |   25 +++-------
 myserver/src/http_handler/mscgi/mscgi.cpp          |    5 +--
 myserver/src/http_handler/proxy/proxy.cpp          |   38 ++++++++-------
 myserver/src/protocol/http/http.cpp                |    3 +-
 myserver/src/protocol/http/http_data_handler.cpp   |   25 +++++++---
 myserver/src/protocol/http/http_data_read.cpp      |   50 +++++++++++---------
 myserver/src/protocol/http/http_headers.cpp        |    2 +-
 9 files changed, 88 insertions(+), 84 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

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