gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r5041 - libmicrohttpd/src/daemon
Date: Wed, 13 Jun 2007 16:24:12 -0600 (MDT)

Author: grothoff
Date: 2007-06-13 16:24:11 -0600 (Wed, 13 Jun 2007)
New Revision: 5041

Modified:
   libmicrohttpd/src/daemon/Makefile.am
   libmicrohttpd/src/daemon/daemontest.c
   libmicrohttpd/src/daemon/daemontest1.c
Log:
using curl properly

Modified: libmicrohttpd/src/daemon/Makefile.am
===================================================================
--- libmicrohttpd/src/daemon/Makefile.am        2007-06-13 22:16:26 UTC (rev 
5040)
+++ libmicrohttpd/src/daemon/Makefile.am        2007-06-13 22:24:11 UTC (rev 
5041)
@@ -27,8 +27,7 @@
 daemontest_SOURCES = \
   daemontest.c
 daemontest_LDADD = \
-  $(top_builddir)/src/daemon/libmicrohttpd.la \
-  @LIBCURL@ 
+  $(top_builddir)/src/daemon/libmicrohttpd.la 
 
 daemontest1_SOURCES = \
   daemontest1.c

Modified: libmicrohttpd/src/daemon/daemontest.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest.c       2007-06-13 22:16:26 UTC (rev 
5040)
+++ libmicrohttpd/src/daemon/daemontest.c       2007-06-13 22:24:11 UTC (rev 
5041)
@@ -25,7 +25,6 @@
  */
 
 #include "config.h"
-#include "curl/curl.h"
 #include "microhttpd.h"
 #include <stdlib.h>
 #include <unistd.h>

Modified: libmicrohttpd/src/daemon/daemontest1.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest1.c      2007-06-13 22:16:26 UTC (rev 
5040)
+++ libmicrohttpd/src/daemon/daemontest1.c      2007-06-13 22:24:11 UTC (rev 
5041)
@@ -19,14 +19,15 @@
 */
 
 /**
- * @file daemontest.c
+ * @file daemontest1.c
  * @brief  Testcase for libmicrohttpd GET operations
+ *         TODO: external select
  * @author Christian Grothoff
  */
 
 #include "config.h"
-#include "curl/curl.h"
-#include "microhttpd.h"
+#include <curl/curl.h>
+#include <microhttpd.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -92,23 +93,17 @@
   cbc.size = 2048;
   cbc.pos = 0;
   d = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_USE_IPv4 | 
MHD_USE_DEBUG,
-                      1083,
+                      1080,
                       &apc_all,
                       NULL,
                       &ahc_echo,
                       "GET");
   if (d == NULL)
     return 1;
-
-  if (MHD_run(d) == MHD_NO) {
-    MHD_stop_daemon(d);
-    return 2;
-  }
-  
   c = curl_easy_init();
   curl_easy_setopt(c,
                   CURLOPT_URL,
-                  "http://localhost:1083/hello_world";);
+                  "http://localhost:1080/hello_world";);
   curl_easy_setopt(c,
                   CURLOPT_WRITEFUNCTION,
                   &copyBuffer);
@@ -120,28 +115,33 @@
                   1);
   curl_easy_setopt(c,
                   CURLOPT_TIMEOUT,
-                  15L);
+                  2L);
   curl_easy_setopt(c,
                   CURLOPT_CONNECTTIMEOUT,
-                  15L);
+                  2L);
   // NOTE: use of CONNECTTIMEOUT without also
   //   setting NOSIGNAL results in really weird
   //   crashes on my system!
   curl_easy_setopt(c,
                   CURLOPT_NOSIGNAL,
                   1);  
-  if (CURLE_OK != curl_easy_perform(c))
-    return 3;
-    
-  curl_easy_cleanup(c);
-  
-  if (cbc.pos != strlen("hello_world"))
+  if (CURLE_OK != curl_easy_perform(c)) {
+    curl_easy_cleanup(c);  
+    MHD_stop_daemon(d);  
+    return 2;
+  }    
+  curl_easy_cleanup(c);  
+  if (cbc.pos != strlen("hello_world")) {
+    MHD_stop_daemon(d);
     return 4;
+  }
   
   if (0 != strncmp("hello_world",
                   cbc.buf,
-                  strlen("hello_world")))
-    return 5;
+                  strlen("hello_world"))) {
+    MHD_stop_daemon(d);
+    return 8;
+  }
   
   MHD_stop_daemon(d);
   
@@ -158,22 +158,17 @@
   cbc.size = 2048;
   cbc.pos = 0;
   d = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_IPv4 | 
MHD_USE_DEBUG,
-                      1084,
+                      1081,
                       &apc_all,
                       NULL,
                       &ahc_echo,
                       "GET");
   if (d == NULL)
-    return 1;
-
-  if(MHD_run(d) == MHD_NO)
-    return 2;
- 
-  
+    return 16;
   c = curl_easy_init();
   curl_easy_setopt(c,
                   CURLOPT_URL,
-                  "http://localhost:1084/hello_world";);
+                  "http://localhost:1081/hello_world";);
   curl_easy_setopt(c,
                   CURLOPT_WRITEFUNCTION,
                   &copyBuffer);
@@ -184,8 +179,11 @@
                   CURLOPT_FAILONERROR,
                   1);
   curl_easy_setopt(c,
+                  CURLOPT_TIMEOUT,
+                  2L);
+  curl_easy_setopt(c,
                   CURLOPT_CONNECTTIMEOUT,
-                  15L);
+                  2L);
   // NOTE: use of CONNECTTIMEOUT without also
   //   setting NOSIGNAL results in really weird
   //   crashes on my system!
@@ -193,16 +191,18 @@
                   CURLOPT_NOSIGNAL,
                   1);  
   if (CURLE_OK != curl_easy_perform(c))
-    return 3;
+    return 32;
   curl_easy_cleanup(c);
-  if (cbc.pos != strlen("hello_world"))
-    return 4;
-  
+  if (cbc.pos != strlen("hello_world")) {
+    MHD_stop_daemon(d);  
+    return 64;
+  }  
   if (0 != strncmp("hello_world",
                   cbc.buf,
-                  strlen("hello_world")))
-    return 5;
-    
+                  strlen("hello_world"))) {
+    MHD_stop_daemon(d);
+    return 128;
+  }
   MHD_stop_daemon(d);
   
   return 0;
@@ -211,11 +211,15 @@
 int main(int argc,
         char * const * argv) {
   unsigned int errorCount = 0;
+
+  if (0 != curl_global_init(CURL_GLOBAL_WIN32)) 
+    return 2;  
   errorCount += testInternalGet();
   errorCount += testMultithreadedGet();  
   if (errorCount != 0)
     fprintf(stderr, 
            "Error (code: %u)\n", 
            errorCount);
+  curl_global_cleanup();
   return errorCount != 0; /* 0 == pass */
 }





reply via email to

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