gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5981 - libmicrohttpd-docs/WWW


From: gnunet
Subject: [GNUnet-SVN] r5981 - libmicrohttpd-docs/WWW
Date: Wed, 19 Dec 2007 21:23:05 -0700 (MST)

Author: grothoff
Date: 2007-12-19 21:23:05 -0700 (Wed, 19 Dec 2007)
New Revision: 5981

Modified:
   libmicrohttpd-docs/WWW/index.php
Log:
new MHD with support for chunked encoding

Modified: libmicrohttpd-docs/WWW/index.php
===================================================================
--- libmicrohttpd-docs/WWW/index.php    2007-12-20 04:23:00 UTC (rev 5980)
+++ libmicrohttpd-docs/WWW/index.php    2007-12-20 04:23:05 UTC (rev 5981)
@@ -88,13 +88,22 @@
                    const char * upload_data,
                    const char * version,
                    unsigned int * upload_data_size,
-                    void ** unused) {
+                    void ** ptr) {
+  static int dummy;
   const char * page = cls;
   struct MHD_Response * response;
   int ret;
 
   if (0 != strcmp(method, "GET"))
     return MHD_NO; /* unexpected method */
+  if (&aptr != *ptr) 
+    {
+      /* The first time only the headers are valid,
+         do not respond in the first round... */
+      *ptr = &aptr;
+      return MHD_YES;
+    }
+  *ptr = NULL; /* clear context pointer */
   response = MHD_create_response_from_data(strlen(page),
                                           (void*) page,
                                           MHD_NO,
@@ -178,6 +187,24 @@
 W("If a client attempts to queue multiple responses or attempts to queue a 
response early, <tt>MHD_queue_response</tt> will fail (and return 
<tt>MHD_NO</tt>).");
 EP();
 
+H3("Queueing responses");
+BP();
+W("The callback function for the respective URL will be called at least 
twice.");
+W("The first call happens after the server has received the headers.");
+W("The client should use the last <tt>void**</tt> argument to store internal 
context for the session.");
+W("The first call to the callback function is mostly for this type of 
initialization and for internal access checks.");
+W("At least, the callback function should &quot;remember&quot; that the first 
call with just the headers has happened.");
+W("Queueing a response during the first call (for a given connection) should 
only be used for errors -- if the client queues a response during this first 
call, a <tt>100 CONTINUE</tt> response will be suppressed, the request body 
will not be read and the connection will be closed after sending the 
response.");
+W("After the first call, the callback function will be called with upload 
data.");
+W("Until <tt>*upload_data_size</tt> is zero, the callback may not queue a 
response, any such attempt will fail.");
+W("The callback function should update <tt>*upload_data_size</tt> to indicate 
how many bytes were processed.");
+W("Depending on available buffer space, incremental processing of the upload 
maybe required.");
+W("Once all of the upload data has been processed, MHD will call the callback 
a second time with <tt>*upload_data_size</tt> being zero.");
+W("At this point, the callback should queue a &quot;normal&quot; response.");
+W("If queueing a response is not possible, the callback may either block or 
simply not queue a response depending on the threading model that is used.");
+W("If the callback does not queue a response at this point, MHD will either 
(eventually) timeout the connection or keep calling it.");
+EP();
+
 H3("Parsing of POST requests");
 BP();
 W("MHD includes a set of three functions for parsing and processing data 
received in POST requests.");





reply via email to

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