From 2e28718de3bfbef0645d830c62b297e187474f85 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Wed, 29 Aug 2012 13:18:28 +0000 Subject: [PATCH] changes --- src/transport/plugin_transport_http_client.c | 33 +++++++++++++++----- src/transport/plugin_transport_http_server.c | 12 +++++++ src/transport/test_plugin_transport.c | 4 +-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 1f08d7bbb..e2bc39f0e 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c @@ -33,7 +33,7 @@ #endif -#define VERBOSE_CURL GNUNET_NO +#define VERBOSE_CURL GNUNET_YES #include "platform.h" #include "gnunet_protocols.h" @@ -322,10 +322,25 @@ client_exist_session (struct HTTP_Client_Plugin *plugin, struct Session *s) static int client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls) { - if (type == CURLINFO_TEXT) + char *ttype; + if ((type == CURLINFO_TEXT) || (type == CURLINFO_HEADER_IN) || (type == CURLINFO_HEADER_OUT)) { char text[size + 2]; + switch (type) { + case CURLINFO_TEXT: + ttype = "TEXT"; + break; + case CURLINFO_HEADER_IN: + ttype = "HEADER_IN"; + break; + case CURLINFO_HEADER_OUT: + ttype = "HEADER_OUT"; + break; + default: + break; + } + memcpy (text, data, size); if (text[size - 1] == '\n') text[size] = '\0'; @@ -336,10 +351,10 @@ client_log (CURL * curl, curl_infotype type, char *data, size_t size, void *cls) } #if BUILD_HTTPS GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-https_client", - "Connection: %p - %s", cls, text); + "Connection %p %s: %s", cls, ttype, text); #else GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-http_client", - "Connection %p: - %s", cls, text); + "Connection %p %s: %s", cls, ttype, text); #endif } return 0; @@ -918,7 +933,6 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) client_schedule (plugin, GNUNET_NO); } - static int client_connect (struct Session *s) { @@ -989,8 +1003,13 @@ client_connect (struct Session *s) curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0); #endif curl_easy_setopt (s->client_put, CURLOPT_URL, url); - curl_easy_setopt (s->client_put, CURLOPT_PUT, 1L); - //curl_easy_setopt (s->client_put, CURLOPT_HEADERFUNCTION, &curl_put_header_cb); + curl_easy_setopt (s->client_put, CURLOPT_UPLOAD, 1L); + /* + struct curl_slist *m_headerlist; + m_headerlist = NULL; + m_headerlist = curl_slist_append(m_headerlist, "Transfer-Encoding: chunked"); + curl_easy_setopt(s->client_put, CURLOPT_HTTPHEADER, m_headerlist);*/ + //curl_easy_setopt (s->client_put, CURLOPT_HEADERFUNCTION, &client_curl_header); //curl_easy_setopt (s->client_put, CURLOPT_WRITEHEADER, ps); curl_easy_setopt (s->client_put, CURLOPT_READFUNCTION, client_send_cb); curl_easy_setopt (s->client_put, CURLOPT_READDATA, s); diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 6ec0c77a0..f89e2210a 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -1152,6 +1152,12 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, struct Session *s; struct MHD_Response *response; + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + _("Access from connection %p (%u of %u) for %s %s url `%s' \n"), + sc, + plugin->cur_connections, plugin->max_connections, + method, version, url); + GNUNET_assert (cls != NULL); if (sc == NULL) { @@ -1363,7 +1369,13 @@ server_accept_cb (void *cls, const struct sockaddr *addr, socklen_t addr_len) struct HTTP_Server_Plugin *plugin = cls; if (plugin->cur_connections <= plugin->max_connections) + { + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + _("Accepting connection (%u of %u) from `%s'\n"), + plugin->cur_connections, plugin->max_connections, + GNUNET_a2s (addr, addr_len)); return MHD_YES; + } else { GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c index 4934dcdad..dae1130df 100644 --- a/src/transport/test_plugin_transport.c +++ b/src/transport/test_plugin_transport.c @@ -144,6 +144,7 @@ end () { struct AddressWrapper *w; int c = 0; + ok = 0; if (GNUNET_SCHEDULER_NO_TASK != timeout_task) { @@ -169,6 +170,7 @@ end () GNUNET_break (0); GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Plugin did not remove %u addresses \n"), c); + ok = 1; } @@ -182,8 +184,6 @@ end () GNUNET_HELPER_stop (suid_helper); suid_helper = NULL; } - - ok = 0; } static void -- 2.25.1