gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5982 - in libmicrohttpd/src: daemon include


From: gnunet
Subject: [GNUnet-SVN] r5982 - in libmicrohttpd/src: daemon include
Date: Wed, 19 Dec 2007 21:45:24 -0700 (MST)

Author: grothoff
Date: 2007-12-19 21:45:24 -0700 (Wed, 19 Dec 2007)
New Revision: 5982

Modified:
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/connection.h
   libmicrohttpd/src/daemon/daemon.c
   libmicrohttpd/src/daemon/daemontest_get.c
   libmicrohttpd/src/daemon/daemontest_large_put.c
   libmicrohttpd/src/daemon/daemontest_post_loop.c
   libmicrohttpd/src/daemon/daemontest_postform.c
   libmicrohttpd/src/daemon/daemontest_put_chunked.c
   libmicrohttpd/src/daemon/fileserver_example.c
   libmicrohttpd/src/daemon/internal.h
   libmicrohttpd/src/daemon/memorypool.c
   libmicrohttpd/src/daemon/memorypool.h
   libmicrohttpd/src/daemon/minimal_example.c
   libmicrohttpd/src/daemon/postprocessor.c
   libmicrohttpd/src/include/microhttpd.h
Log:
formatting

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/connection.c       2007-12-20 04:45:24 UTC (rev 
5982)
@@ -47,7 +47,7 @@
  * Response text used when the request (http header) is too big to
  * be processed.
  *
- * Intentionally empty here to keep our memory footprint 
+ * Intentionally empty here to keep our memory footprint
  * minimal.
  */
 #define REQUEST_TOO_BIG ""
@@ -56,7 +56,7 @@
  * Response text used when the request (http header) does not
  * contain a "Host:" header and still claims to be HTTP 1.1.
  *
- * Intentionally empty here to keep our memory footprint 
+ * Intentionally empty here to keep our memory footprint
  * minimal.
  */
 #define REQUEST_LACKS_HOST ""
@@ -159,11 +159,11 @@
 MHD_queue_response (struct MHD_Connection *connection,
                     unsigned int status_code, struct MHD_Response *response)
 {
-  if ( (connection == NULL) ||
-       (response == NULL) ||
-       (connection->response != NULL) ||
-       ( (connection->state != MHD_CONNECTION_HEADERS_PROCESSED) &&
-        (connection->state != MHD_CONNECTION_FOOTERS_RECEIVED) ) )
+  if ((connection == NULL) ||
+      (response == NULL) ||
+      (connection->response != NULL) ||
+      ((connection->state != MHD_CONNECTION_HEADERS_PROCESSED) &&
+       (connection->state != MHD_CONNECTION_FOOTERS_RECEIVED)))
     return MHD_NO;
   MHD_increment_response_rc (response);
   connection->response = response;
@@ -175,17 +175,16 @@
          have already sent the full message body */
       connection->response_write_position = response->total_size;
     }
-  if ( (response->total_size == -1) &&
-       (0 == strcasecmp(connection->version,
-                       MHD_HTTP_VERSION_1_1)) )
+  if ((response->total_size == -1) &&
+      (0 == strcasecmp (connection->version, MHD_HTTP_VERSION_1_1)))
     connection->have_chunked_response = MHD_YES;
   else
     connection->have_chunked_response = MHD_NO;
-  if (connection->state == MHD_CONNECTION_HEADERS_PROCESSED) 
+  if (connection->state == MHD_CONNECTION_HEADERS_PROCESSED)
     {
-      /* response was queued "early", 
-        refuse to read body / footers or further
-        requests! */
+      /* response was queued "early",
+         refuse to read body / footers or further
+         requests! */
       SHUTDOWN (connection->socket_fd, SHUT_RD);
       connection->read_closed = MHD_YES;
       connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
@@ -203,7 +202,7 @@
   const char *expect;
 
   return ((connection->response == NULL) &&
-         (connection->version != NULL) &&
+          (connection->version != NULL) &&
           (0 == strcasecmp (connection->version,
                             MHD_HTTP_VERSION_1_1)) &&
           (NULL != (expect = MHD_lookup_connection_value (connection,
@@ -234,11 +233,11 @@
 
 /**
  * Prepare the response buffer of this connection for
- * sending.  Assumes that the response mutex is 
+ * sending.  Assumes that the response mutex is
  * already held.  If the transmission is complete,
  * this function may close the socket (and return
  * MHD_NO).
- * 
+ *
  * @return MHD_NO if readying the response failed
  */
 static int
@@ -259,7 +258,7 @@
   if (ret == -1)
     {
       /* either error or http 1.0 transfer, close
-        socket! */
+         socket! */
 #if DEBUG_CLOSE
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon, "Closing connection (end of response)\n");
@@ -268,7 +267,7 @@
       response->total_size = connection->response_write_position;
       connection_close_error (connection);
       return MHD_NO;
-    }    
+    }
   response->data_start = connection->response_write_position;
   response->data_size = ret;
   if (ret == 0)
@@ -278,49 +277,48 @@
 
 /**
  * Prepare the response buffer of this connection for
- * sending.  Assumes that the response mutex is 
+ * sending.  Assumes that the response mutex is
  * already held.  If the transmission is complete,
  * this function may close the socket (and return
  * MHD_NO).
- * 
+ *
  * @return MHD_NO if readying the response failed
  */
 static int
 try_ready_chunked_body (struct MHD_Connection *connection)
 {
   int ret;
-  char * buf;
+  char *buf;
   struct MHD_Response *response;
   unsigned int size;
   char cbuf[9];
 
-  response = connection->response;  
+  response = connection->response;
   if (connection->write_buffer_size == 0)
     {
       size = connection->daemon->pool_size;
-      do 
-       {
-         size /= 2;
-         if (size < 128) 
-           {
-             /* not enough memory */
+      do
+        {
+          size /= 2;
+          if (size < 128)
+            {
+              /* not enough memory */
 #if DEBUG_CLOSE
 #if HAVE_MESSAGES
-             MHD_DLOG (connection->daemon, "Closing connection (out of 
memory)\n");
+              MHD_DLOG (connection->daemon,
+                        "Closing connection (out of memory)\n");
 #endif
 #endif
-             connection_close_error (connection);
-             return MHD_NO; 
-           }
-         buf = MHD_pool_allocate (connection->pool,
-                                  size,
-                                  MHD_NO);
-       } 
+              connection_close_error (connection);
+              return MHD_NO;
+            }
+          buf = MHD_pool_allocate (connection->pool, size, MHD_NO);
+        }
       while (buf == NULL);
       connection->write_buffer_size = size;
       connection->write_buffer = buf;
     }
-  
+
   ret = response->crc (response->crc_cls,
                        connection->response_write_position,
                        &connection->write_buffer[8],
@@ -328,8 +326,7 @@
   if (ret == -1)
     {
       /* end of message, signal other side! */
-      strcpy(connection->write_buffer,
-            "0\r\n");      
+      strcpy (connection->write_buffer, "0\r\n");
       connection->write_buffer_append_offset = 3;
       connection->write_buffer_send_offset = 0;
       response->total_size = connection->response_write_position;
@@ -342,19 +339,12 @@
     }
   if (ret > 0xFFFFFF)
     ret = 0xFFFFFF;
-  snprintf(cbuf,
-          8,
-          "%X\r\n",
-          ret);
-  memcpy(&connection->write_buffer[8 - strlen(cbuf)],
-        cbuf,
-        strlen(cbuf));
-  memcpy(&connection->write_buffer[8 + ret],
-        "\r\n",
-        2);
+  snprintf (cbuf, 8, "%X\r\n", ret);
+  memcpy (&connection->write_buffer[8 - strlen (cbuf)], cbuf, strlen (cbuf));
+  memcpy (&connection->write_buffer[8 + ret], "\r\n", 2);
   connection->response_write_position += ret;
-  connection->write_buffer_send_offset = 8 - strlen(cbuf);
-  connection->write_buffer_append_offset = 8 + ret + 2; 
+  connection->write_buffer_send_offset = 8 - strlen (cbuf);
+  connection->write_buffer_append_offset = 8 + ret + 2;
   return MHD_YES;
 }
 
@@ -370,30 +360,28 @@
 
   connection->have_chunked_upload = MHD_NO;
   if (connection->response->total_size == -1)
-    {      
+    {
       have = MHD_get_response_header (connection->response,
                                       MHD_HTTP_HEADER_CONNECTION);
-      if ( (have == NULL) ||
-          (0 != strcasecmp(have, "close")) )
-       {
-         if ( (connection->version != NULL) &&
-              (0 == strcasecmp(connection->version,
-                               MHD_HTTP_VERSION_1_1)) )
-           {
-             connection->have_chunked_upload = MHD_YES;
-             have = MHD_get_response_header (connection->response,
-                                             
MHD_HTTP_HEADER_TRANSFER_ENCODING);
-             if (have == NULL)
-               MHD_add_response_header (connection->response,
-                                        MHD_HTTP_HEADER_TRANSFER_ENCODING, 
-                                        "chunked");
-           }
-         else        
-           {
-             MHD_add_response_header (connection->response,
-                                      MHD_HTTP_HEADER_CONNECTION, "close");
-           }
-       }
+      if ((have == NULL) || (0 != strcasecmp (have, "close")))
+        {
+          if ((connection->version != NULL) &&
+              (0 == strcasecmp (connection->version, MHD_HTTP_VERSION_1_1)))
+            {
+              connection->have_chunked_upload = MHD_YES;
+              have = MHD_get_response_header (connection->response,
+                                              
MHD_HTTP_HEADER_TRANSFER_ENCODING);
+              if (have == NULL)
+                MHD_add_response_header (connection->response,
+                                         MHD_HTTP_HEADER_TRANSFER_ENCODING,
+                                         "chunked");
+            }
+          else
+            {
+              MHD_add_response_header (connection->response,
+                                       MHD_HTTP_HEADER_CONNECTION, "close");
+            }
+        }
     }
   else if (NULL == MHD_get_response_header (connection->response,
                                             MHD_HTTP_HEADER_CONTENT_LENGTH))
@@ -440,22 +428,22 @@
  * @return MHD_YES on success, MHD_NO on failure
  */
 static int
-try_grow_read_buffer(struct MHD_Connection * connection)
+try_grow_read_buffer (struct MHD_Connection *connection)
 {
-  void * buf;
+  void *buf;
 
   buf = MHD_pool_reallocate (connection->pool,
-                            connection->read_buffer,
-                            connection->read_buffer_size,
-                            connection->read_buffer_size * 2 +
-                            MHD_BUF_INC_SIZE + 1);
+                             connection->read_buffer,
+                             connection->read_buffer_size,
+                             connection->read_buffer_size * 2 +
+                             MHD_BUF_INC_SIZE + 1);
   if (buf == NULL)
     return MHD_NO;
   /* we can actually grow the buffer, do it! */
   connection->read_buffer = buf;
   connection->read_buffer_size =
     connection->read_buffer_size * 2 + MHD_BUF_INC_SIZE;
-  return MHD_YES;  
+  return MHD_YES;
 }
 
 /**
@@ -475,23 +463,22 @@
   char *data;
   enum MHD_ValueKind kind;
   const char *reason_phrase;
-    
+
   if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED)
     {
       add_extra_headers (connection);
-      reason_phrase =
-       MHD_get_reason_phrase_for (connection->responseCode);
+      reason_phrase = MHD_get_reason_phrase_for (connection->responseCode);
       _REAL_SNPRINTF (code, 128, "%s %u %s\r\n", MHD_HTTP_VERSION_1_1,
-                     connection->responseCode, reason_phrase);
+                      connection->responseCode, reason_phrase);
       off = strlen (code);
       /* estimate size */
-      size = off + 2;               /* extra \r\n at the end */
+      size = off + 2;           /* extra \r\n at the end */
       kind = MHD_HEADER_KIND;
       if (NULL == MHD_get_response_header (connection->response,
-                                          MHD_HTTP_HEADER_DATE))
-       get_date_string (date, sizeof (date));
+                                           MHD_HTTP_HEADER_DATE))
+        get_date_string (date, sizeof (date));
       else
-       date[0] = '\0';
+        date[0] = '\0';
       size += strlen (date);
     }
   else
@@ -504,10 +491,10 @@
   while (pos != NULL)
     {
       if (pos->kind == kind)
-       size += strlen (pos->header) + strlen (pos->value) + 4;   /* colon, 
space, linefeeds */
+        size += strlen (pos->header) + strlen (pos->value) + 4; /* colon, 
space, linefeeds */
       pos = pos->next;
     }
-  /* produce data */  
+  /* produce data */
   data = MHD_pool_allocate (connection->pool, size + 1, MHD_YES);
   if (data == NULL)
     {
@@ -523,11 +510,11 @@
   pos = connection->response->first_header;
   while (pos != NULL)
     {
-      if (pos->kind == kind) 
-       {
-         SPRINTF (&data[off], "%s: %s\r\n", pos->header, pos->value);
-         off += strlen (pos->header) + strlen (pos->value) + 4;
-       }
+      if (pos->kind == kind)
+        {
+          SPRINTF (&data[off], "%s: %s\r\n", pos->header, pos->value);
+          off += strlen (pos->header) + strlen (pos->value) + 4;
+        }
       pos = pos->next;
     }
   if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED)
@@ -555,7 +542,7 @@
  */
 static void
 excessive_data_handler (struct MHD_Connection *connection,
-                       unsigned int status_code)
+                        unsigned int status_code)
 {
   struct MHD_Response *response;
 
@@ -569,21 +556,21 @@
   response = MHD_create_response_from_data (strlen (REQUEST_TOO_BIG),
                                             REQUEST_TOO_BIG, MHD_NO, MHD_NO);
   MHD_queue_response (connection, status_code, response);
-  EXTRA_CHECK(connection->response != NULL);
+  EXTRA_CHECK (connection->response != NULL);
   MHD_destroy_response (response);
   if (MHD_NO == build_header_response (connection))
     {
       /* oops - close! */
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon,
-               "Closing connection (failed to create response header)\n");
+                "Closing connection (failed to create response header)\n");
 #endif
       connection->state = MHD_CONNECTION_CLOSED;
-    } 
+    }
   else
     {
       connection->state = MHD_CONNECTION_HEADERS_SENDING;
-    } 
+    }
 }
 
 /**
@@ -591,9 +578,7 @@
  * greater than "*max", set "*max" to fd.
  */
 static void
-do_fd_set(int fd,
-         fd_set * set,
-         int * max_fd) 
+do_fd_set (int fd, fd_set * set, int *max_fd)
 {
   FD_SET (fd, set);
   if (fd > *max_fd)
@@ -626,108 +611,106 @@
   fd = connection->socket_fd;
   if (fd == -1)
     return MHD_YES;
-  while (1) {
+  while (1)
+    {
 #if DEBUG_STATES
-    fprintf(stderr,
-           "`%s' in state %u\n",
-           __FUNCTION__,
-           connection->state);
-#endif    
-    switch (connection->state)
-      {
-      case MHD_CONNECTION_INIT:
-      case MHD_CONNECTION_URL_RECEIVED:
-      case MHD_CONNECTION_HEADER_PART_RECEIVED:
-       /* while reading headers, we always grow the
-          read buffer if needed, no size-check required */
-       if ( (connection->read_closed) &&
-            (connection->read_buffer_offset == 0) )
-         {
-           connection->state = MHD_CONNECTION_CLOSED;
-           continue;
-         }     
-       if ( (connection->read_buffer_offset == connection->read_buffer_size) &&
-            (MHD_NO == try_grow_read_buffer(connection)) )
-         {
-            excessive_data_handler (connection,
-                                   (connection->url != NULL)
-                                   ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
-                                   : MHD_HTTP_REQUEST_URI_TOO_LONG);
-           continue;
-         }
-       if (MHD_NO == connection->read_closed)
-         do_fd_set (fd, read_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_HEADERS_RECEIVED:
-       /* we should never get here */
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_HEADERS_PROCESSED:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_CONTINUE_SENDING:
-       do_fd_set (fd, write_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_CONTINUE_SENT:
-       if (connection->read_buffer_offset == connection->read_buffer_size)
-         try_grow_read_buffer(connection);
-       if (connection->read_buffer_offset < connection->read_buffer_size)
-         do_fd_set (fd, read_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_BODY_RECEIVED:       
-      case MHD_CONNECTION_FOOTER_PART_RECEIVED:        
-       /* while reading footers, we always grow the
-          read buffer if needed, no size-check required */
-       if (MHD_YES == connection->read_closed)
-         {
-           connection->state = MHD_CONNECTION_CLOSED;
-           continue;
-         }
-       do_fd_set (fd, read_fd_set, max_fd);
-       /* transition to FOOTERS_RECEIVED
-          happens in read handler */
-       break;
-      case MHD_CONNECTION_FOOTERS_RECEIVED:    
-       /* no socket action, wait for client
-          to provide response */
-       break;
-      case MHD_CONNECTION_HEADERS_SENDING:
-       /* headers in buffer, keep writing */
-       do_fd_set(fd, write_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_HEADERS_SENT:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_NORMAL_BODY_READY:
-       do_fd_set (fd, write_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_NORMAL_BODY_UNREADY:
-       /* not ready, no socket action */
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_READY:
-       do_fd_set (fd, write_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
-       /* not ready, no socket action */
-       break;
-      case MHD_CONNECTION_BODY_SENT:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_FOOTERS_SENDING:
-       do_fd_set (fd, write_fd_set, max_fd);
-       break;
-      case MHD_CONNECTION_FOOTERS_SENT:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_CLOSED:
-       if (connection->socket_fd != -1) 
-         connection_close_error(connection);     
-       return MHD_YES; /* do nothing, not even reading */
-      default:
-       EXTRA_CHECK(0);
-      }
-    break;
-  }
+      fprintf (stderr, "`%s' in state %u\n", __FUNCTION__, connection->state);
+#endif
+      switch (connection->state)
+        {
+        case MHD_CONNECTION_INIT:
+        case MHD_CONNECTION_URL_RECEIVED:
+        case MHD_CONNECTION_HEADER_PART_RECEIVED:
+          /* while reading headers, we always grow the
+             read buffer if needed, no size-check required */
+          if ((connection->read_closed) &&
+              (connection->read_buffer_offset == 0))
+            {
+              connection->state = MHD_CONNECTION_CLOSED;
+              continue;
+            }
+          if ((connection->read_buffer_offset == connection->read_buffer_size)
+              && (MHD_NO == try_grow_read_buffer (connection)))
+            {
+              excessive_data_handler (connection,
+                                      (connection->url != NULL)
+                                      ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
+                                      : MHD_HTTP_REQUEST_URI_TOO_LONG);
+              continue;
+            }
+          if (MHD_NO == connection->read_closed)
+            do_fd_set (fd, read_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_HEADERS_RECEIVED:
+          /* we should never get here */
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_HEADERS_PROCESSED:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_CONTINUE_SENDING:
+          do_fd_set (fd, write_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_CONTINUE_SENT:
+          if (connection->read_buffer_offset == connection->read_buffer_size)
+            try_grow_read_buffer (connection);
+          if (connection->read_buffer_offset < connection->read_buffer_size)
+            do_fd_set (fd, read_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_BODY_RECEIVED:
+        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+          /* while reading footers, we always grow the
+             read buffer if needed, no size-check required */
+          if (MHD_YES == connection->read_closed)
+            {
+              connection->state = MHD_CONNECTION_CLOSED;
+              continue;
+            }
+          do_fd_set (fd, read_fd_set, max_fd);
+          /* transition to FOOTERS_RECEIVED
+             happens in read handler */
+          break;
+        case MHD_CONNECTION_FOOTERS_RECEIVED:
+          /* no socket action, wait for client
+             to provide response */
+          break;
+        case MHD_CONNECTION_HEADERS_SENDING:
+          /* headers in buffer, keep writing */
+          do_fd_set (fd, write_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_HEADERS_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_NORMAL_BODY_READY:
+          do_fd_set (fd, write_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+          /* not ready, no socket action */
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_READY:
+          do_fd_set (fd, write_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+          /* not ready, no socket action */
+          break;
+        case MHD_CONNECTION_BODY_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_FOOTERS_SENDING:
+          do_fd_set (fd, write_fd_set, max_fd);
+          break;
+        case MHD_CONNECTION_FOOTERS_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_CLOSED:
+          if (connection->socket_fd != -1)
+            connection_close_error (connection);
+          return MHD_YES;       /* do nothing, not even reading */
+        default:
+          EXTRA_CHECK (0);
+        }
+      break;
+    }
   return MHD_YES;
 }
 
@@ -765,9 +748,9 @@
           if (rbuf == NULL)
             {
               excessive_data_handler (connection,
-                                     (connection->url != NULL)
-                                     ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
-                                     : MHD_HTTP_REQUEST_URI_TOO_LONG);
+                                      (connection->url != NULL)
+                                      ? MHD_HTTP_REQUEST_ENTITY_TOO_LARGE
+                                      : MHD_HTTP_REQUEST_URI_TOO_LONG);
             }
           else
             {
@@ -793,7 +776,7 @@
  */
 static int
 connection_add_header (struct MHD_Connection *connection,
-                      char *key, char *value, enum MHD_ValueKind kind)
+                       char *key, char *value, enum MHD_ValueKind kind)
 {
   struct MHD_HTTP_Header *hdr;
 
@@ -805,8 +788,7 @@
       MHD_DLOG (connection->daemon,
                 "Not enough memory to allocate header record!\n");
 #endif
-      excessive_data_handler (connection,
-                             MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
+      excessive_data_handler (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
       return MHD_NO;
     }
   hdr->next = connection->headers_received;
@@ -842,8 +824,7 @@
         }
       MHD_http_unescape (args);
       MHD_http_unescape (equals);
-      if (MHD_NO == connection_add_header (connection,
-                                          args, equals, kind))
+      if (MHD_NO == connection_add_header (connection, args, equals, kind))
         return MHD_NO;
       args = amper;
     }
@@ -874,8 +855,7 @@
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon, "Not enough memory to parse cookies!\n");
 #endif
-      excessive_data_handler (connection,
-                             MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
+      excessive_data_handler (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
       return MHD_NO;
     }
   memcpy (cpy, hdr, strlen (hdr) + 1);
@@ -911,7 +891,7 @@
           equals++;
         }
       if (MHD_NO == connection_add_header (connection,
-                                          pos, equals, MHD_COOKIE_KIND))
+                                           pos, equals, MHD_COOKIE_KIND))
         return MHD_NO;
       pos = semicolon;
     }
@@ -977,13 +957,13 @@
   int malformed;
 
   if (connection->response != NULL)
-    return; /* already queued a response */
+    return;                     /* already queued a response */
   do
     {
       instant_retry = MHD_NO;
       available = connection->read_buffer_offset;
-      if ( (connection->have_chunked_upload == MHD_YES) &&
-          (connection->remaining_upload_size == -1) )
+      if ((connection->have_chunked_upload == MHD_YES) &&
+          (connection->remaining_upload_size == -1))
         {
           if ((connection->current_chunk_offset ==
                connection->current_chunk_size)
@@ -1044,16 +1024,17 @@
                 }
               if (i >= available)
                 return;         /* need more data... */
-             malformed = (i >= 6);
-             if (! malformed) 
-               {
+              malformed = (i >= 6);
+              if (!malformed)
+                {
                   connection->read_buffer[i] = '\0';
-                 malformed = (1 != sscanf (connection->read_buffer,
-                                           "%X",
-                                           &connection->current_chunk_size)) &&
-                   (1 != sscanf (connection->read_buffer,
-                                 "%x", &connection->current_chunk_size));      
          
-               }
+                  malformed = (1 != sscanf (connection->read_buffer,
+                                            "%X",
+                                            &connection->current_chunk_size))
+                    && (1 !=
+                        sscanf (connection->read_buffer, "%x",
+                                &connection->current_chunk_size));
+                }
               if (malformed)
                 {
                   /* malformed encoding */
@@ -1088,13 +1069,15 @@
           available = 0;
         }
       used = processed;
-      if (MHD_NO == connection->daemon->default_handler 
(connection->daemon->default_handler_cls,
-                            connection,
-                            connection->url,
-                            connection->method,
-                            connection->version,
-                            connection->read_buffer, &processed,
-                            &connection->client_context))
+      if (MHD_NO ==
+          connection->daemon->default_handler (connection->daemon->
+                                               default_handler_cls,
+                                               connection, connection->url,
+                                               connection->method,
+                                               connection->version,
+                                               connection->read_buffer,
+                                               &processed,
+                                               &connection->client_context))
         {
           /* serious internal error, close connection */
 #if HAVE_MESSAGES
@@ -1105,7 +1088,7 @@
           return;
         }
       if (processed > used)
-       abort(); /* fatal client API violation! */
+        abort ();               /* fatal client API violation! */
       if (processed != 0)
         instant_retry = MHD_NO; /* client did not process everything */
       used -= processed;
@@ -1117,7 +1100,7 @@
                  &connection->read_buffer[used], processed + available);
       if (connection->remaining_upload_size != -1)
         connection->remaining_upload_size -= used;
-      connection->read_buffer_offset = processed + available;      
+      connection->read_buffer_offset = processed + available;
     }
   while (instant_retry == MHD_YES);
 }
@@ -1131,10 +1114,10 @@
  *                no space was available
  */
 static int
-do_read(struct MHD_Connection * connection)
+do_read (struct MHD_Connection *connection)
 {
   int bytes_read;
-  
+
   if (connection->read_buffer_size == connection->read_buffer_offset)
     return MHD_NO;
   bytes_read = RECV (connection->socket_fd,
@@ -1168,8 +1151,7 @@
  * to process.
  */
 static void
-process_header_line(struct MHD_Connection * connection,
-                   char * line) 
+process_header_line (struct MHD_Connection *connection, char *line)
 {
   char *colon;
 
@@ -1180,14 +1162,14 @@
       /* error in header line, die hard */
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon,
-               "Received malformed line (no colon), closing connection.\n");
+                "Received malformed line (no colon), closing connection.\n");
 #endif
       connection->state = MHD_CONNECTION_CLOSED;
       return;
     }
   /* zero-terminate header */
   colon[0] = '\0';
-  colon++;                  /* advance to value */
+  colon++;                      /* advance to value */
   while ((colon[0] != '\0') && ((colon[0] == ' ') || (colon[0] == '\t')))
     colon++;
   /* we do the actual adding of the connection
@@ -1201,55 +1183,50 @@
 
 /**
  * Process a header value that spans multiple lines.
- * The previous line(s) are in connection->last.  
+ * The previous line(s) are in connection->last.
  *
  * @param line the current input line
  * @param kind if the line is complete, add a header
  *        of the given kind
  */
 static void
-process_broken_line(struct MHD_Connection * connection,
-                   char * line,
-                   enum MHD_ValueKind kind) 
+process_broken_line (struct MHD_Connection *connection,
+                     char *line, enum MHD_ValueKind kind)
 {
-  char * last;
-  char * tmp;
+  char *last;
+  char *tmp;
 
   last = connection->last;
   if ((line[0] == ' ') || (line[0] == '\t'))
     {
       /* value was continued on the next line, see
-        http://www.jmarshall.com/easy/http/ */
+         http://www.jmarshall.com/easy/http/ */
       last = MHD_pool_reallocate (connection->pool,
-                                 last,
-                                 strlen (last) + 1,
-                                 strlen (line) + strlen (last) + 1);
+                                  last,
+                                  strlen (last) + 1,
+                                  strlen (line) + strlen (last) + 1);
       if (last == NULL)
-       {
-         excessive_data_handler (connection,
-                                 MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
-         return;
-       }
+        {
+          excessive_data_handler (connection,
+                                  MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
+          return;
+        }
       tmp = line;
       while ((tmp[0] == ' ') || (tmp[0] == '\t'))
-       tmp++;          /* skip whitespace at start of 2nd line */
+        tmp++;                  /* skip whitespace at start of 2nd line */
       strcat (last, tmp);
       connection->last = last;
-      return;         /* possibly more than 2 lines... */
+      return;                   /* possibly more than 2 lines... */
     }
   if (MHD_NO == connection_add_header (connection,
-                                      last,
-                                      connection->colon,
-                                      kind))
+                                       last, connection->colon, kind))
     {
-      excessive_data_handler (connection,
-                             MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
+      excessive_data_handler (connection, MHD_HTTP_REQUEST_ENTITY_TOO_LARGE);
       return;
     }
   /* we still have the current line to deal with... */
-  if (strlen(line) != 0)
-    process_header_line(connection,
-                       line);
+  if (strlen (line) != 0)
+    process_header_line (connection, line);
 }
 
 /**
@@ -1258,7 +1235,7 @@
  * the protocol.  Advance to the appropriate state.
  */
 static void
-parse_connection_headers(struct MHD_Connection * connection)
+parse_connection_headers (struct MHD_Connection *connection)
 {
   const char *clen;
   unsigned long long cval;
@@ -1269,63 +1246,61 @@
       && (NULL != connection->version)
       && (0 == strcasecmp (MHD_HTTP_VERSION_1_1, connection->version))
       && (NULL ==
-         MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
-                                      MHD_HTTP_HEADER_HOST)))
+          MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+                                       MHD_HTTP_HEADER_HOST)))
     {
       /* die, http 1.1 request without host and we are pedantic */
       connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
       connection->read_closed = MHD_YES;
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon,
-               "Received `%s' request without `%s' header.\n",
-               MHD_HTTP_VERSION_1_1, MHD_HTTP_HEADER_HOST);
+                "Received `%s' request without `%s' header.\n",
+                MHD_HTTP_VERSION_1_1, MHD_HTTP_HEADER_HOST);
 #endif
       response =
-       MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST),
-                                      REQUEST_LACKS_HOST, MHD_NO,
-                                      MHD_NO);
+        MHD_create_response_from_data (strlen (REQUEST_LACKS_HOST),
+                                       REQUEST_LACKS_HOST, MHD_NO, MHD_NO);
       MHD_queue_response (connection, MHD_HTTP_BAD_REQUEST, response);
       MHD_destroy_response (response);
       return;
     }
 
   clen = MHD_lookup_connection_value (connection,
-                                     MHD_HEADER_KIND,
-                                     MHD_HTTP_HEADER_CONTENT_LENGTH);
+                                      MHD_HEADER_KIND,
+                                      MHD_HTTP_HEADER_CONTENT_LENGTH);
   if (clen != NULL)
     {
       if (1 != sscanf (clen, "%llu", &cval))
-       {
+        {
 #if HAVE_MESSAGES
-         MHD_DLOG (connection->daemon,
-                   "Failed to parse `%s' header `%s', closing connection.\n",
-                   MHD_HTTP_HEADER_CONTENT_LENGTH, clen);
+          MHD_DLOG (connection->daemon,
+                    "Failed to parse `%s' header `%s', closing connection.\n",
+                    MHD_HTTP_HEADER_CONTENT_LENGTH, clen);
 #endif
-         connection->state = MHD_CONNECTION_CLOSED;
-         return;
-       }
+          connection->state = MHD_CONNECTION_CLOSED;
+          return;
+        }
       connection->remaining_upload_size = cval;
     }
   else
     {
       if (NULL == MHD_lookup_connection_value (connection,
-                                              MHD_HEADER_KIND,
-                                              
MHD_HTTP_HEADER_TRANSFER_ENCODING))
-       {
-         /* this request does not have a body */
-         connection->remaining_upload_size = 0;
-       }
+                                               MHD_HEADER_KIND,
+                                               
MHD_HTTP_HEADER_TRANSFER_ENCODING))
+        {
+          /* this request does not have a body */
+          connection->remaining_upload_size = 0;
+        }
       else
-       {
-         connection->remaining_upload_size = -1;   /* unknown size */
-         if (0 ==
-             strcasecmp (MHD_lookup_connection_value
-                         (connection, MHD_HEADER_KIND,
-                          MHD_HTTP_HEADER_TRANSFER_ENCODING),
-                         "chunked"))
-           connection->have_chunked_upload = MHD_YES;  
-       }
-    }  
+        {
+          connection->remaining_upload_size = -1;       /* unknown size */
+          if (0 ==
+              strcasecmp (MHD_lookup_connection_value
+                          (connection, MHD_HEADER_KIND,
+                           MHD_HTTP_HEADER_TRANSFER_ENCODING), "chunked"))
+            connection->have_chunked_upload = MHD_YES;
+        }
+    }
 }
 
 /**
@@ -1333,57 +1308,55 @@
  * determined that there is data to be read off a socket. All
  * implementations (multithreaded, external select, internal select)
  * call this function to handle reads.
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
 int
 MHD_connection_handle_read (struct MHD_Connection *connection)
 {
-  connection->last_activity = time(NULL);
-  if (connection->state == MHD_CONNECTION_CLOSED) 
+  connection->last_activity = time (NULL);
+  if (connection->state == MHD_CONNECTION_CLOSED)
     return MHD_NO;
-  if (MHD_NO == do_read(connection))
+  if (MHD_NO == do_read (connection))
     return MHD_YES;
-  while (1) {
+  while (1)
+    {
 #if DEBUG_STATES
-    fprintf(stderr,
-           "`%s' in state %u\n",
-           __FUNCTION__,
-           connection->state);
-#endif    
-    switch (connection->state)
-      {
-      case MHD_CONNECTION_INIT:
-      case MHD_CONNECTION_URL_RECEIVED:
-      case MHD_CONNECTION_HEADER_PART_RECEIVED:
-      case MHD_CONNECTION_HEADERS_RECEIVED:
-      case MHD_CONNECTION_HEADERS_PROCESSED:
-      case MHD_CONNECTION_CONTINUE_SENDING:
-      case MHD_CONNECTION_CONTINUE_SENT:
-      case MHD_CONNECTION_BODY_RECEIVED:
-      case MHD_CONNECTION_FOOTER_PART_RECEIVED:
-       /* nothing to do but default action */
-       if (MHD_YES == connection->read_closed) 
-         {
-           connection->state = MHD_CONNECTION_CLOSED;
-           continue;
-         }
-       break;
-      case MHD_CONNECTION_CLOSED:
-       if (connection->socket_fd != -1)
-         connection_close_error (connection);
-       return MHD_NO;
-      default:
-       /* shrink read buffer to how much is actually used */
-       MHD_pool_reallocate (connection->pool,
-                            connection->read_buffer,
-                            connection->read_buffer_size + 1,
-                            connection->read_buffer_offset);       
-       break;
-      }
-    break;
-  }
+      fprintf (stderr, "`%s' in state %u\n", __FUNCTION__, connection->state);
+#endif
+      switch (connection->state)
+        {
+        case MHD_CONNECTION_INIT:
+        case MHD_CONNECTION_URL_RECEIVED:
+        case MHD_CONNECTION_HEADER_PART_RECEIVED:
+        case MHD_CONNECTION_HEADERS_RECEIVED:
+        case MHD_CONNECTION_HEADERS_PROCESSED:
+        case MHD_CONNECTION_CONTINUE_SENDING:
+        case MHD_CONNECTION_CONTINUE_SENT:
+        case MHD_CONNECTION_BODY_RECEIVED:
+        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+          /* nothing to do but default action */
+          if (MHD_YES == connection->read_closed)
+            {
+              connection->state = MHD_CONNECTION_CLOSED;
+              continue;
+            }
+          break;
+        case MHD_CONNECTION_CLOSED:
+          if (connection->socket_fd != -1)
+            connection_close_error (connection);
+          return MHD_NO;
+        default:
+          /* shrink read buffer to how much is actually used */
+          MHD_pool_reallocate (connection->pool,
+                               connection->read_buffer,
+                               connection->read_buffer_size + 1,
+                               connection->read_buffer_offset);
+          break;
+        }
+      break;
+    }
   return MHD_YES;
 }
 
@@ -1392,35 +1365,34 @@
  * write buffer of the connection.
  *
  * @return MHD_YES if something changed,
- *         MHD_NO if we were interrupted 
+ *         MHD_NO if we were interrupted
  */
 static int
-do_write(struct MHD_Connection * connection)
+do_write (struct MHD_Connection *connection)
 {
   int ret;
 
   ret = SEND (connection->socket_fd,
-             &connection->write_buffer[connection->
-                                       write_buffer_send_offset],
-             connection->write_buffer_append_offset -
-             connection->write_buffer_send_offset, MSG_NOSIGNAL);
+              &connection->write_buffer[connection->
+                                        write_buffer_send_offset],
+              connection->write_buffer_append_offset -
+              connection->write_buffer_send_offset, MSG_NOSIGNAL);
   if (ret < 0)
     {
       if (errno == EINTR)
-       return MHD_NO;
+        return MHD_NO;
 #if HAVE_MESSAGES
       MHD_DLOG (connection->daemon,
-               "Failed to send data: %s\n", STRERROR (errno));
+                "Failed to send data: %s\n", STRERROR (errno));
 #endif
       connection_close_error (connection);
       return MHD_YES;
     }
 #if DEBUG_SEND_DATA
   fprintf (stderr,
-          "Sent HEADER response: `%.*s'\n",
-          ret,
-          &connection->write_buffer[connection->
-                                    write_buffer_send_offset]);
+           "Sent HEADER response: `%.*s'\n",
+           ret,
+           &connection->write_buffer[connection->write_buffer_send_offset]);
 #endif
   connection->write_buffer_send_offset += ret;
   return MHD_YES;
@@ -1432,18 +1404,18 @@
  * @return MHY_NO if we are not done, MHD_YES if we are
  */
 static int
-check_write_done(struct MHD_Connection * connection,
-                enum MHD_CONNECTION_STATE next_state)
+check_write_done (struct MHD_Connection *connection,
+                  enum MHD_CONNECTION_STATE next_state)
 {
   if (connection->write_buffer_append_offset !=
       connection->write_buffer_send_offset)
-    return MHD_NO;    
+    return MHD_NO;
   connection->write_buffer_append_offset = 0;
   connection->write_buffer_send_offset = 0;
   connection->state = next_state;
   MHD_pool_reallocate (connection->pool,
-                      connection->write_buffer,
-                      connection->write_buffer_size, 0);
+                       connection->write_buffer,
+                       connection->write_buffer_size, 0);
   connection->write_buffer = NULL;
   connection->write_buffer_size = 0;
   return MHD_YES;
@@ -1454,7 +1426,7 @@
  * been determined that the socket can be written to. All
  * implementations (multithreaded, external select, internal select)
  * call this function
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
@@ -1464,133 +1436,135 @@
   struct MHD_Response *response;
   int ret;
 
-  connection->last_activity = time(NULL);
-  while (1) {
+  connection->last_activity = time (NULL);
+  while (1)
+    {
 #if DEBUG_STATES
-    fprintf(stderr,
-           "`%s' in state %u\n",
-           __FUNCTION__,
-           connection->state);
-#endif    
-    switch (connection->state)
-      {
-      case MHD_CONNECTION_INIT:
-      case MHD_CONNECTION_URL_RECEIVED:
-      case MHD_CONNECTION_HEADER_PART_RECEIVED:
-      case MHD_CONNECTION_HEADERS_RECEIVED:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_HEADERS_PROCESSED:
-       break;
-      case MHD_CONNECTION_CONTINUE_SENDING:
-       ret = SEND (connection->socket_fd,
-                   &HTTP_100_CONTINUE[connection->
-                                      continue_message_write_offset],
-                   strlen (HTTP_100_CONTINUE) -
-                   connection->continue_message_write_offset, MSG_NOSIGNAL);
-       if (ret < 0)
-         {
-           if (errno == EINTR)
-             break;
+      fprintf (stderr, "`%s' in state %u\n", __FUNCTION__, connection->state);
+#endif
+      switch (connection->state)
+        {
+        case MHD_CONNECTION_INIT:
+        case MHD_CONNECTION_URL_RECEIVED:
+        case MHD_CONNECTION_HEADER_PART_RECEIVED:
+        case MHD_CONNECTION_HEADERS_RECEIVED:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_HEADERS_PROCESSED:
+          break;
+        case MHD_CONNECTION_CONTINUE_SENDING:
+          ret = SEND (connection->socket_fd,
+                      &HTTP_100_CONTINUE[connection->
+                                         continue_message_write_offset],
+                      strlen (HTTP_100_CONTINUE) -
+                      connection->continue_message_write_offset,
+                      MSG_NOSIGNAL);
+          if (ret < 0)
+            {
+              if (errno == EINTR)
+                break;
 #if HAVE_MESSAGES
-           MHD_DLOG (connection->daemon,
-                     "Failed to send data: %s\n", STRERROR (errno));
+              MHD_DLOG (connection->daemon,
+                        "Failed to send data: %s\n", STRERROR (errno));
 #endif
-           connection_close_error (connection);
-           return MHD_NO;
-         }
+              connection_close_error (connection);
+              return MHD_NO;
+            }
 #if DEBUG_SEND_DATA
-       fprintf (stderr,
-                "Sent 100 continue response: `%.*s'\n",
-                ret,
-                &HTTP_100_CONTINUE[connection->continue_message_write_offset]);
+          fprintf (stderr,
+                   "Sent 100 continue response: `%.*s'\n",
+                   ret,
+                   &HTTP_100_CONTINUE[connection->
+                                      continue_message_write_offset]);
 #endif
-       connection->continue_message_write_offset += ret;
-       break;
-      case MHD_CONNECTION_CONTINUE_SENT:
-      case MHD_CONNECTION_BODY_RECEIVED:
-      case MHD_CONNECTION_FOOTER_PART_RECEIVED:
-      case MHD_CONNECTION_FOOTERS_RECEIVED:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_HEADERS_SENDING:
-       do_write(connection);
-       check_write_done(connection,
-                        MHD_CONNECTION_HEADERS_SENT);
-       break;
-      case MHD_CONNECTION_HEADERS_SENT:
-       EXTRA_CHECK(0);
-       break;  
-      case MHD_CONNECTION_NORMAL_BODY_READY:
-       response = connection->response;
-       if (response->crc != NULL)
-         pthread_mutex_lock (&response->mutex);
-       if (MHD_YES != try_ready_normal_body(connection))
-         {
-           if (response->crc != NULL)
-             pthread_mutex_unlock (&response->mutex);
-           connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
-           break;
-         }
-       ret = SEND (connection->socket_fd,
-                   &response->data[connection->response_write_position -
-                                   response->data_start],
-                   response->data_size - (connection->response_write_position -
-                                          response->data_start), MSG_NOSIGNAL);
+          connection->continue_message_write_offset += ret;
+          break;
+        case MHD_CONNECTION_CONTINUE_SENT:
+        case MHD_CONNECTION_BODY_RECEIVED:
+        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+        case MHD_CONNECTION_FOOTERS_RECEIVED:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_HEADERS_SENDING:
+          do_write (connection);
+          check_write_done (connection, MHD_CONNECTION_HEADERS_SENT);
+          break;
+        case MHD_CONNECTION_HEADERS_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_NORMAL_BODY_READY:
+          response = connection->response;
+          if (response->crc != NULL)
+            pthread_mutex_lock (&response->mutex);
+          if (MHD_YES != try_ready_normal_body (connection))
+            {
+              if (response->crc != NULL)
+                pthread_mutex_unlock (&response->mutex);
+              connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
+              break;
+            }
+          ret = SEND (connection->socket_fd,
+                      &response->data[connection->response_write_position -
+                                      response->data_start],
+                      response->data_size -
+                      (connection->response_write_position -
+                       response->data_start), MSG_NOSIGNAL);
 #if DEBUG_SEND_DATA
-       if (ret > 0)
-         fprintf (stderr,
-                  "Sent DATA response: `%.*s'\n",
-                  ret,
-                  &response->data[connection->response_write_position -
-                                  response->data_start]);
-#endif 
-       if (response->crc != NULL)
-         pthread_mutex_unlock (&response->mutex);
-       if (ret < 0)
-         {
-           if (errno == EINTR)
-             return MHD_YES;
+          if (ret > 0)
+            fprintf (stderr,
+                     "Sent DATA response: `%.*s'\n",
+                     ret,
+                     &response->data[connection->response_write_position -
+                                     response->data_start]);
+#endif
+          if (response->crc != NULL)
+            pthread_mutex_unlock (&response->mutex);
+          if (ret < 0)
+            {
+              if (errno == EINTR)
+                return MHD_YES;
 #if HAVE_MESSAGES
-           MHD_DLOG (connection->daemon,
-                     "Failed to send data: %s\n", STRERROR (errno));
+              MHD_DLOG (connection->daemon,
+                        "Failed to send data: %s\n", STRERROR (errno));
 #endif
-           connection_close_error (connection);
-           return MHD_NO;
-         }
-       connection->response_write_position += ret;
-       if (connection->response_write_position == 
connection->response->total_size)
-         connection->state = MHD_CONNECTION_FOOTERS_SENT; /* have no 
footers... */
-       break;  
-      case MHD_CONNECTION_NORMAL_BODY_UNREADY:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_READY:
-       do_write(connection);
-       check_write_done(connection,
-                        (connection->response->total_size == 
connection->response_write_position) 
-                        ? MHD_CONNECTION_BODY_SENT
-                        : MHD_CONNECTION_CHUNKED_BODY_UNREADY);
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
-      case MHD_CONNECTION_BODY_SENT:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_FOOTERS_SENDING:
-       do_write(connection);
-       check_write_done(connection,
-                        MHD_CONNECTION_FOOTERS_SENT);
-       break;          
-      case MHD_CONNECTION_FOOTERS_SENT:
-       EXTRA_CHECK(0);
-       break;
-      case MHD_CONNECTION_CLOSED:
-       if (connection->socket_fd != -1) 
-         connection_close_error(connection);     
-       return MHD_NO;
-     }
-    break;
-  }
+              connection_close_error (connection);
+              return MHD_NO;
+            }
+          connection->response_write_position += ret;
+          if (connection->response_write_position ==
+              connection->response->total_size)
+            connection->state = MHD_CONNECTION_FOOTERS_SENT;    /* have no 
footers... */
+          break;
+        case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_READY:
+          do_write (connection);
+          check_write_done (connection,
+                            (connection->response->total_size ==
+                             connection->
+                             response_write_position) ?
+                            MHD_CONNECTION_BODY_SENT :
+                            MHD_CONNECTION_CHUNKED_BODY_UNREADY);
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+        case MHD_CONNECTION_BODY_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_FOOTERS_SENDING:
+          do_write (connection);
+          check_write_done (connection, MHD_CONNECTION_FOOTERS_SENT);
+          break;
+        case MHD_CONNECTION_FOOTERS_SENT:
+          EXTRA_CHECK (0);
+          break;
+        case MHD_CONNECTION_CLOSED:
+          if (connection->socket_fd != -1)
+            connection_close_error (connection);
+          return MHD_NO;
+        }
+      break;
+    }
   return MHD_YES;
 }
 
@@ -1599,7 +1573,7 @@
  * has to happen even if the socket cannot be read or written to.  All
  * implementations (multithreaded, external select, internal select)
  * call this function.
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
@@ -1607,258 +1581,252 @@
 MHD_connection_handle_idle (struct MHD_Connection *connection)
 {
   unsigned int timeout;
-  const char * end;
-  char * line;
+  const char *end;
+  char *line;
 
-  while (1) {
+  while (1)
+    {
 #if DEBUG_STATES
-    fprintf(stderr,
-           "`%s' in state %u\n",
-           __FUNCTION__,
-           connection->state);
-#endif    
-    switch (connection->state)
-      {
-      case MHD_CONNECTION_INIT:
-       line = get_next_header_line(connection);
-       if (line == NULL)
-         break;
-       if (MHD_NO == parse_initial_message_line (connection, line))
-         connection->state = MHD_CONNECTION_CLOSED;
-       else
-         connection->state = MHD_CONNECTION_URL_RECEIVED;
-       continue;
-      case MHD_CONNECTION_URL_RECEIVED:
-       line = get_next_header_line(connection);
-       if (line == NULL)
-         break;
-       if (strlen(line) == 0)
-         {
-           connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
-           continue;
-         }
-       process_header_line(connection, line);
-       connection->state = MHD_CONNECTION_HEADER_PART_RECEIVED;
-       continue;
-      case MHD_CONNECTION_HEADER_PART_RECEIVED:
-       line = get_next_header_line(connection);
-       if (line == NULL)
-         break;
-       process_broken_line(connection,
-                           line,
-                           MHD_HEADER_KIND);
-       if (strlen(line) == 0)
-         {
-           connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
-           continue;
-         }
-       continue;
-      case MHD_CONNECTION_HEADERS_RECEIVED:
-       parse_connection_headers (connection);
-       if (connection->state == MHD_CONNECTION_CLOSED)
-         continue;
-       connection->state = MHD_CONNECTION_HEADERS_PROCESSED;
-       continue;
-      case MHD_CONNECTION_HEADERS_PROCESSED:
-       call_connection_handler (connection); /* first call */
-       if (need_100_continue(connection)) 
-         {
-           connection->state = MHD_CONNECTION_CONTINUE_SENDING;
-           break;
-         }
-       connection->state = (connection->remaining_upload_size == 0)
-         ? MHD_CONNECTION_FOOTERS_RECEIVED 
-         : MHD_CONNECTION_CONTINUE_SENT;
-       continue;
-      case MHD_CONNECTION_CONTINUE_SENDING:
-       if (connection->continue_message_write_offset ==
-           strlen (HTTP_100_CONTINUE))
-         {
-           connection->state = MHD_CONNECTION_CONTINUE_SENT;
-           continue;
-         }
-       break;
-      case MHD_CONNECTION_CONTINUE_SENT:
-       if (connection->read_buffer_offset != 0) {
-         call_connection_handler(connection); /* loop call */
-         if (connection->state == MHD_CONNECTION_CLOSED)
-           continue;
-       }
-       if ( (connection->remaining_upload_size == 0) ||
-            ( (connection->remaining_upload_size == -1) &&
-              (connection->read_buffer_offset == 0) &&
-              (MHD_YES == connection->read_closed) ) )
-         {
-           if ( (MHD_YES == connection->have_chunked_upload) &&
-                (MHD_NO == connection->read_closed) ) 
-             connection->state = MHD_CONNECTION_BODY_RECEIVED;
-           else
-             connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-           continue;
-         }
-       break;
-      case MHD_CONNECTION_BODY_RECEIVED:
-       line = get_next_header_line(connection);
-       if (line == NULL)
-         break;
-       if (strlen(line) == 0)
-         {
-           connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-           continue;
-         }
-       process_header_line(connection, line);
-       connection->state = MHD_CONNECTION_FOOTER_PART_RECEIVED;
-       continue;
-      case MHD_CONNECTION_FOOTER_PART_RECEIVED:
-       line = get_next_header_line(connection);
-       if (line == NULL)
-         break;
-       process_broken_line(connection,
-                           line,
-                           MHD_FOOTER_KIND);
-       if (strlen(line) == 0)
-         {
-           connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
-           continue;
-         }
-       continue;
-      case MHD_CONNECTION_FOOTERS_RECEIVED:    
-       call_connection_handler (connection); /* "final" call */
-       if (connection->state == MHD_CONNECTION_CLOSED)
-         continue;
-       if (connection->response == NULL) 
-         break; /* try again next time */        
-       if (MHD_NO == build_header_response (connection))
-         {
-           /* oops - close! */
+      fprintf (stderr, "`%s' in state %u\n", __FUNCTION__, connection->state);
+#endif
+      switch (connection->state)
+        {
+        case MHD_CONNECTION_INIT:
+          line = get_next_header_line (connection);
+          if (line == NULL)
+            break;
+          if (MHD_NO == parse_initial_message_line (connection, line))
+            connection->state = MHD_CONNECTION_CLOSED;
+          else
+            connection->state = MHD_CONNECTION_URL_RECEIVED;
+          continue;
+        case MHD_CONNECTION_URL_RECEIVED:
+          line = get_next_header_line (connection);
+          if (line == NULL)
+            break;
+          if (strlen (line) == 0)
+            {
+              connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
+              continue;
+            }
+          process_header_line (connection, line);
+          connection->state = MHD_CONNECTION_HEADER_PART_RECEIVED;
+          continue;
+        case MHD_CONNECTION_HEADER_PART_RECEIVED:
+          line = get_next_header_line (connection);
+          if (line == NULL)
+            break;
+          process_broken_line (connection, line, MHD_HEADER_KIND);
+          if (strlen (line) == 0)
+            {
+              connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
+              continue;
+            }
+          continue;
+        case MHD_CONNECTION_HEADERS_RECEIVED:
+          parse_connection_headers (connection);
+          if (connection->state == MHD_CONNECTION_CLOSED)
+            continue;
+          connection->state = MHD_CONNECTION_HEADERS_PROCESSED;
+          continue;
+        case MHD_CONNECTION_HEADERS_PROCESSED:
+          call_connection_handler (connection); /* first call */
+          if (need_100_continue (connection))
+            {
+              connection->state = MHD_CONNECTION_CONTINUE_SENDING;
+              break;
+            }
+          connection->state = (connection->remaining_upload_size == 0)
+            ? MHD_CONNECTION_FOOTERS_RECEIVED : MHD_CONNECTION_CONTINUE_SENT;
+          continue;
+        case MHD_CONNECTION_CONTINUE_SENDING:
+          if (connection->continue_message_write_offset ==
+              strlen (HTTP_100_CONTINUE))
+            {
+              connection->state = MHD_CONNECTION_CONTINUE_SENT;
+              continue;
+            }
+          break;
+        case MHD_CONNECTION_CONTINUE_SENT:
+          if (connection->read_buffer_offset != 0)
+            {
+              call_connection_handler (connection);     /* loop call */
+              if (connection->state == MHD_CONNECTION_CLOSED)
+                continue;
+            }
+          if ((connection->remaining_upload_size == 0) ||
+              ((connection->remaining_upload_size == -1) &&
+               (connection->read_buffer_offset == 0) &&
+               (MHD_YES == connection->read_closed)))
+            {
+              if ((MHD_YES == connection->have_chunked_upload) &&
+                  (MHD_NO == connection->read_closed))
+                connection->state = MHD_CONNECTION_BODY_RECEIVED;
+              else
+                connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+              continue;
+            }
+          break;
+        case MHD_CONNECTION_BODY_RECEIVED:
+          line = get_next_header_line (connection);
+          if (line == NULL)
+            break;
+          if (strlen (line) == 0)
+            {
+              connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+              continue;
+            }
+          process_header_line (connection, line);
+          connection->state = MHD_CONNECTION_FOOTER_PART_RECEIVED;
+          continue;
+        case MHD_CONNECTION_FOOTER_PART_RECEIVED:
+          line = get_next_header_line (connection);
+          if (line == NULL)
+            break;
+          process_broken_line (connection, line, MHD_FOOTER_KIND);
+          if (strlen (line) == 0)
+            {
+              connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
+              continue;
+            }
+          continue;
+        case MHD_CONNECTION_FOOTERS_RECEIVED:
+          call_connection_handler (connection); /* "final" call */
+          if (connection->state == MHD_CONNECTION_CLOSED)
+            continue;
+          if (connection->response == NULL)
+            break;              /* try again next time */
+          if (MHD_NO == build_header_response (connection))
+            {
+              /* oops - close! */
 #if HAVE_MESSAGES
-           MHD_DLOG (connection->daemon,
-                     "Closing connection (failed to create response 
header)\n");
+              MHD_DLOG (connection->daemon,
+                        "Closing connection (failed to create response 
header)\n");
 #endif
-           connection->state = MHD_CONNECTION_CLOSED;
-           continue;           
-         }
-       connection->state = MHD_CONNECTION_HEADERS_SENDING;
-       break;
-      case MHD_CONNECTION_HEADERS_SENDING:
-       /* no default action */
-       break;
-      case MHD_CONNECTION_HEADERS_SENT:
-       if (connection->have_chunked_upload)
-         connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
-       else
-         connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
-       continue;
-      case MHD_CONNECTION_NORMAL_BODY_READY:
-       /* nothing to do here */
-       break;
-      case MHD_CONNECTION_NORMAL_BODY_UNREADY:
-       if (connection->response->crc != NULL)
-         pthread_mutex_lock (&connection->response->mutex);
-       if (MHD_YES == try_ready_normal_body(connection))
-         {
-           if (connection->response->crc != NULL)
-             pthread_mutex_unlock (&connection->response->mutex);
-           connection->state = MHD_CONNECTION_NORMAL_BODY_READY;
-           break;
-         }     
-       if (connection->response->crc != NULL)
-         pthread_mutex_unlock (&connection->response->mutex);
-       /* not ready, no socket action */
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_READY:
-       /* nothing to do here */
-       break;
-      case MHD_CONNECTION_CHUNKED_BODY_UNREADY:        
-       if (connection->response->crc != NULL)
-         pthread_mutex_lock (&connection->response->mutex);
-       if (MHD_YES == try_ready_chunked_body(connection))
-         {
-           if (connection->response->crc != NULL)
-             pthread_mutex_unlock (&connection->response->mutex);
-           connection->state = MHD_CONNECTION_CHUNKED_BODY_READY;
-           continue;
-         }
-       if (connection->response->crc != NULL)
-         pthread_mutex_unlock (&connection->response->mutex);
-       break;
-      case MHD_CONNECTION_BODY_SENT:
-       build_header_response(connection);
-       if (connection->write_buffer_send_offset  == 
connection->write_buffer_append_offset)
-         connection->state = MHD_CONNECTION_FOOTERS_SENT;
-       else
-         connection->state = MHD_CONNECTION_FOOTERS_SENDING;
-       continue;
-      case MHD_CONNECTION_FOOTERS_SENDING:
-       /* no default action */
-       break;
-      case MHD_CONNECTION_FOOTERS_SENT:
-       MHD_destroy_response (connection->response);
-       if (connection->daemon->notify_completed != NULL)
-         connection->daemon->notify_completed (connection->daemon->
-                                               notify_completed_cls,
-                                               connection,
-                                               &connection->client_context,
-                                               
MHD_REQUEST_TERMINATED_COMPLETED_OK);
-       end = MHD_lookup_connection_value (connection,
-                                          MHD_HEADER_KIND,
-                                          MHD_HTTP_HEADER_CONNECTION);
-       connection->client_context = NULL;
-       connection->continue_message_write_offset = 0;
-       connection->responseCode = 0;
-       connection->response = NULL;
-       connection->headers_received = NULL;
-       connection->response_write_position = 0;
-       connection->have_chunked_upload = MHD_NO;
-       connection->method = NULL;
-       connection->url = NULL;
-       connection->write_buffer = NULL;
-       connection->write_buffer_size = 0;
-       connection->write_buffer_send_offset = 0;
-       connection->write_buffer_append_offset = 0;
-       if ((end != NULL) && (0 == strcasecmp (end, "close")))
-         {
-           connection->read_closed = MHD_YES;    
-           connection->read_buffer_offset = 0;
-         }
-       if ( ( (MHD_YES == connection->read_closed) &&
-              (0 == connection->read_buffer_offset) ) ||
-            (connection->version == NULL) ||
-            (0 != strcasecmp (MHD_HTTP_VERSION_1_1, connection->version)) )
-         {
-           connection->state = MHD_CONNECTION_CLOSED;
-           MHD_pool_destroy (connection->pool);
-           connection->pool = NULL; 
-           connection->read_buffer = NULL;
-           connection->read_buffer_size = 0;
-           connection->read_buffer_offset = 0;
-         }
-       else
-         {             
-           connection->version = NULL;
-           connection->state = MHD_CONNECTION_INIT;
-           connection->read_buffer 
-             = MHD_pool_reset(connection->pool,
-                              connection->read_buffer,
-                              connection->read_buffer_size);
-         }
-       continue;
-      case MHD_CONNECTION_CLOSED:
-       if (connection->socket_fd != -1)
-         connection_close_error (connection);
-       break;
-      default:
-       EXTRA_CHECK(0);
-       break;
-      }
-    break;
-  } 
+              connection->state = MHD_CONNECTION_CLOSED;
+              continue;
+            }
+          connection->state = MHD_CONNECTION_HEADERS_SENDING;
+          break;
+        case MHD_CONNECTION_HEADERS_SENDING:
+          /* no default action */
+          break;
+        case MHD_CONNECTION_HEADERS_SENT:
+          if (connection->have_chunked_upload)
+            connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
+          else
+            connection->state = MHD_CONNECTION_NORMAL_BODY_UNREADY;
+          continue;
+        case MHD_CONNECTION_NORMAL_BODY_READY:
+          /* nothing to do here */
+          break;
+        case MHD_CONNECTION_NORMAL_BODY_UNREADY:
+          if (connection->response->crc != NULL)
+            pthread_mutex_lock (&connection->response->mutex);
+          if (MHD_YES == try_ready_normal_body (connection))
+            {
+              if (connection->response->crc != NULL)
+                pthread_mutex_unlock (&connection->response->mutex);
+              connection->state = MHD_CONNECTION_NORMAL_BODY_READY;
+              break;
+            }
+          if (connection->response->crc != NULL)
+            pthread_mutex_unlock (&connection->response->mutex);
+          /* not ready, no socket action */
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_READY:
+          /* nothing to do here */
+          break;
+        case MHD_CONNECTION_CHUNKED_BODY_UNREADY:
+          if (connection->response->crc != NULL)
+            pthread_mutex_lock (&connection->response->mutex);
+          if (MHD_YES == try_ready_chunked_body (connection))
+            {
+              if (connection->response->crc != NULL)
+                pthread_mutex_unlock (&connection->response->mutex);
+              connection->state = MHD_CONNECTION_CHUNKED_BODY_READY;
+              continue;
+            }
+          if (connection->response->crc != NULL)
+            pthread_mutex_unlock (&connection->response->mutex);
+          break;
+        case MHD_CONNECTION_BODY_SENT:
+          build_header_response (connection);
+          if (connection->write_buffer_send_offset ==
+              connection->write_buffer_append_offset)
+            connection->state = MHD_CONNECTION_FOOTERS_SENT;
+          else
+            connection->state = MHD_CONNECTION_FOOTERS_SENDING;
+          continue;
+        case MHD_CONNECTION_FOOTERS_SENDING:
+          /* no default action */
+          break;
+        case MHD_CONNECTION_FOOTERS_SENT:
+          MHD_destroy_response (connection->response);
+          if (connection->daemon->notify_completed != NULL)
+            connection->daemon->notify_completed (connection->daemon->
+                                                  notify_completed_cls,
+                                                  connection,
+                                                  &connection->client_context,
+                                                  
MHD_REQUEST_TERMINATED_COMPLETED_OK);
+          end = MHD_lookup_connection_value (connection,
+                                             MHD_HEADER_KIND,
+                                             MHD_HTTP_HEADER_CONNECTION);
+          connection->client_context = NULL;
+          connection->continue_message_write_offset = 0;
+          connection->responseCode = 0;
+          connection->response = NULL;
+          connection->headers_received = NULL;
+          connection->response_write_position = 0;
+          connection->have_chunked_upload = MHD_NO;
+          connection->method = NULL;
+          connection->url = NULL;
+          connection->write_buffer = NULL;
+          connection->write_buffer_size = 0;
+          connection->write_buffer_send_offset = 0;
+          connection->write_buffer_append_offset = 0;
+          if ((end != NULL) && (0 == strcasecmp (end, "close")))
+            {
+              connection->read_closed = MHD_YES;
+              connection->read_buffer_offset = 0;
+            }
+          if (((MHD_YES == connection->read_closed) &&
+               (0 == connection->read_buffer_offset)) ||
+              (connection->version == NULL) ||
+              (0 != strcasecmp (MHD_HTTP_VERSION_1_1, connection->version)))
+            {
+              connection->state = MHD_CONNECTION_CLOSED;
+              MHD_pool_destroy (connection->pool);
+              connection->pool = NULL;
+              connection->read_buffer = NULL;
+              connection->read_buffer_size = 0;
+              connection->read_buffer_offset = 0;
+            }
+          else
+            {
+              connection->version = NULL;
+              connection->state = MHD_CONNECTION_INIT;
+              connection->read_buffer
+                = MHD_pool_reset (connection->pool,
+                                  connection->read_buffer,
+                                  connection->read_buffer_size);
+            }
+          continue;
+        case MHD_CONNECTION_CLOSED:
+          if (connection->socket_fd != -1)
+            connection_close_error (connection);
+          break;
+        default:
+          EXTRA_CHECK (0);
+          break;
+        }
+      break;
+    }
   timeout = connection->daemon->connection_timeout;
-  if ( (timeout != 0) &&
-       (time(NULL) - timeout > connection->last_activity) )
+  if ((timeout != 0) && (time (NULL) - timeout > connection->last_activity))
     {
       connection_close_error (connection);
-      return MHD_NO;  
+      return MHD_NO;
     }
   return MHD_YES;
 

Modified: libmicrohttpd/src/daemon/connection.h
===================================================================
--- libmicrohttpd/src/daemon/connection.h       2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/connection.h       2007-12-20 04:45:24 UTC (rev 
5982)
@@ -44,7 +44,7 @@
  * determined that there is data to be read off a socket. All implementations
  * (multithreaded, external select, internal select) call this function
  * to handle reads.
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
@@ -56,7 +56,7 @@
  * determined that the socket can be written to. If there is no data
  * to be written, however, the function call does nothing. All implementations
  * (multithreaded, external select, internal select) call this function
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
@@ -68,11 +68,10 @@
  * has to happen even if the socket cannot be read or written to.  All
  * implementations (multithreaded, external select, internal select)
  * call this function.
- * 
+ *
  * @return MHD_YES if we should continue to process the
  *         connection (not dead yet), MHD_NO if it died
  */
-int
-MHD_connection_handle_idle (struct MHD_Connection *connection);
-  
+int MHD_connection_handle_idle (struct MHD_Connection *connection);
+
 #endif

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2007-12-20 04:23:05 UTC (rev 5981)
+++ libmicrohttpd/src/daemon/daemon.c   2007-12-20 04:45:24 UTC (rev 5982)
@@ -42,13 +42,13 @@
 
 /**
  * Print extra messages with reasons for closing
- * sockets? (only adds non-error messages). 
+ * sockets? (only adds non-error messages).
  */
 #define DEBUG_CLOSE MHD_NO
 
 /**
  * Print extra messages when establishing
- * connections? (only adds non-error messages). 
+ * connections? (only adds non-error messages).
  */
 #define DEBUG_CONNECT MHD_NO
 
@@ -116,20 +116,19 @@
   if (con == NULL)
     abort ();
   timeout = con->daemon->connection_timeout;
-  while ( (!con->daemon->shutdown) &&
-         (con->socket_fd != -1) )
+  while ((!con->daemon->shutdown) && (con->socket_fd != -1))
     {
       FD_ZERO (&rs);
       FD_ZERO (&ws);
       FD_ZERO (&es);
       max = 0;
       MHD_connection_get_fdset (con, &rs, &ws, &es, &max);
-      now = time(NULL);      
+      now = time (NULL);
       tv.tv_usec = 0;
-      if ( timeout > (now - con->last_activity) )
-       tv.tv_sec = timeout - (now - con->last_activity);
+      if (timeout > (now - con->last_activity))
+        tv.tv_sec = timeout - (now - con->last_activity);
       else
-       tv.tv_sec = 0;
+        tv.tv_sec = 0;
       num_ready = SELECT (max + 1,
                           &rs, &ws, &es, (timeout != 0) ? &tv : NULL);
       if (num_ready < 0)
@@ -143,12 +142,11 @@
           break;
         }
       if (FD_ISSET (con->socket_fd, &rs))
-          MHD_connection_handle_read (con);
-      if ((con->socket_fd != -1) &&
-          (FD_ISSET (con->socket_fd, &ws)) )
-       MHD_connection_handle_write (con);
-      if (con->socket_fd != -1) 
-       MHD_connection_handle_idle (con);
+        MHD_connection_handle_read (con);
+      if ((con->socket_fd != -1) && (FD_ISSET (con->socket_fd, &ws)))
+        MHD_connection_handle_write (con);
+      if (con->socket_fd != -1)
+        MHD_connection_handle_idle (con);
     }
   if (con->socket_fd != -1)
     {
@@ -309,7 +307,7 @@
               pthread_kill (pos->pid, SIGALRM);
               pthread_join (pos->pid, &unused);
             }
-         MHD_destroy_response (pos->response);
+          MHD_destroy_response (pos->response);
           MHD_pool_destroy (pos->pool);
           free (pos->addr);
           free (pos);
@@ -455,12 +453,11 @@
           if (ds != -1)
             {
               if (FD_ISSET (ds, &rs))
-               MHD_connection_handle_read (pos); 
-             if ( (pos->socket_fd != -1) &&
-                  (FD_ISSET (ds, &ws)) )
-               MHD_connection_handle_write (pos);
-             if (pos->socket_fd != -1)
-               MHD_connection_handle_idle(pos); 
+                MHD_connection_handle_read (pos);
+              if ((pos->socket_fd != -1) && (FD_ISSET (ds, &ws)))
+                MHD_connection_handle_write (pos);
+              if (pos->socket_fd != -1)
+                MHD_connection_handle_idle (pos);
             }
           pos = pos->next;
         }

Modified: libmicrohttpd/src/daemon/daemontest_get.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_get.c   2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/daemontest_get.c   2007-12-20 04:45:24 UTC (rev 
5982)
@@ -73,17 +73,18 @@
 
   if (0 != strcmp (me, method))
     return MHD_NO;              /* unexpected method */
-  if (&ptr != *unused) {
-    *unused = &ptr;
-    return MHD_YES;
-  }
+  if (&ptr != *unused)
+    {
+      *unused = &ptr;
+      return MHD_YES;
+    }
   *unused = NULL;
   response = MHD_create_response_from_data (strlen (url),
                                             (void *) url, MHD_NO, MHD_YES);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   if (ret == MHD_NO)
-    abort();
+    abort ();
   return ret;
 }
 

Modified: libmicrohttpd/src/daemon/daemontest_large_put.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_large_put.c     2007-12-20 04:23:05 UTC 
(rev 5981)
+++ libmicrohttpd/src/daemon/daemontest_large_put.c     2007-12-20 04:45:24 UTC 
(rev 5982)
@@ -96,16 +96,15 @@
     return MHD_NO;              /* unexpected method */
   if ((*done) == 0)
     {
-      if (*upload_data_size != PUT_SIZE) 
-       {
+      if (*upload_data_size != PUT_SIZE)
+        {
 #if 0
-         fprintf(stderr,
-                 "Waiting for more data (%u/%u)...\n",
-                 *upload_data_size,
-                 PUT_SIZE);
+          fprintf (stderr,
+                   "Waiting for more data (%u/%u)...\n",
+                   *upload_data_size, PUT_SIZE);
 #endif
-         return MHD_YES;         /* not yet ready */
-       }
+          return MHD_YES;       /* not yet ready */
+        }
       if (0 == memcmp (upload_data, put_buffer, PUT_SIZE))
         {
           *upload_data_size = 0;
@@ -236,10 +235,7 @@
   MHD_stop_daemon (d);
   if (cbc.pos != strlen ("/hello_world"))
     {
-      fprintf(stderr,
-             "Got invalid response `%.*s'\n",
-             cbc.pos,
-             cbc.buf);
+      fprintf (stderr, "Got invalid response `%.*s'\n", cbc.pos, cbc.buf);
       return 64;
     }
   if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
@@ -274,10 +270,9 @@
   multi = NULL;
   d = MHD_start_daemon (MHD_USE_DEBUG,
                         1082,
-                        NULL, NULL, &ahc_echo, &done_flag, 
-                       MHD_OPTION_CONNECTION_MEMORY_LIMIT,
-                       PUT_SIZE * 4,
-                       MHD_OPTION_END);
+                        NULL, NULL, &ahc_echo, &done_flag,
+                        MHD_OPTION_CONNECTION_MEMORY_LIMIT,
+                        PUT_SIZE * 4, MHD_OPTION_END);
   if (d == NULL)
     return 256;
   c = curl_easy_init ();
@@ -375,10 +370,7 @@
   MHD_stop_daemon (d);
   if (cbc.pos != strlen ("/hello_world"))
     {
-      fprintf(stderr,
-             "Got invalid response `%.*s'\n",
-             cbc.pos,
-             cbc.buf);
+      fprintf (stderr, "Got invalid response `%.*s'\n", cbc.pos, cbc.buf);
       return 8192;
     }
   if (0 != strncmp ("/hello_world", cbc.buf, strlen ("/hello_world")))
@@ -403,7 +395,7 @@
       errorCount += testInternalPut ();
       errorCount += testMultithreadedPut ();
     }
-  errorCount += testExternalPut (); 
+  errorCount += testExternalPut ();
   free (put_buffer);
   if (errorCount != 0)
     fprintf (stderr, "Error (code: %u)\n", errorCount);

Modified: libmicrohttpd/src/daemon/daemontest_post_loop.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_post_loop.c     2007-12-20 04:23:05 UTC 
(rev 5981)
+++ libmicrohttpd/src/daemon/daemontest_post_loop.c     2007-12-20 04:45:24 UTC 
(rev 5982)
@@ -311,7 +311,7 @@
               MHD_stop_daemon (d);
               return 2048;
             }
-         if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
+          if (MHD_YES != MHD_get_fdset (d, &rs, &ws, &es, &max))
             {
               curl_multi_remove_handle (multi, c);
               curl_multi_cleanup (multi);
@@ -320,7 +320,7 @@
               return 4096;
             }
           if (MHD_NO == MHD_get_timeout (d, &timeout))
-            timeout = 100;  /* 100ms == INFTY -- CURL bug... */
+            timeout = 100;      /* 100ms == INFTY -- CURL bug... */
           if ((CURLM_OK == curl_multi_timeout (multi, &ctimeout)) &&
               (ctimeout < timeout) && (ctimeout >= 0))
             timeout = ctimeout;

Modified: libmicrohttpd/src/daemon/daemontest_postform.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_postform.c      2007-12-20 04:23:05 UTC 
(rev 5981)
+++ libmicrohttpd/src/daemon/daemontest_postform.c      2007-12-20 04:45:24 UTC 
(rev 5982)
@@ -73,11 +73,7 @@
   int *eok = cls;
 
 #if 0
-  fprintf(stderr,
-         "PI sees %s-%.*s\n",
-         key,
-         size,
-         value);
+  fprintf (stderr, "PI sees %s-%.*s\n", key, size, value);
 #endif
   if ((0 == strcmp (key, "name")) &&
       (size == strlen ("daniel")) && (0 == strncmp (value, "daniel", size)))
@@ -102,7 +98,7 @@
   struct MHD_PostProcessor *pp;
   int ret;
 
-  if (0 != strcmp ("POST", method)) 
+  if (0 != strcmp ("POST", method))
     {
       printf ("METHOD: %s\n", method);
       return MHD_NO;            /* unexpected method */

Modified: libmicrohttpd/src/daemon/daemontest_put_chunked.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_put_chunked.c   2007-12-20 04:23:05 UTC 
(rev 5981)
+++ libmicrohttpd/src/daemon/daemontest_put_chunked.c   2007-12-20 04:45:24 UTC 
(rev 5982)
@@ -106,9 +106,7 @@
           return MHD_NO;
         }
 #if 0
-      fprintf(stderr,
-             "Not ready for response: %u/%u\n",
-             *done, 8);
+      fprintf (stderr, "Not ready for response: %u/%u\n", *done, 8);
 #endif
       return MHD_YES;
     }

Modified: libmicrohttpd/src/daemon/fileserver_example.c
===================================================================
--- libmicrohttpd/src/daemon/fileserver_example.c       2007-12-20 04:23:05 UTC 
(rev 5981)
+++ libmicrohttpd/src/daemon/fileserver_example.c       2007-12-20 04:45:24 UTC 
(rev 5982)
@@ -62,13 +62,13 @@
 
   if (0 != strcmp (method, "GET"))
     return MHD_NO;              /* unexpected method */
-   if (&aptr != *ptr) 
+  if (&aptr != *ptr)
     {
       /* do never respond on first call */
       *ptr = &aptr;
       return MHD_YES;
     }
-  *ptr = NULL; /* reset when done */
+  *ptr = NULL;                  /* reset when done */
   file = fopen (&url[1], "r");
   if (file == NULL)
     {

Modified: libmicrohttpd/src/daemon/internal.h
===================================================================
--- libmicrohttpd/src/daemon/internal.h 2007-12-20 04:23:05 UTC (rev 5981)
+++ libmicrohttpd/src/daemon/internal.h 2007-12-20 04:45:24 UTC (rev 5982)
@@ -239,12 +239,12 @@
    * 11: We have sent the response headers.  Get ready to send the body.
    */
   MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1,
-  
+
   /**
    * 12: We are ready to send a part of a non-chunked body.  Send it.
    */
   MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_HEADERS_SENT + 1,
-  
+
   /**
    * 13: We are waiting for the client to provide more
    * data of a non-chunked body.
@@ -260,16 +260,16 @@
    * 15: We are waiting for the client to provide a chunk of the body.
    */
   MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_CHUNKED_BODY_READY + 1,
-  
+
   /**
    * 16: We have sent the response body. Prepare the footers.
    */
   MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1,
-  
+
   /**
    * 17: We have prepared the response footer.  Send it.
    */
-  MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1,  
+  MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1,
 
   /**
    * 18: We have sent the response footer.  Shutdown or restart.
@@ -281,7 +281,7 @@
    * allowed).
    */
   MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
-  
+
 };
 
 struct MHD_Connection
@@ -367,7 +367,7 @@
   char *last;
 
   /**
-   * Position after the colon on the last incomplete header 
+   * Position after the colon on the last incomplete header
    * line during parsing of headers.
    * Allocated in pool.  Only valid if state is
    * either HEADER_PART_RECEIVED or FOOTER_PART_RECEIVED.
@@ -389,7 +389,7 @@
   /**
    * Size of read_buffer (in bytes).  This value indicates
    * how many bytes we're willing to read into the buffer;
-   * the real buffer is one byte longer to allow for 
+   * the real buffer is one byte longer to allow for
    * adding zero-termination (when needed).
    */
   size_t read_buffer_size;
@@ -419,7 +419,7 @@
   /**
    * How many more bytes of the body do we expect
    * to read? "-1" for unknown.
-   */ 
+   */
   size_t remaining_upload_size;
 
   /**
@@ -476,7 +476,7 @@
   /**
    * Set to MHD_YES if the response's content reader
    * callback failed to provide data the last time
-   * we tried to read from it.  In that case, the 
+   * we tried to read from it.  In that case, the
    * write socket should be marked as unready until
    * the CRC call succeeds.
    */
@@ -525,7 +525,7 @@
   /**
    * Closure argument to default_handler.
    */
-  void * default_handler_cls;
+  void *default_handler_cls;
 
   /**
    * Linked list of our current connections.

Modified: libmicrohttpd/src/daemon/memorypool.c
===================================================================
--- libmicrohttpd/src/daemon/memorypool.c       2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/memorypool.c       2007-12-20 04:45:24 UTC (rev 
5982)
@@ -191,24 +191,21 @@
 /**
  * Clear all entries from the memory pool except
  * for "keep" of the given "size".
- * 
+ *
  * @param keep pointer to the entry to keep (maybe NULL)
  * @param size how many bytes need to be kept at this address
  * @return addr new address of "keep" (if it had to change)
  */
-void *MHD_pool_reset(struct MemoryPool * pool,
-                    void * keep,
-                    unsigned int size) 
+void *
+MHD_pool_reset (struct MemoryPool *pool, void *keep, unsigned int size)
 {
   if (keep != NULL)
     {
       if (keep != pool->memory)
-       {
-         memmove(pool->memory,
-                 keep,
-                 size);
-         keep = pool->memory;
-       }
+        {
+          memmove (pool->memory, keep, size);
+          keep = pool->memory;
+        }
       pool->pos = size;
     }
   pool->end = pool->size;

Modified: libmicrohttpd/src/daemon/memorypool.h
===================================================================
--- libmicrohttpd/src/daemon/memorypool.h       2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/memorypool.h       2007-12-20 04:45:24 UTC (rev 
5982)
@@ -84,13 +84,11 @@
 /**
  * Clear all entries from the memory pool except
  * for "keep" of the given "size".
- * 
+ *
  * @param keep pointer to the entry to keep (maybe NULL)
  * @param size how many bytes need to be kept at this address
  * @return addr new address of "keep" (if it had to change)
  */
-void *MHD_pool_reset(struct MemoryPool * pool,
-                    void * keep,
-                    unsigned int size);
+void *MHD_pool_reset (struct MemoryPool *pool, void *keep, unsigned int size);
 
 #endif

Modified: libmicrohttpd/src/daemon/minimal_example.c
===================================================================
--- libmicrohttpd/src/daemon/minimal_example.c  2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/minimal_example.c  2007-12-20 04:45:24 UTC (rev 
5982)
@@ -50,13 +50,13 @@
 
   if (0 != strcmp (method, "GET"))
     return MHD_NO;              /* unexpected method */
-  if (&aptr != *ptr) 
+  if (&aptr != *ptr)
     {
       /* do never respond on first call */
       *ptr = &aptr;
       return MHD_YES;
     }
-  *ptr = NULL; /* reset when done */
+  *ptr = NULL;                  /* reset when done */
   response = MHD_create_response_from_data (strlen (me),
                                             (void *) me, MHD_NO, MHD_NO);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);

Modified: libmicrohttpd/src/daemon/postprocessor.c
===================================================================
--- libmicrohttpd/src/daemon/postprocessor.c    2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/daemon/postprocessor.c    2007-12-20 04:45:24 UTC (rev 
5982)
@@ -130,7 +130,7 @@
 
 /**
  * Create a PostProcessor.
- * 
+ *
  * A PostProcessor can be used to (incrementally)
  * parse the data portion of a POST request.
  *
@@ -260,7 +260,7 @@
           else if ((delta > 1) && (xbuf[delta - 2] == '%'))
             delta -= 2;
 
-          /* if we have an incomplete escape sequence, save it to 
+          /* if we have an incomplete escape sequence, save it to
              pp->xbuf for later */
           if (delta < xoff)
             {
@@ -332,14 +332,14 @@
 }
 
 /**
- * Decode multipart POST data. 
+ * Decode multipart POST data.
  *
  * TODO: If the content-type is multipart/mixed, we do not do anything
  * special.  However, we should probably break the individual values
  * apart and give them to the callback individually (will require some
  * additional states & state).
  *
- * See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4 
+ * See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
  */
 static int
 post_process_multipart (struct MHD_PostProcessor *pp,
@@ -507,7 +507,7 @@
                 newline++;
               if (newline + blen + 4 > pp->buffer_size)
                 {
-                  /* boundary not in sight -- 
+                  /* boundary not in sight --
                      process data, then make room for more! */
                   if (MHD_NO == pp->ikvi (pp->cls,
                                           MHD_POSTDATA_KIND,
@@ -622,9 +622,9 @@
  * Parse and process POST data.
  * Call this function when POST data is available
  * (usually during an MHD_AccessHandlerCallback)
- * with the upload_data and upload_data_size.  
+ * with the upload_data and upload_data_size.
  * Whenever possible, this will then cause calls
- * to the MHD_IncrementalKeyValueIterator.  
+ * to the MHD_IncrementalKeyValueIterator.
  *
  * @param pp the post processor
  * @param post_data post_data_len bytes of POST data

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2007-12-20 04:23:05 UTC (rev 
5981)
+++ libmicrohttpd/src/include/microhttpd.h      2007-12-20 04:45:24 UTC (rev 
5982)
@@ -39,10 +39,10 @@
  * The library also understands headers that control connection
  * management (specifically, "Connection: close" and "Expect: 100
  * continue" are understood and handled automatically).<p>
- * 
+ *
  * MHD understands POST data and is able to decode certain formats
  * (at the moment only "application/x-www-form-urlencoded") if the
- * entire data fits into the allowed amount of memory for the 
+ * entire data fits into the allowed amount of memory for the
  * connection.  Unsupported encodings and large POST submissions are
  * provided as a stream to the main application (and thus can be
  * processed, just not conveniently by MHD).<p>
@@ -325,7 +325,7 @@
    * up).  Requests that have never been presented to the application
    * (via MHD_AccessHandlerCallback) will not result in
    * notifications.<p>
-   * 
+   *
    * This option should be followed by TWO pointers.  First a pointer
    * to a function of type "MHD_RequestCompletedCallback" and second a
    * pointer to a closure to pass to the request completed callback.
@@ -407,7 +407,7 @@
   MHD_REQUEST_TERMINATED_TIMEOUT_REACHED = 2,
 
   /**
-   * We had to close the session since MHD was being 
+   * We had to close the session since MHD was being
    * shut down.
    */
   MHD_REQUEST_TERMINATED_DAEMON_SHUTDOWN = 3,
@@ -497,13 +497,13 @@
 
 /**
  * Signature of the callback used by MHD to notify the
- * application about completed requests.  
+ * application about completed requests.
  *
  * @param cls client-defined closure
  * @param connection connection handle
  * @param con_cls value as set by the last call to
  *        the MHD_AccessHandlerCallback
- * @param toe reason for request termination 
+ * @param toe reason for request termination
  * @see MHD_OPTION_NOTIFY_COMPLETED
  */
 typedef void
@@ -551,10 +551,10 @@
  *        obtained from the content reader so far.
  * @return -1 for the end of transmission (or on error);
  *  if a content transfer size was pre-set and the callback
- *  has provided fewer than that amount of data, 
+ *  has provided fewer than that amount of data,
  *  MHD will close the connection with the client;
  *  if no content size was specified and this is an
- *  http 1.1 connection using chunked encoding, MHD will 
+ *  http 1.1 connection using chunked encoding, MHD will
  *  interpret "-1" as the normal end of the transfer
  *  (possibly allowing the client to perform additional
  *  requests using the same TCP connection).
@@ -585,7 +585,7 @@
  * @param data pointer to size bytes of data at the
  *              specified offset
  * @param off offset of data in the overall value
- * @param size number of bytes in data available 
+ * @param size number of bytes in data available
  * @return MHD_YES to continue iterating,
  *         MHD_NO to abort the iteration
  */
@@ -796,7 +796,7 @@
 
 /**
  * Create a PostProcessor.
- * 
+ *
  * A PostProcessor can be used to (incrementally)
  * parse the data portion of a POST request.
  *
@@ -823,9 +823,9 @@
  * Parse and process POST data.
  * Call this function when POST data is available
  * (usually during an MHD_AccessHandlerCallback)
- * with the upload_data and upload_data_size.  
+ * with the upload_data and upload_data_size.
  * Whenever possible, this will then cause calls
- * to the MHD_IncrementalKeyValueIterator.  
+ * to the MHD_IncrementalKeyValueIterator.
  *
  * @param pp the post processor
  * @param post_data post_data_len bytes of POST data





reply via email to

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