track delay between transmission request and satisfaction:
[oweals/gnunet.git] / src / transport / test_plugin_transport_http.c
1 /*
2      This file is part of GNUnet.
3      (C) 2010 Christian Grothoff (and other contributing authors)
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet is distributed in the hope that it will be useful, but
11      WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13      General Public License for more details.
14
15      You should have received a copy of the GNU General Public License
16      along with GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20 /**
21  * @file transport/test_plugin_transport_http.c
22  * @brief testcase for plugin_transport_http.c
23  * @author Matthias Wachs
24  */
25
26 #include "platform.h"
27 #include "gnunet_constants.h"
28 #include "gnunet_common.h"
29 #include "gnunet_getopt_lib.h"
30 #include "gnunet_hello_lib.h"
31 #include "gnunet_os_lib.h"
32 #include "gnunet_peerinfo_service.h"
33 #include "gnunet_plugin_lib.h"
34 #include "gnunet_protocols.h"
35 #include "gnunet_program_lib.h"
36 #include "gnunet_signatures.h"
37 #include "gnunet_service_lib.h"
38 #include "gnunet_crypto_lib.h"
39
40 #include "plugin_transport.h"
41 #include "gnunet_statistics_service.h"
42 #include "transport.h"
43 #include <curl/curl.h>
44
45 #define VERBOSE GNUNET_NO
46 #define DEBUG_CURL GNUNET_NO
47 #define HTTP_BUFFER_SIZE 2048
48
49 #define PROTOCOL_PREFIX "http"
50
51 #define PLUGIN libgnunet_plugin_transport_template
52
53 /**
54  * How long until we give up on transmitting the message?
55  */
56 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
57
58 /**
59  * Testcase timeout
60  */
61 #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
62
63 /**
64  * How long between recieve and send?
65  */
66 #define WAIT_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
67
68
69
70 /**
71  *  Struct for plugin addresses
72  */
73 struct Plugin_Address
74 {
75   /**
76    * Next field for linked list
77    */
78   struct Plugin_Address * next;
79
80   /**
81    * buffer containing data to send
82    */
83   void * addr;
84
85   /**
86    * amount of data to sent
87    */
88   size_t addrlen;
89 };
90
91 /**
92  *  Message to send using http
93  */
94 struct HTTP_Message
95 {
96   /**
97    * buffer
98    */
99   unsigned char buf[HTTP_BUFFER_SIZE];
100
101   /**
102    * current position in buffer
103    */
104   size_t pos;
105
106   /**
107    * buffer size
108    */
109   size_t size;
110
111   /**
112    * data size
113    */
114   size_t len;
115 };
116
117
118 /**
119  *  Struct for plugin addresses
120  */
121 struct HTTP_Transfer
122 {
123   /**
124    * amount of bytes we recieved
125    */
126   size_t data_size;
127
128   /**
129    * buffer for http transfers
130    */
131   unsigned char buf[HTTP_BUFFER_SIZE];
132
133   /**
134    * buffer size this transfer
135    */
136   size_t size;
137
138   /**
139    * amount of bytes we recieved
140    */
141   size_t pos;
142
143   /**
144    * HTTP Header result for transfer
145    */
146   unsigned int http_result_code;
147
148   /**
149    * did the test fail?
150    */
151   unsigned int test_failed;
152
153   /**
154    * was this test already executed?
155    */
156   unsigned int test_executed;
157 };
158
159
160 /**
161  * Network format for IPv4 addresses.
162  */
163 struct IPv4HttpAddress
164 {
165   struct IPv4HttpAddress * next;
166
167   struct IPv4HttpAddress * prev;
168
169   /**
170    * IPv4 address, in network byte order.
171    */
172   uint32_t ipv4_addr GNUNET_PACKED;
173
174   /**
175    * Port number, in network byte order.
176    */
177   uint16_t u_port GNUNET_PACKED;
178
179 };
180
181
182 /**
183  * Network format for IPv6 addresses.
184  */
185 struct IPv6HttpAddress
186 {
187   struct IPv6HttpAddress * next;
188
189   struct IPv6HttpAddress * prev;
190
191   /**
192    * IPv6 address.
193    */
194   struct in6_addr ipv6_addr GNUNET_PACKED;
195
196   /**
197    * Port number, in network byte order.
198    */
199   uint16_t u6_port GNUNET_PACKED;
200
201 };
202
203
204 /**
205  * Our public key.
206  */
207 /* static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key; */
208
209 /**
210  * Our public key.
211  */
212 static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key;
213
214 /**
215  * Our identity.
216  */
217 static struct GNUNET_PeerIdentity my_identity;
218
219 /**
220  * Our private key.
221  */
222 static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
223
224 /**
225  * Peer's port
226  */
227 static long long unsigned int port;
228
229 /**
230  * Peer's addr
231  */
232 static char * test_addr;
233
234 /**
235  * Our scheduler.
236  */
237 struct GNUNET_SCHEDULER_Handle *sched;
238
239 /**
240  * Our statistics handle.
241  */
242 struct GNUNET_STATISTICS_Handle *stats;
243
244
245 /**
246  * Our configuration.
247  */
248 const struct GNUNET_CONFIGURATION_Handle *cfg;
249
250 /**
251  * Number of neighbours we'd like to have.
252  */
253 static uint32_t max_connect_per_transport;
254
255 /**
256  * Environment for this plugin.
257  */
258 static struct GNUNET_TRANSPORT_PluginEnvironment env;
259
260 /**
261  *handle for the api provided by this plugin
262  */
263 static struct GNUNET_TRANSPORT_PluginFunctions *api;
264
265 /**
266  * ID of the task controlling the testcase timeout
267  */
268 static GNUNET_SCHEDULER_TaskIdentifier ti_timeout;
269
270 static GNUNET_SCHEDULER_TaskIdentifier ti_send;
271
272 //const struct GNUNET_PeerIdentity * p;
273
274 /**
275  * buffer for data to send
276  */
277 static struct HTTP_Message buffer_out;
278
279 /**
280  * buffer for data to recieve
281  */
282 static struct HTTP_Message buffer_in;
283
284
285 struct Plugin_Address * addr_head;
286
287 /**
288  * Did the test pass or fail?
289  */
290 static int fail_notify_address;
291 /**
292  * Did the test pass or fail?
293  */
294 static int fail_notify_address_count;
295
296 /**
297  * Did the test pass or fail?
298  */
299 static int fail_pretty_printer;
300
301 /**
302  * Did the test pass or fail?
303  */
304 static int fail_pretty_printer_count;
305
306 /**
307  * Did the test pass or fail?
308  */
309 static int fail_addr_to_str;
310
311 /**
312  * No. of msgs transmitted successfully to local addresses
313  */
314 static int fail_msgs_transmited_to_local_addrs;
315
316 /**
317  * Test: transmit msg of max. size
318  */
319 static int fail_msg_transmited_bigger_max_size;
320
321 /**
322  * Test: transmit msg of max. size
323  */
324 static int fail_msg_transmited_max_size;
325
326 /**
327  * Test: transmit 2 msgs. in in send operation
328  */
329 static int fail_multiple_msgs_in_transmission;
330
331 /**
332  * Test: connect to peer without peer identification
333  */
334 static struct HTTP_Transfer test_no_ident;
335
336 /**
337  * Test: connect to peer without peer identification
338  */
339 static struct HTTP_Transfer test_too_short_ident;
340
341 /**
342  * Test: connect to peer without peer identification
343  */
344 static struct HTTP_Transfer test_too_long_ident;
345
346 /**
347  * Test: connect to peer with valid peer identification
348  */
349 static struct HTTP_Transfer test_valid_ident;
350
351 /**
352  * Test: session selection, use any existing
353  */
354 static int fail_session_selection_any;
355
356 /**
357  * Test: session selection, use existing inbound session
358  */
359 static int fail_session_selection_session;
360
361 /**
362  * Test: session selection, use existing inbound session
363  * max message, not fitting in send & recv buffers at one time
364  */
365 static int fail_session_selection_session_big;
366
367 /**
368 * Test: session selection, use reliable existing
369  */
370 static int fail_session_selection_reliable;
371
372 /**
373  * Did the test pass or fail?
374  */
375 static int fail;
376
377 /**
378  * Number of local addresses
379  */
380 static unsigned int count_str_addr;
381
382 CURL *curl_handle;
383
384 /**
385  * cURL Multihandle
386  */
387 static CURLM *multi_handle;
388
389 /**
390  * The task sending data
391  */
392 static GNUNET_SCHEDULER_TaskIdentifier http_task_send;
393
394 /**
395  * Shutdown testcase
396  */
397 static void
398 shutdown_clean ()
399 {
400   struct Plugin_Address * cur;
401   struct Plugin_Address * tmp;
402
403   /* Evaluate results  */
404   fail = 0;
405   if ((fail_notify_address == GNUNET_YES) || (fail_pretty_printer == GNUNET_YES) || (fail_addr_to_str == GNUNET_YES))
406   {
407     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 0: Test plugin functions failed\n");
408     fail = 1;
409   }
410   if ((test_no_ident.test_failed == GNUNET_YES) || (test_too_short_ident.test_failed == GNUNET_YES) || (test_too_long_ident.test_failed == GNUNET_YES) || (test_valid_ident.test_failed == GNUNET_YES))
411   {
412     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 1: Test connect with wrong data failed\n");
413     fail = 1;
414   }
415   if ((fail_session_selection_any != GNUNET_NO) || (fail_session_selection_reliable != GNUNET_NO) || (fail_session_selection_session != GNUNET_NO) || (fail_session_selection_session_big != GNUNET_NO))
416   {
417     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 2: Test session selection failed\n");
418     fail = 1;
419   }
420   if ((fail_msgs_transmited_to_local_addrs != count_str_addr) || (fail_multiple_msgs_in_transmission != 2) || (fail_msg_transmited_max_size == GNUNET_YES))
421   {
422     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Phase 3: Test sending with plugin failed\n");
423     fail = 1;
424   }
425   if (fail != 1)
426   {
427     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All tests successful\n");
428   }
429
430   api->disconnect(api->cls,&my_identity);
431
432   curl_multi_cleanup(multi_handle);
433
434   if (NULL != curl_handle)
435     curl_easy_cleanup (curl_handle);
436
437   /* cleaning addresses */
438   while (addr_head != NULL)
439   {
440     cur = addr_head;
441     tmp = addr_head->next;
442     GNUNET_free (addr_head->addr);
443     GNUNET_free (addr_head);
444     addr_head=tmp;
445   }
446
447   if (ti_send != GNUNET_SCHEDULER_NO_TASK)
448   {
449     GNUNET_SCHEDULER_cancel(sched,ti_send);
450     ti_send = GNUNET_SCHEDULER_NO_TASK;
451   }
452
453   if (http_task_send != GNUNET_SCHEDULER_NO_TASK)
454   {
455     GNUNET_SCHEDULER_cancel(sched,http_task_send);
456     http_task_send = GNUNET_SCHEDULER_NO_TASK;
457   }
458
459   if (ti_timeout != GNUNET_SCHEDULER_NO_TASK)
460   {
461     GNUNET_SCHEDULER_cancel(sched,ti_timeout);
462     ti_timeout = GNUNET_SCHEDULER_NO_TASK;
463   }
464
465   GNUNET_free(test_addr);
466   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unloading http plugin\n");
467   GNUNET_assert (NULL == GNUNET_PLUGIN_unload ("libgnunet_plugin_transport_http", api));
468
469   GNUNET_SCHEDULER_shutdown(sched);
470   GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http");
471
472   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Exiting testcase\n");
473   exit(fail);
474   return;
475 }
476
477
478 /**
479  * Continuation called after plugin send message
480  * @cls closure
481  * @target target
482  * @result GNUNET_OK or GNUNET_SYSERR
483  */
484
485 static void task_send_cont (void *cls,
486                             const struct GNUNET_PeerIdentity * target,
487                             int result)
488 {
489   struct Plugin_Address * tmp_addr;
490   tmp_addr = addr_head;
491
492   if ((cls == &fail_msg_transmited_bigger_max_size) && (result == GNUNET_SYSERR))
493   {
494     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message bigger max msg size was not sent!\n");
495     fail_msg_transmited_bigger_max_size = GNUNET_NO;
496     return;
497   }
498
499   if ((cls == &fail_msg_transmited_max_size) && (result == GNUNET_OK))
500   {
501     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message with max msg size succesfully sent!\n",fail_msgs_transmited_to_local_addrs);
502     fail_msg_transmited_max_size = GNUNET_NO;
503   }
504 }
505
506
507 static void run_connection_tests( int phase , void * cls);
508
509 /**
510  * Recieves messages from plugin, in real world transport
511  */
512 static struct GNUNET_TIME_Relative
513 receive (void *cls,
514          const struct GNUNET_PeerIdentity * peer,
515          const struct GNUNET_MessageHeader * message,
516          uint32_t distance,
517          struct Session *session,
518          const char *sender_address,
519          uint16_t sender_address_len)
520 {
521   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase recieved new message from peer `%s' with type %u and length %u, session %X\n",  GNUNET_i2s(peer), ntohs(message->type), ntohs(message->size),session);
522
523   if ((ntohs(message->type)>=10) && (ntohs(message->type)<20))
524   {
525     fail_msgs_transmited_to_local_addrs++;
526     if (fail_msgs_transmited_to_local_addrs == count_str_addr)
527       run_connection_tests(2, session);
528   }
529
530
531   if ((ntohs(message->type)==20))
532   {
533     fail_session_selection_reliable = GNUNET_NO;
534   }
535
536   if ((ntohs(message->type)==21))
537   {
538     fail_session_selection_any = GNUNET_NO;
539   }
540   if ((ntohs(message->type)==22))
541   {
542     fail_session_selection_session = GNUNET_NO;
543   }
544
545   if ((ntohs(message->type)==23))
546   {
547     fail_session_selection_session_big = GNUNET_NO;
548     run_connection_tests(3, NULL);
549   }
550
551   if ((ntohs(message->type)==30) || (ntohs(message->type)==31))
552   {
553     fail_multiple_msgs_in_transmission ++;
554   }
555
556   if ((ntohs(message->type)==32) && (ntohs(message->size) == GNUNET_SERVER_MAX_MESSAGE_SIZE-1))
557   {
558     fail_msg_transmited_max_size = GNUNET_NO;
559     shutdown_clean();
560   }
561
562   return GNUNET_TIME_UNIT_ZERO;
563 }
564
565 static size_t send_function (void *stream, size_t size, size_t nmemb, void *ptr)
566 {
567   unsigned int len;
568
569   len = buffer_out.len;
570
571   if (( buffer_out.pos == len) || (len > (size * nmemb)))
572     return 0;
573   memcpy(stream, buffer_out.buf, len);
574   buffer_out.pos = len;
575   return len;
576 }
577
578 static size_t recv_function (void *ptr, size_t size, size_t nmemb, void *ctx)
579 {
580
581   if (buffer_in.pos + size * nmemb > buffer_in.size)
582     return 0;                   /* overflow */
583
584   buffer_in.len = size * nmemb;
585   memcpy (&buffer_in.buf[buffer_in.pos], ptr, size * nmemb);
586   buffer_in.pos += size * nmemb;
587   buffer_in.len = buffer_in.pos;
588   buffer_in.buf[buffer_in.pos] = '\0';
589   return buffer_in.pos;
590 }
591
592 static size_t header_function( void *ptr, size_t size, size_t nmemb, void *stream)
593 {
594   struct HTTP_Transfer * res = (struct HTTP_Transfer *) stream;
595   char * tmp;
596   unsigned int len = size * nmemb;
597
598   tmp = GNUNET_malloc (  len+1 );
599   memcpy(tmp,ptr,len);
600   if (tmp[len-2] == 13)
601     tmp[len-2]= '\0';
602 #if DEBUG_CURL
603   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Header: `%s'\n",tmp);
604 #endif
605   if (0==strcmp (tmp,"HTTP/1.1 100 Continue"))
606   {
607     res->http_result_code=100;
608   }
609   if (0==strcmp (tmp,"HTTP/1.1 200 OK"))
610   {
611     res->http_result_code=200;
612   }
613   if (0==strcmp (tmp,"HTTP/1.1 400 Bad Request"))
614   {
615     res->http_result_code=400;
616   }
617   if (0==strcmp (tmp,"HTTP/1.1 404 Not Found"))
618   {
619     res->http_result_code=404;
620   }
621   if (0==strcmp (tmp,"HTTP/1.1 413 Request entity too large"))
622   {
623     res->http_result_code=413;
624   }
625
626   GNUNET_free (tmp);
627   return size * nmemb;
628 }
629
630 static size_t send_prepare( struct HTTP_Transfer * result);
631
632
633
634 static void send_execute (void *cls,
635              const struct GNUNET_SCHEDULER_TaskContext *tc)
636 {
637   struct HTTP_Transfer *res;
638
639   int running;
640   struct CURLMsg *msg;
641   CURLMcode mret;
642
643   res = (struct HTTP_Transfer *) cls;
644   http_task_send = GNUNET_SCHEDULER_NO_TASK;
645   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
646     return;
647
648   do
649     {
650       running = 0;
651       mret = curl_multi_perform (multi_handle, &running);
652       if (running == 0)
653         {
654           do
655             {
656
657               msg = curl_multi_info_read (multi_handle, &running);
658               if (msg == NULL)
659                 break;
660               /* get session for affected curl handle */
661               //cs = find_session_by_curlhandle (msg->easy_handle);
662               //GNUNET_assert ( cs != NULL );
663               switch (msg->msg)
664                 {
665
666                 case CURLMSG_DONE:
667                   if ( (msg->data.result != CURLE_OK) &&
668                        (msg->data.result != CURLE_GOT_NOTHING) )
669                     {
670
671                     GNUNET_log(GNUNET_ERROR_TYPE_INFO,
672                                _("curl failed for `%s' at %s:%d: `%s'\n"),
673                                "curl_multi_perform",
674                                __FILE__,
675                                __LINE__,
676                                curl_easy_strerror (msg->data.result));
677                     /* sending msg failed*/
678                     curl_easy_cleanup(curl_handle);
679                     curl_handle=NULL;
680
681                     run_connection_tests(0, NULL);
682                     }
683                   if (res == &test_no_ident)
684                   {
685                     if  ((res->http_result_code==404) && (buffer_in.len==208))
686                     {
687                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer without any peer identification: test passed\n");
688                       res->test_failed = GNUNET_NO;
689                     }
690                     else
691                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer without any peer identification: test failed\n"));
692                   }
693                   if (res == &test_too_short_ident)
694                   {
695                     if  ((res->http_result_code==404) && (buffer_in.len==208))
696                     {
697                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too short peer identification: test passed\n");
698                       res->test_failed = GNUNET_NO;
699                     }
700                     else
701                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too short peer identification: test failed\n"));
702                   }
703                   if (res == &test_too_long_ident)
704                   {
705                     if  ((res->http_result_code==404) && (buffer_in.len==208))
706                       {
707                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with too long peer identification: test passed\n");
708                       res->test_failed = GNUNET_NO;
709                       }
710                     else
711                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Connecting to peer with too long peer identification: test failed\n"));
712                   }
713                   if (res == &test_valid_ident)
714                   {
715                     if  ((res->http_result_code==200))
716                     {
717                       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting to peer with valid peer identification: test passed\n");
718                       res->test_failed = GNUNET_NO;
719                     }
720                     else
721                       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connecting to peer with valid peer identification: test failed\n");
722                   }
723                   curl_easy_cleanup(curl_handle);
724                   curl_handle=NULL;
725                   if ((res == &test_valid_ident) && (res->test_failed == GNUNET_NO))
726                     run_connection_tests(1, NULL);
727                   run_connection_tests(0, NULL);
728                   return;
729                 default:
730                   break;
731                 }
732
733             }
734           while ( (running > 0) );
735         }
736     }
737   while (mret == CURLM_CALL_MULTI_PERFORM);
738   send_prepare(cls);
739 }
740
741 /**
742  * Function setting up file descriptors and scheduling task to run
743  * @param ses session to send data to
744  * @return bytes sent to peer
745  */
746 static size_t send_prepare( struct HTTP_Transfer * result)
747 {
748   fd_set rs;
749   fd_set ws;
750   fd_set es;
751   int max;
752   struct GNUNET_NETWORK_FDSet *grs;
753   struct GNUNET_NETWORK_FDSet *gws;
754   long to;
755   CURLMcode mret;
756
757   max = -1;
758   FD_ZERO (&rs);
759   FD_ZERO (&ws);
760   FD_ZERO (&es);
761   mret = curl_multi_fdset (multi_handle, &rs, &ws, &es, &max);
762   if (mret != CURLM_OK)
763     {
764       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
765                   _("%s failed at %s:%d: `%s'\n"),
766                   "curl_multi_fdset", __FILE__, __LINE__,
767                   curl_multi_strerror (mret));
768       return -1;
769     }
770   mret = curl_multi_timeout (multi_handle, &to);
771   if (mret != CURLM_OK)
772     {
773       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
774                   _("%s failed at %s:%d: `%s'\n"),
775                   "curl_multi_timeout", __FILE__, __LINE__,
776                   curl_multi_strerror (mret));
777       return -1;
778     }
779
780   grs = GNUNET_NETWORK_fdset_create ();
781   gws = GNUNET_NETWORK_fdset_create ();
782   GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1);
783   GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1);
784   http_task_send = GNUNET_SCHEDULER_add_select (sched,
785                                    GNUNET_SCHEDULER_PRIORITY_DEFAULT,
786                                    GNUNET_SCHEDULER_NO_TASK,
787                                    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 0),
788                                    grs,
789                                    gws,
790                                    &send_execute,
791                                    result);
792   GNUNET_NETWORK_fdset_destroy (gws);
793   GNUNET_NETWORK_fdset_destroy (grs);
794
795   /* FIXME: return bytes REALLY sent */
796   return 0;
797 }
798
799 /**
800  * function to send data to server
801  */
802 static int send_data( struct HTTP_Transfer * result, char * url)
803 {
804
805   curl_handle = curl_easy_init();
806   if( NULL == curl_handle)
807   {
808     printf("easy_init failed \n");
809     return GNUNET_SYSERR;
810   }
811 #if DEBUG_CURL
812   curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
813 #endif
814   curl_easy_setopt(curl_handle, CURLOPT_URL, url);
815   curl_easy_setopt(curl_handle, CURLOPT_PUT, 1L);
816   curl_easy_setopt (curl_handle, CURLOPT_HEADERFUNCTION, &header_function);
817   curl_easy_setopt (curl_handle, CURLOPT_WRITEHEADER, result);
818   curl_easy_setopt (curl_handle, CURLOPT_WRITEFUNCTION, &recv_function);
819   curl_easy_setopt (curl_handle, CURLOPT_WRITEDATA, result);
820   curl_easy_setopt (curl_handle, CURLOPT_READFUNCTION, &send_function);
821   curl_easy_setopt (curl_handle, CURLOPT_READDATA, result);
822   curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t) buffer_out.len);
823   curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, 30);
824   curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 20);
825
826   curl_multi_add_handle(multi_handle, curl_handle);
827
828   send_prepare(result);
829
830   return GNUNET_OK;
831 }
832
833 /**
834  * Plugin notifies transport (aka testcase) about its addresses
835  */
836 void
837 notify_address (void *cls,
838                 const char *name,
839                 const void *addr,
840                 uint16_t addrlen,
841                 struct GNUNET_TIME_Relative expires)
842 {
843   char address[INET6_ADDRSTRLEN];
844   unsigned int port;
845   struct Plugin_Address * pl_addr;
846   struct Plugin_Address * cur;
847
848   if (addrlen == (sizeof (struct IPv4HttpAddress)))
849     {
850       inet_ntop(AF_INET, (struct in_addr *) addr,address,INET_ADDRSTRLEN);
851       port = ntohs(((struct IPv4HttpAddress *) addr)->u_port);
852     }
853   else if (addrlen == (sizeof (struct IPv6HttpAddress)))
854     {
855       inet_ntop(AF_INET6, (struct in6_addr *) addr,address,INET6_ADDRSTRLEN);
856       port = ntohs(((struct IPv6HttpAddress *) addr)->u6_port);
857     }
858   else
859     {
860     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
861                 _("Unknown address size: ipv6 has %u ipv4 has %u but this has %u\n"),
862                 sizeof (struct IPv6HttpAddress),
863                 sizeof (struct IPv4HttpAddress),
864                 addrlen);
865       return;
866     }
867   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
868               _("Transport plugin notification for address: `%s':%u\n"),
869               address,
870               port);
871   pl_addr = GNUNET_malloc (sizeof (struct Plugin_Address) );
872   pl_addr->addrlen = addrlen;
873   pl_addr->addr = GNUNET_malloc(addrlen);
874   memcpy(pl_addr->addr,addr,addrlen);
875   pl_addr->next = NULL;
876
877   if ( NULL == addr_head)
878     {
879       addr_head = pl_addr;
880     }
881   else
882     {
883       cur = addr_head;
884       while (NULL != cur->next)
885         {
886           cur = cur->next;
887         }
888       cur->next = pl_addr;
889     }
890   fail_notify_address_count++;
891   fail_notify_address = GNUNET_NO;
892 }
893
894 static void
895 plugin_env_session_end  (void *cls,
896                          const struct GNUNET_PeerIdentity *peer,
897                          struct Session *session)
898 {
899           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Pluging tells me: session %X to peer `%s' ended\n", session, GNUNET_i2s(peer));
900 }
901
902
903 /**
904  * Setup plugin environment
905  */
906 static void
907 setup_plugin_environment ()
908 {
909   env.cfg = cfg;
910   env.sched = sched;
911   env.stats = stats;
912   env.my_identity = &my_identity;
913   env.cls = &env;
914   env.receive = &receive;
915   env.notify_address = &notify_address;
916   env.max_connections = max_connect_per_transport;
917   env.session_end = &plugin_env_session_end;
918 }
919
920
921 /**
922  * Task shutting down testcase if it a timeout occurs
923  */
924 static void
925 task_timeout (void *cls,
926             const struct GNUNET_SCHEDULER_TaskContext *tc)
927 {
928   ti_timeout = GNUNET_SCHEDULER_NO_TASK;
929   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
930     return;
931
932   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Testcase timeout\n");
933   fail = GNUNET_YES;
934   shutdown_clean();
935   return;
936 }
937
938 static void pretty_printer_cb (void *cls,
939                                const char *address)
940 {
941   if (NULL==address)
942     return;
943   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Plugin returned pretty address: `%s'\n",address);
944   fail_pretty_printer_count++;
945 }
946
947 /**
948  * Runs every single test to test the plugin
949  */
950 static void run_connection_tests( int phase , void * cls)
951 {
952   struct GNUNET_MessageHeader * msg;
953   unsigned int size;
954
955   if (phase==0)
956   {
957     char * host_str = NULL;
958     /* resetting buffers */
959     buffer_in.size = HTTP_BUFFER_SIZE;
960     buffer_in.pos = 0;
961     buffer_in.len = 0;
962
963     buffer_out.size = HTTP_BUFFER_SIZE;
964     buffer_out.pos = 0;
965     buffer_out.len = 0;
966
967     if (test_no_ident.test_executed == GNUNET_NO)
968     {
969       /* Connecting to peer without identification */
970       char * ident = "";
971       GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
972       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer without any peer identification.\n"));
973       test_no_ident.test_executed = GNUNET_YES;
974       send_data ( &test_no_ident, host_str);
975       GNUNET_free (host_str);
976       return;
977     }
978     if (test_too_short_ident.test_executed == GNUNET_NO)
979     {
980       char * ident = "AAAAAAAAAA";
981       /* Connecting to peer with too short identification */
982       GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX,test_addr,ident);
983       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too short peer identification.\n"));
984       test_too_short_ident.test_executed = GNUNET_YES;
985       send_data ( &test_too_short_ident, host_str);
986       GNUNET_free (host_str);
987       return;
988     }
989
990     if (test_too_long_ident.test_executed == GNUNET_NO)
991     {
992       char * ident = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
993
994       /* Connecting to peer with too long identification */
995       GNUNET_asprintf (&host_str, "%s://%s/%s",PROTOCOL_PREFIX, test_addr,ident);
996       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with too long peer identification.\n"));
997       test_too_long_ident.test_executed = GNUNET_YES;
998       send_data ( &test_too_long_ident, host_str);
999       GNUNET_free (host_str);
1000       return;
1001     }
1002     if (test_valid_ident.test_executed == GNUNET_NO)
1003     {
1004       struct GNUNET_CRYPTO_HashAsciiEncoded ident;
1005       GNUNET_CRYPTO_hash_to_enc(&my_identity.hashPubKey,&ident);
1006       GNUNET_asprintf (&host_str, "%s://%s/%s%s",PROTOCOL_PREFIX, test_addr,(char *) &ident,";0");
1007       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Connecting to peer with valid peer identification.\n"));
1008       test_valid_ident.test_executed = GNUNET_YES;
1009       send_data ( &test_valid_ident, host_str);
1010       GNUNET_free (host_str);
1011       return;
1012     }
1013   }
1014   if (phase==1)
1015   {
1016     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\nPhase 1: transmit data to all suggested addresses\n\n");
1017     /* Using one of the addresses the plugin proposed */
1018     GNUNET_assert (addr_head->addr != NULL);
1019
1020     struct Plugin_Address * tmp_addr;
1021     struct GNUNET_MessageHeader msg;
1022     char * tmp = GNUNET_malloc(sizeof(struct GNUNET_MessageHeader));
1023     char address[INET6_ADDRSTRLEN];
1024     unsigned int port;
1025     unsigned int type = 10;
1026
1027     msg.size=htons(sizeof(struct GNUNET_MessageHeader));
1028     tmp_addr = addr_head;
1029     /* send a message to all addresses advertised by plugin */
1030
1031     int count = 0;
1032     while (tmp_addr != NULL)
1033     {
1034       if (tmp_addr->addrlen == (sizeof (struct IPv4HttpAddress)))
1035         {
1036           inet_ntop(AF_INET, (struct in_addr *) tmp_addr->addr,address,INET_ADDRSTRLEN);
1037           port = ntohs(((struct IPv4HttpAddress *) tmp_addr->addr)->u_port);
1038           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address, port);
1039         }
1040       if (tmp_addr->addrlen == (sizeof (struct IPv6HttpAddress)))
1041         {
1042           inet_ntop(AF_INET6, (struct in6_addr *) tmp_addr->addr,address,INET6_ADDRSTRLEN);
1043           port = ntohs(((struct IPv6HttpAddress *) tmp_addr->addr)->u6_port);
1044           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Sending message to addres no. %u: `%s':%u\n", count,address,port);
1045         }
1046       msg.type=htons(type);
1047       memcpy(tmp,&msg,sizeof(struct GNUNET_MessageHeader));
1048       api->send(api->cls, &my_identity, tmp, sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,tmp_addr->addr, tmp_addr->addrlen, GNUNET_YES, &task_send_cont, &fail_msgs_transmited_to_local_addrs);
1049       tmp_addr = tmp_addr->next;
1050
1051       count ++;
1052       type ++;
1053     }
1054     GNUNET_free(tmp);
1055     return;
1056   }
1057
1058   if (phase==2)
1059   {
1060     struct Session * session = cls;
1061     msg = GNUNET_malloc (sizeof(struct GNUNET_MessageHeader));
1062
1063     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 2: session selection\n\n");
1064     size = sizeof(struct GNUNET_MessageHeader);
1065     msg->size=htons(size);
1066     msg->type = htons(20);
1067     api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1068
1069     msg->type = htons(21);
1070     api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1071
1072     /* answer on session*/
1073     size = sizeof( struct GNUNET_MessageHeader);
1074     msg->size = htons(size);
1075     msg->type = htons(22);
1076     api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_SYSERR, &task_send_cont, NULL);
1077
1078     GNUNET_free(msg);
1079
1080     /* answer on session with big message not fitting in mhd send buffer*/
1081     size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1082     msg = GNUNET_malloc (size);
1083     msg->size=htons(size);
1084     msg->type = htons(23);
1085     api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, session, NULL, 0, GNUNET_NO, &task_send_cont, NULL);
1086     GNUNET_free(msg);
1087     return;
1088   }
1089
1090   if (phase==3)
1091   {
1092
1093     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: send multiple or big messages after disconnect\n\n");
1094     /* disconnect from peer, so new connections are created */
1095     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Disconnect from peer: `%s'\n", GNUNET_i2s(&my_identity));
1096     api->disconnect(api->cls, &my_identity);
1097
1098     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Phase 3: sending messages\n");
1099     /* send a multiple GNUNET_messages at a time*/
1100     size = 2 * sizeof(struct GNUNET_MessageHeader);
1101     msg = GNUNET_malloc( 2* size);
1102     msg->size = htons(size);
1103     msg->type = htons(30);
1104     struct GNUNET_MessageHeader * msg2 = &msg[2];
1105     msg2->size = htons(2 * sizeof(struct GNUNET_MessageHeader));
1106     msg2->type = htons(31);
1107     api->send(api->cls, &my_identity, (const char *) msg, 4 * sizeof(struct GNUNET_MessageHeader), 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_multiple_msgs_in_transmission);
1108     GNUNET_free(msg);
1109     /* send a message with size GNUNET_SERVER_MAX_MESSAGE_SIZE-1  */
1110
1111     size = GNUNET_SERVER_MAX_MESSAGE_SIZE-1;
1112     msg = GNUNET_malloc(size);
1113     msg->size = htons(size);
1114     msg->type = htons(32);
1115     api->send(api->cls, &my_identity, (const char *) msg, size, 0, TIMEOUT, NULL,addr_head->addr, addr_head->addrlen, GNUNET_NO, &task_send_cont, &fail_msg_transmited_max_size);
1116     GNUNET_free(msg);
1117     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No more tests to run\n");
1118   }
1119 }
1120
1121
1122 /**
1123  * Runs the test.
1124  *
1125  * @param cls closure
1126  * @param s scheduler to use
1127  * @param c configuration to use
1128  */
1129 static void
1130 run (void *cls,
1131      struct GNUNET_SCHEDULER_Handle *s,
1132      char *const *args,
1133      const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
1134 {
1135   char * libname;
1136   sched = s;
1137   cfg = c;
1138   char *keyfile;
1139   unsigned long long tneigh;
1140   struct Plugin_Address * cur;
1141   const char * addr_str;
1142
1143
1144   unsigned int suggest_res;
1145
1146   fail_pretty_printer = GNUNET_YES;
1147   fail_notify_address = GNUNET_YES;
1148   fail_addr_to_str = GNUNET_YES;
1149   fail_msgs_transmited_to_local_addrs = 0;
1150   fail_msg_transmited_max_size = GNUNET_YES;
1151   fail_multiple_msgs_in_transmission = 0;
1152   fail_session_selection_reliable = GNUNET_YES;
1153   fail_session_selection_reliable = GNUNET_YES;
1154   fail_session_selection_session = GNUNET_YES;
1155   fail_session_selection_session_big = GNUNET_YES;
1156
1157   addr_head = NULL;
1158   count_str_addr = 0;
1159   /* parse configuration */
1160   if ((GNUNET_OK !=
1161        GNUNET_CONFIGURATION_get_value_number (c,
1162                                               "TRANSPORT",
1163                                               "NEIGHBOUR_LIMIT",
1164                                               &tneigh)) ||
1165       (GNUNET_OK !=
1166        GNUNET_CONFIGURATION_get_value_filename (c,
1167                                                 "GNUNETD",
1168                                                 "HOSTKEY", &keyfile)))
1169     {
1170       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1171                   _("Transport service is lacking key configuration settings.  Exiting.\n"));
1172       GNUNET_SCHEDULER_shutdown (s);
1173       fail = 1;
1174       return;
1175     }
1176
1177   if ((GNUNET_OK !=
1178       GNUNET_CONFIGURATION_get_value_number (cfg,
1179                                              "transport-http",
1180                                              "PORT",
1181                                              &port)) ||
1182      (port > 65535) || (port == 0))
1183   {
1184     GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
1185                      "http",
1186                      _
1187                      ("Require valid port number for transport plugin `%s' in configuration!\n"),
1188                      "transport-http");
1189   }
1190
1191   max_connect_per_transport = (uint32_t) tneigh;
1192   my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
1193   GNUNET_free (keyfile);
1194   if (my_private_key == NULL)
1195     {
1196       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1197                   _("Transport service could not access hostkey.  Exiting.\n"));
1198       GNUNET_SCHEDULER_shutdown (s);
1199       fail = 1;
1200       return;
1201     }
1202
1203   GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key);
1204   GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &my_identity.hashPubKey);
1205
1206   /* assertions before start */
1207   GNUNET_assert ((port > 0) && (port <= 65535));
1208   GNUNET_assert(&my_public_key != NULL);
1209   GNUNET_assert(&my_identity.hashPubKey != NULL);
1210
1211   /* load plugins... */
1212   setup_plugin_environment ();
1213   GNUNET_asprintf (&libname, "libgnunet_plugin_transport_http");
1214   GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading HTTP transport plugin `%s'\n"),libname);
1215   api = GNUNET_PLUGIN_load (libname, &env);
1216   GNUNET_free (libname);
1217   if (api == NULL)
1218   {
1219     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1220                 _("Failed to load transport plugin for http\n"));
1221     fail = 1;
1222     return;
1223   }
1224
1225
1226   ti_timeout = GNUNET_SCHEDULER_add_delayed (sched, TEST_TIMEOUT, &task_timeout, NULL);
1227
1228   /* testing plugin functionality */
1229   GNUNET_assert (0!=fail_notify_address_count);
1230   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport plugin returned %u addresses to connect to\n",  fail_notify_address_count);
1231
1232   /* testing pretty printer with all addresses obtained from the plugin*/
1233   cur = addr_head;
1234   while (cur != NULL)
1235   {
1236
1237     api->address_pretty_printer (api->cls, "http",cur->addr,cur->addrlen, GNUNET_NO,TEST_TIMEOUT, &pretty_printer_cb,NULL);
1238     addr_str = api->address_to_string (api->cls, cur->addr, cur->addrlen);
1239     suggest_res = api->check_address (api->cls, cur->addr, cur->addrlen);
1240
1241     GNUNET_assert (GNUNET_OK == suggest_res);
1242     GNUNET_assert (NULL != addr_str);
1243     count_str_addr++;
1244     GNUNET_free ( (char *) addr_str);
1245     cur = cur->next;
1246   }
1247   GNUNET_assert (fail_pretty_printer_count > 0);
1248   GNUNET_assert (fail_pretty_printer_count==fail_notify_address_count);
1249   GNUNET_assert (fail_pretty_printer_count==count_str_addr);
1250   fail_pretty_printer=GNUNET_NO;
1251   fail_addr_to_str=GNUNET_NO;
1252
1253   /* Suggesting addresses with wrong port*/
1254   struct IPv4HttpAddress failing_addr;
1255   failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK);
1256   failing_addr.u_port = htons(0);
1257   suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv4HttpAddress));
1258   GNUNET_assert (GNUNET_SYSERR == suggest_res);
1259
1260   /* Suggesting addresses with wrong size*/
1261   failing_addr.ipv4_addr = htonl(INADDR_LOOPBACK);
1262   failing_addr.u_port = htons(0);
1263   suggest_res = api->check_address (api->cls,&failing_addr,sizeof (struct IPv6HttpAddress));
1264   GNUNET_assert (GNUNET_SYSERR == suggest_res);
1265
1266   /* Suggesting addresses with wrong address*/
1267   failing_addr.ipv4_addr = htonl(0xffc00000);
1268   failing_addr.u_port = htons(12389);
1269   suggest_res = api->check_address (api->cls,&failing_addr,100);
1270   GNUNET_assert (GNUNET_SYSERR == suggest_res);
1271
1272   /* test sending to client */
1273   multi_handle = curl_multi_init();
1274
1275   /* Setting up buffers */
1276   buffer_in.size = HTTP_BUFFER_SIZE;
1277   buffer_in.pos = 0;
1278   buffer_in.len = 0;
1279
1280   buffer_out.size = HTTP_BUFFER_SIZE;
1281   buffer_out.pos = 0;
1282   buffer_out.len = 0;
1283
1284   /* Setting up connection tests */
1285
1286   /* Test: connecting without a peer identification */
1287   test_no_ident.test_executed = GNUNET_NO;
1288   test_no_ident.test_failed = GNUNET_YES;
1289
1290   /* Test: connecting with too short peer identification */
1291   test_too_short_ident.test_executed = GNUNET_NO;
1292   test_too_short_ident.test_failed = GNUNET_YES;
1293
1294   /* Test: connecting with too long peer identification */
1295   test_too_long_ident.test_executed = GNUNET_NO;
1296   test_too_long_ident.test_failed = GNUNET_YES;
1297
1298   /* Test: connecting with valid identification */
1299   test_valid_ident.test_executed = GNUNET_NO;
1300   test_valid_ident.test_failed = GNUNET_YES;
1301
1302   test_addr = (char *) api->address_to_string (api->cls,addr_head->addr,addr_head->addrlen);
1303
1304   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Phase 0\n\n"));
1305   run_connection_tests(0, NULL);
1306
1307   /* testing finished */
1308
1309   return;
1310 }
1311
1312
1313 /**
1314  * The main function for the transport service.
1315  *
1316  * @param argc number of arguments from the command line
1317  * @param argv command line arguments
1318  * @return 0 ok, 1 on error
1319  */
1320 int
1321 main (int argc, char *const *argv)
1322 {
1323
1324   static struct GNUNET_GETOPT_CommandLineOption options[] = {
1325     GNUNET_GETOPT_OPTION_END
1326   };
1327   int ret;
1328   char *const argv_prog[] = {
1329     "test_plugin_transport_http",
1330     "-c",
1331     "test_plugin_transport_data_http.conf",
1332     "-L",
1333 #if VERBOSE
1334     "DEBUG",
1335 #else
1336     "WARNING",
1337 #endif
1338     NULL
1339   };
1340   GNUNET_log_setup ("test_plugin_transport_http",
1341 #if VERBOSE
1342                     "DEBUG",
1343 #else
1344                     "WARNING",
1345 #endif
1346                     NULL);
1347
1348   ret = (GNUNET_OK ==
1349          GNUNET_PROGRAM_run (5,
1350                              argv_prog,
1351                              "test_plugin_transport_http",
1352                              "testcase", options, &run, NULL)) ? GNUNET_NO : GNUNET_YES;
1353
1354     GNUNET_DISK_directory_remove ("/tmp/test_plugin_transport_http");
1355
1356   return fail;
1357 }
1358
1359 /* end of test_plugin_transport_http.c */