[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11593 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11593 - gnunet/src/transport |
Date: |
Tue, 1 Jun 2010 16:49:19 +0200 |
Author: wachs
Date: 2010-06-01 16:49:19 +0200 (Tue, 01 Jun 2010)
New Revision: 11593
Modified:
gnunet/src/transport/test_plugin_transport_http.c
Log:
Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c 2010-06-01 14:14:57 UTC
(rev 11592)
+++ gnunet/src/transport/test_plugin_transport_http.c 2010-06-01 14:49:19 UTC
(rev 11593)
@@ -153,6 +153,23 @@
size_t addrlen;
};
+/**
+ * Struct for plugin addresses
+ */
+struct HTTP_Transfer
+{
+ /**
+ * HTTP Header result for transfer
+ */
+ unsigned int http_result_code;
+
+ /**
+ * amount of bytes we recieved
+ */
+ size_t data_size;
+
+};
+
struct Plugin_Address * addr_head;
/**
@@ -182,6 +199,14 @@
/**
* Did the test pass or fail?
*/
+static int fail_send_data;
+static struct HTTP_Transfer no_ident;
+
+
+
+/**
+ * Did the test pass or fail?
+ */
static int fail;
/**
@@ -333,10 +358,24 @@
if (cbc->pos + size * nmemb > cbc->size)
return 0; /* overflow */
memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Send completed. %s\n",cbc->buf);
cbc->pos += size * nmemb;
return size * nmemb;
}
+static size_t header_function( void *ptr, size_t size, size_t nmemb, void
*stream)
+{
+ char * tmp;
+ unsigned int len = size * nmemb;
+ tmp = GNUNET_malloc ( len+1 );
+ memcpy(tmp,ptr,len);
+ //if (tmp[len-1]!='\0')
+ // tmp[len]= '\0';
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: %u :`%s'\n",len,tmp);
+ GNUNET_free (tmp);
+ return size * nmemb;
+}
+
static size_t send_prepare( void );
static void send_execute (void *cls,
@@ -383,13 +422,16 @@
__LINE__,
curl_easy_strerror (msg->data.result));
/* sending msg failed*/
+ fail_send_data = GNUNET_YES;
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Send completed.\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send completed\n");
/* sending completed */
+ fail_send_data = GNUNET_NO;
}
+
+
curl_easy_cleanup(curl_handle);
curl_handle=NULL;
shutdown_clean();
@@ -467,7 +509,7 @@
/**
* function to send data to server
*/
-static int send_data(struct HTTP_Message *msg, char * url)
+static int send_data(struct HTTP_Message *msg, struct HTTP_Transfer * result,
char * url)
{
curl_handle = curl_easy_init();
@@ -481,6 +523,8 @@
#endif
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
+ curl_easy_setopt (curl_handle, CURLOPT_HEADERFUNCTION, &header_function);
+ curl_easy_setopt (curl_handle, CURLOPT_WRITEHEADER, result);
curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, ©Buffer);
curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, msg);
curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, &putBuffer);
@@ -657,6 +701,7 @@
fail_pretty_printer = GNUNET_YES;
fail_notify_address = GNUNET_YES;
fail_addr_to_str = GNUNET_YES;
+ fail_send_data = GNUNET_YES;
addr_head = NULL;
count_str_addr = 0;
/* parse configuration */
@@ -764,10 +809,11 @@
msg->pos = 0;
msg->buf = GNUNET_malloc (2048);
- res = send_data (msg, "http://localhost:12389/");
+ res = send_data (msg, &no_ident, "http://localhost:12389/");
+
/* testing finished, shutting down */
- if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO)
&& (fail_addr_to_str == GNUNET_NO) )
+ if ((fail_notify_address == GNUNET_NO) && (fail_pretty_printer == GNUNET_NO)
&& (fail_addr_to_str == GNUNET_NO) && (fail_send_data == GNUNET_NO))
fail = 0;
else
fail = 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11593 - gnunet/src/transport,
gnunet <=