diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-18 11:08:57 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-09-18 11:08:57 +0000 |
commit | e5d90281a1b8b9d91e4ea754bc7831cf56c4a0c9 (patch) | |
tree | f4a6a12fd8569b53b95964b6902b4caa963a9701 /src/transport/plugin_transport_http_client.c | |
parent | d97fd0c17f23c6d74e8ec09871e9fa58b4231783 (diff) | |
download | gnunet-e5d90281a1b8b9d91e4ea754bc7831cf56c4a0c9.tar.gz gnunet-e5d90281a1b8b9d91e4ea754bc7831cf56c4a0c9.zip |
- changes to http
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 4b10eb52b..7ec0e682e 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | #define VERBOSE_CURL GNUNET_YES | 35 | #define VERBOSE_CURL GNUNET_YES |
36 | 36 | ||
37 | #define PUT_DISCONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) | 37 | #define PUT_DISCONNECT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
38 | 38 | ||
39 | #define ENABLE_PUT GNUNET_YES | 39 | #define ENABLE_PUT GNUNET_YES |
40 | #define ENABLE_GET GNUNET_YES | 40 | #define ENABLE_GET GNUNET_YES |
@@ -694,6 +694,8 @@ client_put_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
694 | client_schedule (s->plugin, GNUNET_YES); | 694 | client_schedule (s->plugin, GNUNET_YES); |
695 | } | 695 | } |
696 | 696 | ||
697 | |||
698 | |||
697 | /** | 699 | /** |
698 | * Callback method used with libcurl | 700 | * Callback method used with libcurl |
699 | * Method is called when libcurl needs to read data during sending | 701 | * Method is called when libcurl needs to read data during sending |
@@ -800,14 +802,13 @@ client_receive_mst_cb (void *cls, void *client, | |||
800 | struct HTTP_Client_Plugin *plugin; | 802 | struct HTTP_Client_Plugin *plugin; |
801 | struct GNUNET_TIME_Relative delay; | 803 | struct GNUNET_TIME_Relative delay; |
802 | struct GNUNET_ATS_Information atsi[2]; | 804 | struct GNUNET_ATS_Information atsi[2]; |
803 | //GNUNET_break (0); | ||
804 | if (GNUNET_YES != client_exist_session(p, s)) | 805 | if (GNUNET_YES != client_exist_session(p, s)) |
805 | { | 806 | { |
806 | GNUNET_break (0); | 807 | GNUNET_break (0); |
807 | return GNUNET_OK; | 808 | return GNUNET_OK; |
808 | } | 809 | } |
809 | plugin = s->plugin; | 810 | plugin = s->plugin; |
810 | //GNUNET_break (0); | 811 | |
811 | atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 812 | atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
812 | atsi[0].value = htonl (1); | 813 | atsi[0].value = htonl (1); |
813 | atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); | 814 | atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE); |
@@ -817,6 +818,7 @@ client_receive_mst_cb (void *cls, void *client, | |||
817 | delay = s->plugin->env->receive (plugin->env->cls, &s->target, message, | 818 | delay = s->plugin->env->receive (plugin->env->cls, &s->target, message, |
818 | (const struct GNUNET_ATS_Information *) &atsi, 2, | 819 | (const struct GNUNET_ATS_Information *) &atsi, 2, |
819 | s, s->addr, s->addrlen); | 820 | s, s->addr, s->addrlen); |
821 | |||
820 | s->next_receive = | 822 | s->next_receive = |
821 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | 823 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); |
822 | 824 | ||
@@ -833,10 +835,26 @@ client_receive_mst_cb (void *cls, void *client, | |||
833 | } | 835 | } |
834 | 836 | ||
835 | 837 | ||
838 | /** | ||
839 | * Callback method used with libcurl when data for a PUT connection are | ||
840 | * received. We do not expect data here, so we just dismiss it | ||
841 | * | ||
842 | * @param stream pointer where to write data | ||
843 | * @param size size of an individual element | ||
844 | * @param nmemb count of elements that can be written to the buffer | ||
845 | * @param cls destination pointer, passed to the libcurl handle | ||
846 | * @return bytes read from stream | ||
847 | */ | ||
848 | static size_t | ||
849 | client_receive_put (void *stream, size_t size, size_t nmemb, void *cls) | ||
850 | { | ||
851 | return size * nmemb; | ||
852 | } | ||
853 | |||
836 | 854 | ||
837 | /** | 855 | /** |
838 | * Callback method used with libcurl | 856 | * Callback method used with libcurl when data for a GET connection are |
839 | * Method is called when libcurl needs to write data during sending | 857 | * received. Forward to MST |
840 | * | 858 | * |
841 | * @param stream pointer where to write data | 859 | * @param stream pointer where to write data |
842 | * @param size size of an individual element | 860 | * @param size size of an individual element |
@@ -875,9 +893,8 @@ client_receive (void *stream, size_t size, size_t nmemb, void *cls) | |||
875 | } | 893 | } |
876 | if (NULL == s->msg_tk) | 894 | if (NULL == s->msg_tk) |
877 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); | 895 | s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s); |
878 | (void) GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, GNUNET_NO); | 896 | GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, GNUNET_NO); |
879 | return len; | 897 | return len; |
880 | |||
881 | } | 898 | } |
882 | 899 | ||
883 | 900 | ||
@@ -1118,7 +1135,7 @@ client_connect_put (struct Session *s) | |||
1118 | //curl_easy_setopt (s->client_put, CURLOPT_WRITEHEADER, ps); | 1135 | //curl_easy_setopt (s->client_put, CURLOPT_WRITEHEADER, ps); |
1119 | curl_easy_setopt (s->client_put, CURLOPT_READFUNCTION, client_send_cb); | 1136 | curl_easy_setopt (s->client_put, CURLOPT_READFUNCTION, client_send_cb); |
1120 | curl_easy_setopt (s->client_put, CURLOPT_READDATA, s); | 1137 | curl_easy_setopt (s->client_put, CURLOPT_READDATA, s); |
1121 | curl_easy_setopt (s->client_put, CURLOPT_WRITEFUNCTION, client_receive); | 1138 | curl_easy_setopt (s->client_put, CURLOPT_WRITEFUNCTION, client_receive_put); |
1122 | curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, s); | 1139 | curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, s); |
1123 | /* No timeout by default, timeout done with session timeout */ | 1140 | /* No timeout by default, timeout done with session timeout */ |
1124 | curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0); | 1141 | curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0); |