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


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-265-ga125bce
Date: Tue, 22 Jun 2010 22:21:00 +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  a125bce0bbb9a4c98a729ae53386e46be1e56423 (commit)
      from  0ca49e426dec971726ae03d2ac09557dad828e39 (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 a125bce0bbb9a4c98a729ae53386e46be1e56423
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Jun 23 00:18:14 2010 +0200

    Always create the temporary file used to store POST data.

diff --git a/myserver/src/protocol/http/http_data_read.cpp 
b/myserver/src/protocol/http/http_data_read.cpp
index dadf324..6aedc5c 100644
--- a/myserver/src/protocol/http/http_data_read.cpp
+++ b/myserver/src/protocol/http/http_data_read.cpp
@@ -48,28 +48,28 @@ using namespace std;
   \param nbr Number of bytes read.
   \param timeout Timeout value to use on the socket.
   \return Return 0 on success.
- */
+*/
 int HttpDataRead::readContiguousPrimitivePostData (const char* inBuffer,
-                                                  u_long *inBufferPos,
-                                                  u_long inBufferSize,
-                                                  Socket *inSocket,
-                                                  char* outBuffer,
-                                                  u_long outBufferSize,
-                                                  u_long* nbr,
-                                                  u_long timeout)
+                                                   u_long *inBufferPos,
+                                                   u_long inBufferSize,
+                                                   Socket *inSocket,
+                                                   char* outBuffer,
+                                                   u_long outBufferSize,
+                                                   u_long* nbr,
+                                                   u_long timeout)
 {
   int ret;
   *nbr = 0;
   if (inBufferSize - *inBufferPos)
-  {
-    *nbr = min (outBufferSize, inBufferSize - *inBufferPos);
-    memcpy (outBuffer, inBuffer + *inBufferPos, *nbr);
-    *inBufferPos += *nbr;
-  }
+    {
+      *nbr = min (outBufferSize, inBufferSize - *inBufferPos);
+      memcpy (outBuffer, inBuffer + *inBufferPos, *nbr);
+      *inBufferPos += *nbr;
+    }
 
   /*
     No other space in the out buffer, return from the function with success.
-   */
+  */
   if (outBufferSize == *nbr)
     return 0;
 
@@ -101,122 +101,122 @@ int HttpDataRead::readContiguousPrimitivePostData 
(const char* inBuffer,
   \return Return 0 on success.
   \return -1 on internal error.
   \return Any other value is the HTTP error code.
- */
+*/
 int HttpDataRead::readChunkedPostData (const char* inBuffer,
-                                      u_long *inBufferPos,
-                                      u_long inBufferSize,
-                                      Socket *inSocket,
-                                      char* outBuffer,
-                                      u_long outBufferSize,
-                                      u_long* outNbr,
-                                      u_long timeout,
-                                      Stream* out,
-                                      long maxChunks)
+                                       u_long *inBufferPos,
+                                       u_long inBufferSize,
+                                       Socket *inSocket,
+                                       char* outBuffer,
+                                       u_long outBufferSize,
+                                       u_long* outNbr,
+                                       u_long timeout,
+                                       Stream* out,
+                                       long maxChunks)
 {
   u_long nbr;
   *outNbr = 0;
 
   for (int n = 0; maxChunks == 0 || n < maxChunks; n++)
-  {
-    u_long chunkNbr;
-    u_long dataToRead;
-    u_long nbw;
-    u_long bufferlen;
-    char buffer[20];
-    char c;
-    bufferlen = 0;
-    buffer[0] = '\0';
-    for (;;)
     {
-      if (readContiguousPrimitivePostData (inBuffer,
-                                         inBufferPos,
-                                         inBufferSize,
-                                         inSocket,
-                                         &c,
-                                         1,
-                                         &nbr,
-                                         timeout))
-        return -1;
-
-      if (nbr != 1)
-        return -1;
+      u_long chunkNbr;
+      u_long dataToRead;
+      u_long nbw;
+      u_long bufferlen;
+      char buffer[20];
+      char c;
+      bufferlen = 0;
+      buffer[0] = '\0';
+      for (;;)
+        {
+          if (readContiguousPrimitivePostData (inBuffer,
+                                               inBufferPos,
+                                               inBufferSize,
+                                               inSocket,
+                                               &c,
+                                               1,
+                                               &nbr,
+                                               timeout))
+            return -1;
 
-      if ((c != '\r') && (bufferlen < 19))
-      {
-        buffer[bufferlen++] = c;
-        buffer[bufferlen] = '\0';
-      }
-      else
-        break;
-    }
+          if (nbr != 1)
+            return -1;
 
-    /* Read the \n character too. */
-    if (readContiguousPrimitivePostData (inBuffer,
-                                       inBufferPos,
-                                       inBufferSize,
-                                       inSocket,
-                                       &c,
-                                       1,
-                                       &nbr,
-                                       timeout))
-       return -1;
+          if ((c != '\r') && (bufferlen < 19))
+            {
+              buffer[bufferlen++] = c;
+              buffer[bufferlen] = '\0';
+            }
+          else
+            break;
+        }
 
-    dataToRead = (u_long) hexToInt (buffer);
+      /* Read the \n character too. */
+      if (readContiguousPrimitivePostData (inBuffer,
+                                           inBufferPos,
+                                           inBufferSize,
+                                           inSocket,
+                                           &c,
+                                           1,
+                                           &nbr,
+                                           timeout))
+        return -1;
 
-    /* The last chunk length is 0.  */
-    if (dataToRead == 0)
-      break;
+      dataToRead = (u_long) hexToInt (buffer);
 
-    chunkNbr = 0;
+      /* The last chunk length is 0.  */
+      if (dataToRead == 0)
+        break;
 
-    while (chunkNbr < dataToRead)
-    {
-      u_long rs = min (outBufferSize , dataToRead - chunkNbr);
+      chunkNbr = 0;
 
-      if (readContiguousPrimitivePostData (inBuffer,
-                                         inBufferPos,
-                                         inBufferSize,
-                                         inSocket,
-                                         outBuffer,
-                                         rs,
-                                         &nbr,
-                                         timeout))
-      {
-        return -1;
-      }
+      while (chunkNbr < dataToRead)
+        {
+          u_long rs = min (outBufferSize , dataToRead - chunkNbr);
+
+          if (readContiguousPrimitivePostData (inBuffer,
+                                               inBufferPos,
+                                               inBufferSize,
+                                               inSocket,
+                                               outBuffer,
+                                               rs,
+                                               &nbr,
+                                               timeout))
+            {
+              return -1;
+            }
 
-      if (nbr == 0)
-        return -1;
+          if (nbr == 0)
+            return -1;
 
-      chunkNbr += nbr;
+          chunkNbr += nbr;
 
-      if (out && out->write (outBuffer, nbr, &nbw))
-        return -1;
+          if (out && out->write (outBuffer, nbr, &nbw))
+            return -1;
 
-      if (nbw != nbr)
-        return -1;
+          if (nbw != nbr)
+            return -1;
 
-      if (out)
-        *outNbr += nbw;
-      else
-        *outNbr += nbr;
+          if (out)
+            *outNbr += nbw;
+          else
+            *outNbr += nbr;
+
+          /* Read final chunk \r\n.  */
+          if (readContiguousPrimitivePostData (inBuffer,
+                                               inBufferPos,
+                                               inBufferSize,
+                                               inSocket,
+                                               outBuffer,
+                                               2,
+                                               &nbr,
+                                               timeout))
+            {
+              return -1;
+            }
 
-      /* Read final chunk \r\n.  */
-      if (readContiguousPrimitivePostData (inBuffer,
-                                         inBufferPos,
-                                         inBufferSize,
-                                         inSocket,
-                                         outBuffer,
-                                         2,
-                                         &nbr,
-                                         timeout))
-      {
-        return -1;
-      }
+        }
 
     }
-
-  }
   return 0;
 }
 
@@ -226,9 +226,9 @@ int HttpDataRead::readChunkedPostData (const char* inBuffer,
   \param httpRetCode The HTTP error to report to the client.
   \return Return 0 on success.
   \return Return -1 on irreversible error and
-         the connection should be removed immediately.
+  the connection should be removed immediately.
   \return Any other value is a protocol error specified in HTTPRETCODE.
- */
+*/
 int HttpDataRead::readPostData (HttpThreadContext* td, int* httpRetCode)
 {
   int contentLength = 0;
@@ -250,61 +250,58 @@ int HttpDataRead::readPostData (HttpThreadContext* td, 
int* httpRetCode)
 
   /* Specify a type if it not specified by the client.  */
   if (contentType == 0)
-  {
-    contentType = new HttpRequestHeader::Entry ();
-    contentType->name.assign ("content-type");
-    contentType->value.assign ("application/x-www-form-urlencoded");
-  }
+    {
+      contentType = new HttpRequestHeader::Entry ();
+      contentType->name.assign ("content-type");
+      contentType->value.assign ("application/x-www-form-urlencoded");
+    }
   else if (contentType->value.length () == 0)
-  {
     contentType->value.assign ("application/x-www-form-urlencoded");
-  }
 
   td->request.uriOptsPtr = &(td->buffer->getBuffer ())[td->nHeaderChars];
   td->buffer->getBuffer ()[td->nBytesToRead < td->buffer->getRealLength () - 1
-                   ? td->nBytesToRead : td->buffer->getRealLength ()-1] = '\0';
+                           ? td->nBytesToRead : td->buffer->getRealLength 
()-1] = '\0';
 
   if (td->request.contentLength.length ())
-  {
-    contentLength = atoi (td->request.contentLength.c_str ());
-    contentLengthSpecified = true;
-    if (contentLength < 0)
     {
-      *httpRetCode = 400;
-      return 1;
+      contentLength = atoi (td->request.contentLength.c_str ());
+      contentLengthSpecified = true;
+      if (contentLength < 0)
+        {
+          *httpRetCode = 400;
+          return 1;
+        }
     }
-  }
 
-  /*!
+  /*
     If the connection is Keep-Alive be sure that the client specify the
     HTTP CONTENT-LENGTH field.
     If a CONTENT-ENCODING is specified the CONTENT-LENGTH is not
     always needed.
-   */
+  */
   if (!contentLengthSpecified && td->request.isKeepAlive ())
-  {
-    HttpRequestHeader::Entry *content =
-      td->request.other.get ("content-encoding");
-
-    if (content && (content->value.length () == '\0')
-           && (td->request.contentLength.length () == 0))
     {
-      *httpRetCode = 400;
-      return 1;
+      HttpRequestHeader::Entry *content =
+        td->request.other.get ("content-encoding");
+
+      if (content && (content->value.length () == '\0')
+          && (td->request.contentLength.length () == 0))
+        {
+          *httpRetCode = 400;
+          return 1;
+        }
     }
-  }
 
   /*
     Create the file that contains the posted data.
     This data is the stdin file in the CGI.
-   */
-  if (td->inputData.openFile (td->inputDataPath, File::FILE_OPEN_ALWAYS |
-                            File::READ |
-                            File::WRITE))
-  {
-    *httpRetCode = 500;
-    return 1;
-  }
+  */
+  if (td->inputData.openFile (td->inputDataPath, File::READ
+                              | File::WRITE))
+    {
+      *httpRetCode = 500;
+      return 1;
+    }
 
   length = contentLength;
 
@@ -314,40 +311,40 @@ int HttpDataRead::readPostData (HttpThreadContext* td, 
int* httpRetCode)
 
   /* If it is specified a transfer encoding read data using it.  */
   if (encoding)
-  {
-    if (!encoding->value.compare ("chunked"))
     {
-      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 == -1)
-      {
-        td->inputDataPath.assign ("");
-        td->outputDataPath.assign ("");
-        td->inputData.close ();
-        return -1;
-      }
-      else if (ret)
-      {
-        *httpRetCode = ret;
-        return 1;
-      }
+      if (!encoding->value.compare ("chunked"))
+        {
+          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 == -1)
+            {
+              td->inputDataPath.assign ("");
+              td->outputDataPath.assign ("");
+              td->inputData.close ();
+              return -1;
+            }
+          else if (ret)
+            {
+              *httpRetCode = ret;
+              return 1;
+            }
+
+        }
+      else
+        {
+          *httpRetCode = 501;
+          return 1;
+        }
     }
-    else
-    {
-      *httpRetCode = 501;
-      return 1;
-    }
-  }
   else
     {
       for (;;)

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

Summary of changes:
 myserver/src/protocol/http/http_data_read.cpp |  359 ++++++++++++-------------
 1 files changed, 178 insertions(+), 181 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

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