diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-30 14:17:30 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-30 15:05:58 +0200 |
commit | e8eb1ecc006ffd3d7aa99fc9d3e8d19eedd9d343 (patch) | |
tree | a01efd9ce01f20411adfe6607a32659554b5789f | |
parent | 6d4120e96a52cbd38fb761b03485303b5000215a (diff) | |
download | gnunet-e8eb1ecc006ffd3d7aa99fc9d3e8d19eedd9d343.tar.gz gnunet-e8eb1ecc006ffd3d7aa99fc9d3e8d19eedd9d343.zip |
-improve logging if there is no HTTP response
-rw-r--r-- | src/curl/curl.c | 21 | ||||
-rw-r--r-- | src/include/gnunet_curl_lib.h | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c index b6aef4f61..79aac74ce 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c | |||
@@ -784,6 +784,20 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
784 | (const char *) db->buf); | 784 | (const char *) db->buf); |
785 | return NULL; | 785 | return NULL; |
786 | } | 786 | } |
787 | if (0 == *response_code) | ||
788 | { | ||
789 | char *url; | ||
790 | |||
791 | if (CURLE_OK != | ||
792 | curl_easy_getinfo (eh, | ||
793 | CURLINFO_EFFECTIVE_URL, | ||
794 | &url)) | ||
795 | url = "<unknown URL>"; | ||
796 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
797 | "Failed to download response from `%s': \n", | ||
798 | url); | ||
799 | return NULL; | ||
800 | } | ||
787 | if (MHD_HTTP_NO_CONTENT == *response_code) | 801 | if (MHD_HTTP_NO_CONTENT == *response_code) |
788 | return NULL; | 802 | return NULL; |
789 | json = NULL; | 803 | json = NULL; |
@@ -825,8 +839,9 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
825 | * @param header header string; will be given to the context AS IS. | 839 | * @param header header string; will be given to the context AS IS. |
826 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. | 840 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. |
827 | */ | 841 | */ |
828 | int | 842 | enum GNUNET_GenericReturnValue |
829 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, const char *header) | 843 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, |
844 | const char *header) | ||
830 | { | 845 | { |
831 | ctx->common_headers = curl_slist_append (ctx->common_headers, header); | 846 | ctx->common_headers = curl_slist_append (ctx->common_headers, header); |
832 | if (NULL == ctx->common_headers) | 847 | if (NULL == ctx->common_headers) |
@@ -892,7 +907,7 @@ do_benchmark (CURLMsg *cmsg) | |||
892 | curl -w "foo%{size_request} -XPOST --data "ABC" $URL | 907 | curl -w "foo%{size_request} -XPOST --data "ABC" $URL |
893 | the CURLINFO_REQUEST_SIZE should be the whole size of the request | 908 | the CURLINFO_REQUEST_SIZE should be the whole size of the request |
894 | including headers and body. | 909 | including headers and body. |
895 | */// | 910 | */ |
896 | GNUNET_break (size_curl <= size_long); | 911 | GNUNET_break (size_curl <= size_long); |
897 | 912 | ||
898 | urd = get_url_benchmark_data (url, (unsigned int) response_code); | 913 | urd = get_url_benchmark_data (url, (unsigned int) response_code); |
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index f51e4b503..38acecc48 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h | |||
@@ -150,7 +150,7 @@ GNUNET_CURL_get_select_info (struct GNUNET_CURL_Context *ctx, | |||
150 | * @param header header string; will be given to the context AS IS. | 150 | * @param header header string; will be given to the context AS IS. |
151 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. | 151 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. |
152 | */ | 152 | */ |
153 | int | 153 | enum GNUNET_GenericReturnValue |
154 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, | 154 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, |
155 | const char *header); | 155 | const char *header); |
156 | 156 | ||