diff options
6 files changed, 198 insertions, 6 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index f198b5a6b..8367fb1b1 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -30,13 +30,15 @@ if HAVE_LIBGNURL | |||
30 | HTTP_API_TEST = test_transport_api_http | 30 | HTTP_API_TEST = test_transport_api_http |
31 | HTTP_REVERSE_API_TEST = test_transport_api_http_reverse | 31 | HTTP_REVERSE_API_TEST = test_transport_api_http_reverse |
32 | HTTP_API_TIMEOUT_TEST = test_transport_api_timeout_http | 32 | HTTP_API_TIMEOUT_TEST = test_transport_api_timeout_http |
33 | HTTP_REL_TEST = test_transport_api_reliability_http | 33 | HTTP_REL_TEST = test_transport_api_reliability_http \ |
34 | test_transport_api_reliability_http_xhr | ||
34 | HTTP_QUOTA_TEST = test_quota_compliance_http \ | 35 | HTTP_QUOTA_TEST = test_quota_compliance_http \ |
35 | test_quota_compliance_http_asymmetric | 36 | test_quota_compliance_http_asymmetric |
36 | HTTP_SWITCH = test_transport_address_switch_http | 37 | HTTP_SWITCH = test_transport_address_switch_http |
37 | HTTPS_API_TEST = test_transport_api_https | 38 | HTTPS_API_TEST = test_transport_api_https |
38 | HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https | 39 | HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https |
39 | HTTPS_REL_TEST = test_transport_api_reliability_https | 40 | HTTPS_REL_TEST = test_transport_api_reliability_https \ |
41 | test_transport_api_reliability_https_xhr | ||
40 | HTTPS_QUOTA_TEST = test_quota_compliance_https \ | 42 | HTTPS_QUOTA_TEST = test_quota_compliance_https \ |
41 | test_quota_compliance_https_asymmetric | 43 | test_quota_compliance_https_asymmetric |
42 | HTTPS_SWITCH = test_transport_address_switch_https | 44 | HTTPS_SWITCH = test_transport_address_switch_https |
@@ -933,6 +935,14 @@ test_transport_api_reliability_http_LDADD = \ | |||
933 | $(top_builddir)/src/util/libgnunetutil.la \ | 935 | $(top_builddir)/src/util/libgnunetutil.la \ |
934 | $(top_builddir)/src/transport/libgnunettransporttesting.la | 936 | $(top_builddir)/src/transport/libgnunettransporttesting.la |
935 | 937 | ||
938 | test_transport_api_reliability_http_xhr_SOURCES = \ | ||
939 | test_transport_api_reliability.c | ||
940 | test_transport_api_reliability_http_xhr_LDADD = \ | ||
941 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
942 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
943 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
944 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
945 | |||
936 | test_quota_compliance_http_SOURCES = \ | 946 | test_quota_compliance_http_SOURCES = \ |
937 | test_quota_compliance.c | 947 | test_quota_compliance.c |
938 | test_quota_compliance_http_LDADD = \ | 948 | test_quota_compliance_http_LDADD = \ |
@@ -991,6 +1001,14 @@ test_transport_api_reliability_https_LDADD = \ | |||
991 | $(top_builddir)/src/util/libgnunetutil.la \ | 1001 | $(top_builddir)/src/util/libgnunetutil.la \ |
992 | $(top_builddir)/src/transport/libgnunettransporttesting.la | 1002 | $(top_builddir)/src/transport/libgnunettransporttesting.la |
993 | 1003 | ||
1004 | test_transport_api_reliability_https_xhr_SOURCES = \ | ||
1005 | test_transport_api_reliability.c | ||
1006 | test_transport_api_reliability_https_xhr_LDADD = \ | ||
1007 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
1008 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
1009 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
1010 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
1011 | |||
994 | test_transport_api_reliability_unix_SOURCES = \ | 1012 | test_transport_api_reliability_unix_SOURCES = \ |
995 | test_transport_api_reliability.c | 1013 | test_transport_api_reliability.c |
996 | test_transport_api_reliability_unix_LDADD = \ | 1014 | test_transport_api_reliability_unix_LDADD = \ |
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 81ab4d5da..cf75ec5d7 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -353,6 +353,10 @@ struct HTTP_Client_Plugin | |||
353 | */ | 353 | */ |
354 | uint16_t use_ipv4; | 354 | uint16_t use_ipv4; |
355 | 355 | ||
356 | /** | ||
357 | * Should we emulate an XHR client for testing? | ||
358 | */ | ||
359 | int emulate_xhr; | ||
356 | }; | 360 | }; |
357 | 361 | ||
358 | 362 | ||
@@ -649,6 +653,16 @@ client_log (CURL *curl, | |||
649 | 653 | ||
650 | 654 | ||
651 | /** | 655 | /** |
656 | * Connect GET connection for a session | ||
657 | * | ||
658 | * @param s the session to connect | ||
659 | * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise | ||
660 | */ | ||
661 | static int | ||
662 | client_connect_get (struct Session *s); | ||
663 | |||
664 | |||
665 | /** | ||
652 | * Connect a HTTP put connection | 666 | * Connect a HTTP put connection |
653 | * | 667 | * |
654 | * @param s the session to connect | 668 | * @param s the session to connect |
@@ -983,6 +997,15 @@ client_send_cb (void *stream, | |||
983 | 997 | ||
984 | if (NULL == msg) | 998 | if (NULL == msg) |
985 | { | 999 | { |
1000 | if (GNUNET_YES == plugin->emulate_xhr) | ||
1001 | { | ||
1002 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1003 | "Session %p/connection %p: PUT request finished\n", | ||
1004 | s, s->put.easyhandle); | ||
1005 | s->put_tmp_disconnecting = GNUNET_YES; | ||
1006 | return 0; | ||
1007 | } | ||
1008 | |||
986 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1009 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
987 | "Session %p/connection %p: nothing to send, suspending\n", | 1010 | "Session %p/connection %p: nothing to send, suspending\n", |
988 | s, s->put.easyhandle); | 1011 | s, s->put.easyhandle); |
@@ -1343,7 +1366,15 @@ curl_easy_getinfo (easy_h, | |||
1343 | /* FIXME: who calls curl_multi_remove on 'easy_h' now!? */ | 1366 | /* FIXME: who calls curl_multi_remove on 'easy_h' now!? */ |
1344 | GNUNET_assert (plugin->cur_connections > 0); | 1367 | GNUNET_assert (plugin->cur_connections > 0); |
1345 | plugin->cur_connections--; | 1368 | plugin->cur_connections--; |
1346 | http_client_plugin_session_disconnect (plugin, s); | 1369 | /* If we are emulating an XHR client we need to make another GET |
1370 | * request. | ||
1371 | */ | ||
1372 | if (GNUNET_YES == plugin->emulate_xhr) | ||
1373 | { | ||
1374 | if (GNUNET_SYSERR == client_connect_get (s)) | ||
1375 | http_client_plugin_session_disconnect (plugin, s); | ||
1376 | } else | ||
1377 | http_client_plugin_session_disconnect (plugin, s); | ||
1347 | } | 1378 | } |
1348 | } | 1379 | } |
1349 | } | 1380 | } |
@@ -1413,7 +1444,15 @@ client_connect_get (struct Session *s) | |||
1413 | s->plugin->proxy_use_httpproxytunnel); | 1444 | s->plugin->proxy_use_httpproxytunnel); |
1414 | } | 1445 | } |
1415 | 1446 | ||
1416 | curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, s->url); | 1447 | if (GNUNET_YES == s->plugin->emulate_xhr) |
1448 | { | ||
1449 | char *url; | ||
1450 | |||
1451 | GNUNET_asprintf(&url, "%s,1", s->url); | ||
1452 | curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, url); | ||
1453 | GNUNET_free(url); | ||
1454 | } else | ||
1455 | curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, s->url); | ||
1417 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_HEADERFUNCTION, &curl_get_header_cb); | 1456 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_HEADERFUNCTION, &curl_get_header_cb); |
1418 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEHEADER, ps); | 1457 | //curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEHEADER, ps); |
1419 | curl_easy_setopt (s->get.easyhandle, CURLOPT_READFUNCTION, client_send_cb); | 1458 | curl_easy_setopt (s->get.easyhandle, CURLOPT_READFUNCTION, client_send_cb); |
@@ -1583,8 +1622,14 @@ client_connect (struct Session *s) | |||
1583 | "Initiating outbound session peer `%s' using address `%s'\n", | 1622 | "Initiating outbound session peer `%s' using address `%s'\n", |
1584 | GNUNET_i2s (&s->address->peer), s->url); | 1623 | GNUNET_i2s (&s->address->peer), s->url); |
1585 | 1624 | ||
1586 | if ((GNUNET_SYSERR == client_connect_get (s)) || | 1625 | if (GNUNET_SYSERR == client_connect_get (s)) |
1587 | (GNUNET_SYSERR == client_connect_put (s))) | 1626 | return GNUNET_SYSERR; |
1627 | /* If we are emulating an XHR client then delay sending a PUT request until | ||
1628 | * there is something to send. | ||
1629 | */ | ||
1630 | if (GNUNET_YES == plugin->emulate_xhr) | ||
1631 | s->put_tmp_disconnected = GNUNET_YES; | ||
1632 | else if (GNUNET_SYSERR == client_connect_put (s)) | ||
1588 | return GNUNET_SYSERR; | 1633 | return GNUNET_SYSERR; |
1589 | 1634 | ||
1590 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1635 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1970,6 +2015,12 @@ client_configure_plugin (struct HTTP_Client_Plugin *plugin) | |||
1970 | 2015 | ||
1971 | GNUNET_free_non_null (proxy_type); | 2016 | GNUNET_free_non_null (proxy_type); |
1972 | } | 2017 | } |
2018 | |||
2019 | /* Should we emulate an XHR client for testing? */ | ||
2020 | plugin->emulate_xhr | ||
2021 | = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg, | ||
2022 | plugin->name, | ||
2023 | "EMULATE_XHR"); | ||
1973 | return GNUNET_OK; | 2024 | return GNUNET_OK; |
1974 | } | 2025 | } |
1975 | 2026 | ||
diff --git a/src/transport/test_transport_api_reliability_http_xhr_peer1.conf b/src/transport/test_transport_api_reliability_http_xhr_peer1.conf new file mode 100644 index 000000000..c0cd835a5 --- /dev/null +++ b/src/transport/test_transport_api_reliability_http_xhr_peer1.conf | |||
@@ -0,0 +1,34 @@ | |||
1 | @INLINE@ template_cfg_peer1.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = /tmp/test-transport/api-http-p1/ | ||
4 | |||
5 | [transport-http_client] | ||
6 | EMULATE_XHR = YES | ||
7 | |||
8 | [transport-tcp] | ||
9 | TIMEOUT = 5 s | ||
10 | |||
11 | [transport-http] | ||
12 | PORT = 12180 | ||
13 | |||
14 | [arm] | ||
15 | PORT = 12185 | ||
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock | ||
17 | |||
18 | [statistics] | ||
19 | PORT = 12184 | ||
20 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock | ||
21 | |||
22 | [resolver] | ||
23 | PORT = 12183 | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock | ||
25 | |||
26 | [peerinfo] | ||
27 | PORT = 12182 | ||
28 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock | ||
29 | |||
30 | [transport] | ||
31 | PORT = 12181 | ||
32 | PLUGINS = http_client | ||
33 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock | ||
34 | |||
diff --git a/src/transport/test_transport_api_reliability_http_xhr_peer2.conf b/src/transport/test_transport_api_reliability_http_xhr_peer2.conf new file mode 100644 index 000000000..8d85cf7b1 --- /dev/null +++ b/src/transport/test_transport_api_reliability_http_xhr_peer2.conf | |||
@@ -0,0 +1,30 @@ | |||
1 | @INLINE@ template_cfg_peer2.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = /tmp/test-transport/api-http-p2/ | ||
4 | |||
5 | [transport-http_server] | ||
6 | PORT = 12090 | ||
7 | USE_IPv6 = NO | ||
8 | BINDTO = 127.0.0.1 | ||
9 | |||
10 | [arm] | ||
11 | PORT = 12195 | ||
12 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock | ||
13 | |||
14 | [statistics] | ||
15 | PORT = 12194 | ||
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock | ||
17 | |||
18 | [resolver] | ||
19 | PORT = 12193 | ||
20 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock | ||
21 | |||
22 | [peerinfo] | ||
23 | PORT = 12192 | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock | ||
25 | |||
26 | [transport] | ||
27 | PORT = 12191 | ||
28 | PLUGINS = http_server | ||
29 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock | ||
30 | |||
diff --git a/src/transport/test_transport_api_reliability_https_xhr_peer1.conf b/src/transport/test_transport_api_reliability_https_xhr_peer1.conf new file mode 100644 index 000000000..614e371da --- /dev/null +++ b/src/transport/test_transport_api_reliability_https_xhr_peer1.conf | |||
@@ -0,0 +1,28 @@ | |||
1 | @INLINE@ template_cfg_peer1.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = /tmp/test-transport/api-https-p1/ | ||
4 | |||
5 | [transport-https_client] | ||
6 | EMULATE_XHR = YES | ||
7 | |||
8 | [arm] | ||
9 | PORT = 12305 | ||
10 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock | ||
11 | |||
12 | [statistics] | ||
13 | PORT = 12304 | ||
14 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock | ||
15 | |||
16 | [resolver] | ||
17 | PORT = 12303 | ||
18 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock | ||
19 | |||
20 | [peerinfo] | ||
21 | PORT = 12302 | ||
22 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock | ||
23 | |||
24 | [transport] | ||
25 | PORT = 12301 | ||
26 | PLUGINS = https_client | ||
27 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock | ||
28 | |||
diff --git a/src/transport/test_transport_api_reliability_https_xhr_peer2.conf b/src/transport/test_transport_api_reliability_https_xhr_peer2.conf new file mode 100644 index 000000000..7f7f80778 --- /dev/null +++ b/src/transport/test_transport_api_reliability_https_xhr_peer2.conf | |||
@@ -0,0 +1,31 @@ | |||
1 | @INLINE@ template_cfg_peer2.conf | ||
2 | [PATHS] | ||
3 | GNUNET_TEST_HOME = /tmp/test-transport/api-https-p2/ | ||
4 | |||
5 | [transport-https_server] | ||
6 | PORT = 12310 | ||
7 | KEY_FILE = $GNUNET_TEST_HOME/https_key_p2.key | ||
8 | CERT_FILE = $GNUNET_TEST_HOME/https_cert_p2.crt | ||
9 | |||
10 | [arm] | ||
11 | PORT = 12315 | ||
12 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock | ||
13 | |||
14 | [statistics] | ||
15 | PORT = 12314 | ||
16 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock | ||
17 | |||
18 | [resolver] | ||
19 | PORT = 12313 | ||
20 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock | ||
21 | |||
22 | [peerinfo] | ||
23 | PORT = 12312 | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock | ||
25 | |||
26 | [transport] | ||
27 | PORT = 12311 | ||
28 | PLUGINS = https_server | ||
29 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock | ||
30 | |||
31 | |||