gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22921 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r22921 - gnunet/src/gns
Date: Thu, 26 Jul 2012 13:05:05 +0200

Author: schanzen
Date: 2012-07-26 13:05:05 +0200 (Thu, 26 Jul 2012)
New Revision: 22921

Modified:
   gnunet/src/gns/gnunet-gns-proxy.c
Log:
-fix escaping of url

Modified: gnunet/src/gns/gnunet-gns-proxy.c
===================================================================
--- gnunet/src/gns/gnunet-gns-proxy.c   2012-07-26 10:35:37 UTC (rev 22920)
+++ gnunet/src/gns/gnunet-gns-proxy.c   2012-07-26 11:05:05 UTC (rev 22921)
@@ -191,6 +191,9 @@
   /* DLL for tasks */
   struct ProxyCurlTask *next;
 
+  /* Already accepted */
+  int accepted;
+
   /* Handle to cURL */
   CURL *curl;
 
@@ -469,7 +472,7 @@
 }
 
 /**
- * Escape giben 0-terminated string
+ * Escape given 0-terminated string
  *
  * @param to_esc string to escapse
  * @return allocated new escaped string (MUST free!)
@@ -1742,7 +1745,17 @@
                           ctask);
 }
 
+static void*
+mhd_log_callback (void* cls, const char* url)
+{
+  struct ProxyCurlTask *ctask;
 
+  ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
+  strcpy (ctask->url, url);
+  ctask->accepted = GNUNET_NO;
+  return ctask;
+}
+
 /**
  * Main MHD callback for handling requests.
  *
@@ -1783,7 +1796,7 @@
   char curlurl[MAX_HTTP_URI_LENGTH]; // buffer overflow!
   int ret = MHD_YES;
 
-  struct ProxyCurlTask *ctask;
+  struct ProxyCurlTask *ctask = *con_cls;
   struct ProxyPostData *fin_post;
   
   //FIXME handle
@@ -1798,14 +1811,13 @@
   }
 
 
-  if (NULL == *con_cls)
+  if (GNUNET_NO == ctask->accepted)
   {
 
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Got %s request for %s\n", meth, url);
-    ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
+    //ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
     ctask->mhd = hd;
-    *con_cls = ctask;
     
     ctask->curl = curl_easy_init();
     if (NULL == ctask->curl)
@@ -1820,7 +1832,8 @@
       GNUNET_free (ctask);
       return ret;
     }
-  
+    
+    ctask->accepted = GNUNET_YES;
     ctask->download_in_progress = GNUNET_YES;
     ctask->buf_status = BUF_WAIT_FOR_CURL;
     ctask->connection = con;
@@ -1889,22 +1902,22 @@
     curl_easy_setopt (ctask->curl, CURLOPT_WRITEDATA, ctask);
     curl_easy_setopt (ctask->curl, CURLOPT_FOLLOWLOCATION, 0);
     curl_easy_setopt (ctask->curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
-    
+
     if (GNUNET_NO == ctask->mhd->is_ssl)
     {
-      sprintf (curlurl, "http://%s:%d%s";, ctask->host, ctask->port, url);
-      MHD_get_connection_values (con,
-                                 MHD_GET_ARGUMENT_KIND,
-                                 &get_uri_val_iter, curlurl);
+      sprintf (curlurl, "http://%s:%d%s";, ctask->host, ctask->port, 
ctask->url);
+      //MHD_get_connection_values (con,
+      //                           MHD_GET_ARGUMENT_KIND,
+      //                           &get_uri_val_iter, curlurl);
       curl_easy_setopt (ctask->curl, CURLOPT_URL, curlurl);
     }
-    strcpy (ctask->url, url);
+    
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "MHD: Adding new curl task for %s%s\n", ctask->host, url);
-    MHD_get_connection_values (con,
-                               MHD_GET_ARGUMENT_KIND,
-                               &get_uri_val_iter, ctask->url);
-  
+                  "MHD: Adding new curl task for %s\n", ctask->host);
+    //MHD_get_connection_values (con,
+    //                           MHD_GET_ARGUMENT_KIND,
+    //                           &get_uri_val_iter, ctask->url);
+
     curl_easy_setopt (ctask->curl, CURLOPT_FAILONERROR, 1);
     curl_easy_setopt (ctask->curl, CURLOPT_CONNECTTIMEOUT, 600L);
     curl_easy_setopt (ctask->curl, CURLOPT_TIMEOUT, 600L);
@@ -2509,6 +2522,8 @@
                                MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL,
                                MHD_OPTION_HTTPS_MEM_KEY, pgc->key,
                                MHD_OPTION_HTTPS_MEM_CERT, pgc->cert,
+                               MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback,
+                               NULL,
                                MHD_OPTION_END);
 
     GNUNET_assert (hd->daemon != NULL);
@@ -3297,6 +3312,7 @@
             MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
             MHD_OPTION_NOTIFY_COMPLETED,
             NULL, NULL,
+            MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, NULL,
             MHD_OPTION_END);
 
   GNUNET_assert (httpd != NULL);




reply via email to

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