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


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-442-gdc30ec7
Date: Fri, 15 Apr 2011 12:00:58 +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  dc30ec7b59ce804f22a4341348c734ec3ca3fca4 (commit)
       via  81ca73a88a3f91aec7e0f86b12c61728b3f8e8ff (commit)
      from  5119cca140dad223a8a00673d0acd43c443019e9 (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 dc30ec7b59ce804f22a4341348c734ec3ca3fca4
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Apr 15 14:00:53 2011 +0200

    HttpFile: log correctly the number of written bytes.

diff --git a/myserver/src/http_handler/http_file/http_file.cpp 
b/myserver/src/http_handler/http_file/http_file.cpp
index b9365fc..320cd06 100644
--- a/myserver/src/http_handler/http_file/http_file.cpp
+++ b/myserver/src/http_handler/http_file/http_file.cpp
@@ -333,7 +333,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
       }
 
     useModifiers = chain.hasModifiersFilters ();
-    if (!useModifiers)
+    if (! useModifiers)
       {
         ostringstream buffer;
         buffer << bytesToSend;
@@ -459,8 +459,10 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
         if (bytesToSend)
           {
             /* Read from the file the bytes to send.  */
-            size_t size = std::min (bytesToSend,
-                                    td->buffer->getRealLength () / 2);
+            size_t size = std::min (td->buffer->getRealLength (), bytesToSend);
+
+            if (useModifiers)
+              size = std::min (size, td->auxiliaryBuffer->getRealLength () / 
2);
 
             file->read (td->buffer->getBuffer (), size, &nbr);
             if (nbr == 0)
@@ -471,10 +473,11 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
 
             bytesToSend -= nbr;
 
-            appendDataToHTTPChannel (td, td->buffer->getBuffer (),
-                           nbr, &(td->outputData), &chain, td->appendOutputs,
-                               useChunks, td->buffer->getRealLength (), 
&memStream);
-            dataSent += nbr;
+            dataSent += appendDataToHTTPChannel (td, td->buffer->getBuffer (),
+                                                 nbr, &(td->outputData), 
&chain,
+                                                 td->appendOutputs, useChunks,
+                                                 td->buffer->getRealLength (),
+                                                 &memStream);
           }
         else /* if (bytesToSend) */
           {
@@ -482,6 +485,7 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
             if (!useChunks)
               {
                 chain.flush (&nbw);
+                dataSent += nbw;
                 break;
               }
             else
@@ -501,11 +505,10 @@ int HttpFile::send (HttpThreadContext* td, const char 
*filenamePath,
                 memStream.read (td->buffer->getBuffer (),
                                 td->buffer->getRealLength (), &nbr);
 
-                HttpDataHandler::appendDataToHTTPChannel (td,
-                                                       td->buffer->getBuffer 
(),
-                                                       nbr, &(td->outputData),
-                                                       &chain, 
td->appendOutputs,
-                                                          useChunks);
+                dataSent += appendDataToHTTPChannel (td, td->buffer->getBuffer 
(),
+                                                     nbr, &(td->outputData),
+                                                     &chain, td->appendOutputs,
+                                                     useChunks);
                 break;
               }
           }



commit 81ca73a88a3f91aec7e0f86b12c61728b3f8e8ff
Author: Giuseppe Scrivano <address@hidden>
Date:   Fri Apr 15 13:32:58 2011 +0200

    appendDataToHTTPChannel returns the count of bytes successfully written.

diff --git a/myserver/include/protocol/http/http_data_handler.h 
b/myserver/include/protocol/http/http_data_handler.h
index 58f40f8..c60821a 100644
--- a/myserver/include/protocol/http/http_data_handler.h
+++ b/myserver/include/protocol/http/http_data_handler.h
@@ -50,25 +50,25 @@ public:
   HttpDataHandler ();
   virtual ~HttpDataHandler ();
 
-  static void checkDataChunks (HttpThreadContext*, bool*, bool*);
+  static void checkDataChunks (HttpThreadContext *, bool *, bool *);
 
-  static int appendDataToHTTPChannel (HttpThreadContext* td,
-                                      char* buffer,
-                                      u_long size,
-                                      File* appendFile,
-                                      FiltersChain* chain,
-                                      bool append,
-                                      bool useChunks,
-                                      u_long realBufferSize,
-                                      MemoryStream *tmpStream);
+  static size_t appendDataToHTTPChannel (HttpThreadContext* td,
+                                         char *buffer,
+                                         size_t size,
+                                         File *appendFile,
+                                         FiltersChain *chain,
+                                         bool append,
+                                         bool useChunks,
+                                         size_t realBufferSize,
+                                         MemoryStream *tmpStream);
 
-  static int appendDataToHTTPChannel (HttpThreadContext* td,
-                                      char* buffer,
-                                      u_long size,
-                                      File* appendFile,
-                                      FiltersChain* chain,
-                                      bool append,
-                                      bool useChunks);
+  static size_t appendDataToHTTPChannel (HttpThreadContext* td,
+                                         char *buffer,
+                                         size_t size,
+                                         File *appendFile,
+                                         FiltersChain* chain,
+                                         bool append,
+                                         bool useChunks);
 
 };
 
diff --git a/myserver/src/protocol/http/http_data_handler.cpp 
b/myserver/src/protocol/http/http_data_handler.cpp
index df211b8..04401ea 100644
--- a/myserver/src/protocol/http/http_data_handler.cpp
+++ b/myserver/src/protocol/http/http_data_handler.cpp
@@ -75,15 +75,15 @@ int HttpDataHandler::unLoad ()
   \param tmpStream A support on memory read/write stream used
   internally by the function.
  */
-int HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext* td,
-                                              char* buffer,
-                                              u_long size,
-                                              File* appendFile,
-                                              FiltersChain* chain,
-                                              bool append,
-                                              bool useChunks,
-                                              u_long realBufferSize,
-                                              MemoryStream *tmpStream)
+size_t HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext *td,
+                                                 char *buffer,
+                                                 size_t size,
+                                                 File *appendFile,
+                                                 FiltersChain *chain,
+                                                 bool append,
+                                                 bool useChunks,
+                                                 size_t realBufferSize,
+                                                 MemoryStream *tmpStream)
 {
   size_t nbr, nbw;
   Stream *oldStream = chain->getStream ();
@@ -101,25 +101,12 @@ int HttpDataHandler::appendDataToHTTPChannel 
(HttpThreadContext* td,
    */
   chain->setStream (tmpStream);
 
-  if (chain->write (buffer, size, &nbw))
-    {
-      td->connection->host->warningsLogWrite (_("Http: internal error"));
-      return 1;
-    }
+  chain->write (buffer, size, &nbw);
 
-
-  if (tmpStream->read (buffer, realBufferSize, &nbr))
-    {
-      td->connection->host->warningsLogWrite (_("Http: internal error"));
-      return 1;
-    }
+  tmpStream->read (buffer, realBufferSize, &nbr);
 
   chain->setStream (oldStream);
 
-  /*
-   *Use of chain->getStream () is needed to write directly on the
-   *final stream.
-   */
   return appendDataToHTTPChannel (td, buffer, nbr, appendFile, chain, append,
                                   useChunks);
 }
@@ -135,58 +122,46 @@ int HttpDataHandler::appendDataToHTTPChannel 
(HttpThreadContext* td,
   \param append Append to the file?
   \param useChunks Can we use HTTP chunks to send data?
  */
-int
-HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext* td, char* buffer,
-                           u_long size, File* appendFile, FiltersChain* chain,
+size_t
+HttpDataHandler::appendDataToHTTPChannel (HttpThreadContext* td,
+                                          char *buffer,
+                                          size_t size,
+                                          File *appendFile,
+                                          FiltersChain *chain,
                                           bool append, bool useChunks)
 {
-  size_t nbw;
-
+  size_t tmp, nbw = 0;
   if (chain->hasModifiersFilters ())
     {
       td->connection->host->warningsLogWrite (_("Http: internal error"));
-      return 1;
+      return 0;
     }
 
   if (append)
-    return appendFile->writeToFile (buffer, size, &nbw);
-  else
     {
-      if (useChunks)
-        {
-          ostringstream chunkHeader;
-          size_t flushNbw = 0;
-          chunkHeader << hex << size << "\r\n";
-
-          if (chain->flush (&flushNbw))
-            {
-              td->connection->host->warningsLogWrite (_("Http: internal 
error"));
-              return 1;
-            }
-
-          if (chain->getStream ()->write (chunkHeader.str ().c_str (),
-                                          chunkHeader.str ().length (), &nbw))
-            {
-              td->connection->host->warningsLogWrite (_("Http: internal 
error"));
-              return 1;
-            }
-        }
+      appendFile->writeToFile (buffer, size, &nbw);
+      return nbw;
+    }
 
-      if (size && chain->write (buffer, size, &nbw))
-        {
-          td->connection->host->warningsLogWrite (_("Http: internal error"));
-          return 1;
-        }
+  if (useChunks)
+    {
+      ostringstream chunkHeader;
+      size_t flushNbw = 0;
+      chunkHeader << hex << size << "\r\n";
 
-      if (useChunks && chain->getStream ()->write ("\r\n", 2, &nbw))
-        {
-          td->connection->host->warningsLogWrite (_("Http: internal error"));
-          return 1;
-        }
+      chain->flush (&flushNbw);
 
-      return 0;
+      chain->getStream ()->write (chunkHeader.str ().c_str (),
+                                  chunkHeader.str ().length (), &tmp);
     }
-  return 1;
+
+  if (size)
+    chain->write (buffer, size, &nbw);
+
+  if (useChunks)
+    chain->getStream ()->write ("\r\n", 2, &tmp);
+
+  return nbw;
 }
 
 /*!

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

Summary of changes:
 myserver/include/protocol/http/http_data_handler.h |   34 ++++----
 myserver/src/http_handler/http_file/http_file.cpp  |   27 +++---
 myserver/src/protocol/http/http_data_handler.cpp   |  101 ++++++++------------
 3 files changed, 70 insertions(+), 92 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

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