gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5420 - libmicrohttpd/src/daemon


From: gnunet
Subject: [GNUnet-SVN] r5420 - libmicrohttpd/src/daemon
Date: Tue, 7 Aug 2007 01:08:18 -0600 (MDT)

Author: grothoff
Date: 2007-08-07 01:08:15 -0600 (Tue, 07 Aug 2007)
New Revision: 5420

Modified:
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/daemontest_post.c
Log:
post fixes

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2007-08-06 22:42:32 UTC (rev 
5419)
+++ libmicrohttpd/src/daemon/connection.c       2007-08-07 07:08:15 UTC (rev 
5420)
@@ -111,7 +111,7 @@
        (connection->response != NULL) ||
        (connection->bodyReceived == 0) ||
        (connection->headersReceived == 0) )
-    return MHD_NO;     
+    return MHD_NO; 
   MHD_increment_response_rc(response);
   connection->response = response;
   connection->responseCode = status_code;
@@ -552,6 +552,9 @@
     abort(); /* bad timing... */
   ah = MHD_find_access_handler(connection);
   processed = connection->readLoc;
+  /* FIXME: in case of POST, we need to
+     process the POST data here as well
+     (adding to the header list! */
   if (MHD_NO == ah->dh(ah->dh_cls,
                       connection,
                       connection->url,
@@ -766,7 +769,7 @@
     }
     return MHD_YES;
   }
-  if (response->total_size <= connection->messagePos)
+  if (response->total_size < connection->messagePos)
     abort(); /* internal error */
   if (response->crc != NULL)
     pthread_mutex_lock(&response->mutex);

Modified: libmicrohttpd/src/daemon/daemontest_post.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_post.c  2007-08-06 22:42:32 UTC (rev 
5419)
+++ libmicrohttpd/src/daemon/daemontest_post.c  2007-08-07 07:08:15 UTC (rev 
5420)
@@ -37,6 +37,9 @@
 #include <string.h>
 #include <time.h>
 
+#define POST_DATA "name=daniel&project=curl"
+
+
 static int apc_all(void * cls,
                   const struct sockaddr * addr,
                   socklen_t addrlen) {
@@ -78,6 +81,25 @@
     printf("METHOD: %s\n", method);
     return MHD_NO; /* unexpected method */
   }
+  if ( (*upload_data_size < 24) &&
+       (*upload_data_size > 0) ) 
+    return MHD_YES; /* continue */
+  if (*upload_data_size == 24) {
+    *upload_data_size = 0;
+    if ( (0 != strcmp("daniel",
+                     MHD_lookup_connection_value(connection,
+                                                 MHD_POSTDATA_KIND,
+                                                 "name"))) ||
+        (0 != strcmp("curl",
+                     MHD_lookup_connection_value(connection,
+                                                 MHD_POSTDATA_KIND,
+                                                 "project"))) ) {
+      printf("POST DATA not processed correctly!\n");
+      return MHD_NO;
+    }   
+        
+    return MHD_YES; /* continue */
+  }
   /* FIXME: check connection headers... */
   response = MHD_create_response_from_data(strlen(url),
                                           (void*) url,
@@ -119,10 +141,13 @@
   curl_easy_setopt(c,
                   CURLOPT_WRITEDATA,
                   &cbc);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDS, 
+                  POST_DATA);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDSIZE, 
+                  strlen(POST_DATA));
   curl_easy_setopt(c,
-                  CURLOPT_HTTPPOST,
-                  NULL); /* FIXME! */
-  curl_easy_setopt(c,
                   CURLOPT_POST,
                   1L);
   curl_easy_setopt(c,
@@ -193,10 +218,13 @@
   curl_easy_setopt(c,
                   CURLOPT_WRITEDATA,
                   &cbc);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDS, 
+                  POST_DATA);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDSIZE, 
+                  strlen(POST_DATA));
   curl_easy_setopt(c,
-                  CURLOPT_HTTPPOST,
-                  NULL); /* FIXME! */
-  curl_easy_setopt(c,
                   CURLOPT_POST,
                   1L);
   curl_easy_setopt(c,
@@ -278,10 +306,13 @@
   curl_easy_setopt(c,
                   CURLOPT_WRITEDATA,
                   &cbc);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDS, 
+                  POST_DATA);
+  curl_easy_setopt(c, 
+                  CURLOPT_POSTFIELDSIZE, 
+                  strlen(POST_DATA));
   curl_easy_setopt(c,
-                  CURLOPT_HTTPPOST,
-                  NULL); /* FIXME! */
-  curl_easy_setopt(c,
                   CURLOPT_POST,
                   1L);
   curl_easy_setopt(c,





reply via email to

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