diff options
Diffstat (limited to 'src/curl/curl.c')
-rw-r--r-- | src/curl/curl.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c index b6aef4f61..71672c780 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c | |||
@@ -759,6 +759,15 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
759 | "Downloaded body: %.*s\n", | 759 | "Downloaded body: %.*s\n", |
760 | (int) db->buf_size, | 760 | (int) db->buf_size, |
761 | (char *) db->buf); | 761 | (char *) db->buf); |
762 | if (CURLE_OK != | ||
763 | curl_easy_getinfo (eh, | ||
764 | CURLINFO_RESPONSE_CODE, | ||
765 | response_code)) | ||
766 | { | ||
767 | /* unexpected error... */ | ||
768 | GNUNET_break (0); | ||
769 | *response_code = 0; | ||
770 | } | ||
762 | if ((CURLE_OK != | 771 | if ((CURLE_OK != |
763 | curl_easy_getinfo (eh, | 772 | curl_easy_getinfo (eh, |
764 | CURLINFO_CONTENT_TYPE, | 773 | CURLINFO_CONTENT_TYPE, |
@@ -768,15 +777,6 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
768 | { | 777 | { |
769 | /* No content type or explicitly not JSON, refuse to parse | 778 | /* No content type or explicitly not JSON, refuse to parse |
770 | (but keep response code) */ | 779 | (but keep response code) */ |
771 | if (CURLE_OK != | ||
772 | curl_easy_getinfo (eh, | ||
773 | CURLINFO_RESPONSE_CODE, | ||
774 | response_code)) | ||
775 | { | ||
776 | /* unexpected error... */ | ||
777 | GNUNET_break (0); | ||
778 | *response_code = 0; | ||
779 | } | ||
780 | if (0 != db->buf_size) | 780 | if (0 != db->buf_size) |
781 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 781 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
782 | "Did NOT detect response `%.*s' as JSON\n", | 782 | "Did NOT detect response `%.*s' as JSON\n", |
@@ -786,6 +786,20 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
786 | } | 786 | } |
787 | if (MHD_HTTP_NO_CONTENT == *response_code) | 787 | if (MHD_HTTP_NO_CONTENT == *response_code) |
788 | return NULL; | 788 | return NULL; |
789 | if (0 == *response_code) | ||
790 | { | ||
791 | char *url; | ||
792 | |||
793 | if (CURLE_OK != | ||
794 | curl_easy_getinfo (eh, | ||
795 | CURLINFO_EFFECTIVE_URL, | ||
796 | &url)) | ||
797 | url = "<unknown URL>"; | ||
798 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
799 | "Failed to download response from `%s': \n", | ||
800 | url); | ||
801 | return NULL; | ||
802 | } | ||
789 | json = NULL; | 803 | json = NULL; |
790 | if (0 == db->eno) | 804 | if (0 == db->eno) |
791 | { | 805 | { |
@@ -802,18 +816,6 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
802 | GNUNET_free (db->buf); | 816 | GNUNET_free (db->buf); |
803 | db->buf = NULL; | 817 | db->buf = NULL; |
804 | db->buf_size = 0; | 818 | db->buf_size = 0; |
805 | if (NULL != json) | ||
806 | { | ||
807 | if (CURLE_OK != | ||
808 | curl_easy_getinfo (eh, | ||
809 | CURLINFO_RESPONSE_CODE, | ||
810 | response_code)) | ||
811 | { | ||
812 | /* unexpected error... */ | ||
813 | GNUNET_break (0); | ||
814 | *response_code = 0; | ||
815 | } | ||
816 | } | ||
817 | return json; | 819 | return json; |
818 | } | 820 | } |
819 | 821 | ||
@@ -825,8 +827,9 @@ GNUNET_CURL_download_get_result_ (struct GNUNET_CURL_DownloadBuffer *db, | |||
825 | * @param header header string; will be given to the context AS IS. | 827 | * @param header header string; will be given to the context AS IS. |
826 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. | 828 | * @return #GNUNET_OK if no errors occurred, #GNUNET_SYSERR otherwise. |
827 | */ | 829 | */ |
828 | int | 830 | enum GNUNET_GenericReturnValue |
829 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, const char *header) | 831 | GNUNET_CURL_append_header (struct GNUNET_CURL_Context *ctx, |
832 | const char *header) | ||
830 | { | 833 | { |
831 | ctx->common_headers = curl_slist_append (ctx->common_headers, header); | 834 | ctx->common_headers = curl_slist_append (ctx->common_headers, header); |
832 | if (NULL == ctx->common_headers) | 835 | if (NULL == ctx->common_headers) |
@@ -892,7 +895,7 @@ do_benchmark (CURLMsg *cmsg) | |||
892 | curl -w "foo%{size_request} -XPOST --data "ABC" $URL | 895 | curl -w "foo%{size_request} -XPOST --data "ABC" $URL |
893 | the CURLINFO_REQUEST_SIZE should be the whole size of the request | 896 | the CURLINFO_REQUEST_SIZE should be the whole size of the request |
894 | including headers and body. | 897 | including headers and body. |
895 | */// | 898 | */ |
896 | GNUNET_break (size_curl <= size_long); | 899 | GNUNET_break (size_curl <= size_long); |
897 | 900 | ||
898 | urd = get_url_benchmark_data (url, (unsigned int) response_code); | 901 | urd = get_url_benchmark_data (url, (unsigned int) response_code); |