diff options
author | Christian Grothoff <christian@grothoff.org> | 2023-04-23 14:09:01 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2023-04-23 14:09:01 +0200 |
commit | 6d676cbe03368223204e01053cf392fa107922be (patch) | |
tree | 889af9605fc3caa896761e88e3741332ed0227ba /src/curl/curl.c | |
parent | a663353533b9833540a98da94961a906845f6dee (diff) | |
download | gnunet-6d676cbe03368223204e01053cf392fa107922be.tar.gz gnunet-6d676cbe03368223204e01053cf392fa107922be.zip |
log HTTP request status, URL and duration for every HTTP request we make at INFO-level
Diffstat (limited to 'src/curl/curl.c')
-rw-r--r-- | src/curl/curl.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c index b21153980..68c99dd75 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c | |||
@@ -125,6 +125,11 @@ struct GNUNET_CURL_Job | |||
125 | * after the job has finished. | 125 | * after the job has finished. |
126 | */ | 126 | */ |
127 | struct curl_slist *job_headers; | 127 | struct curl_slist *job_headers; |
128 | |||
129 | /** | ||
130 | * When did we start the job? | ||
131 | */ | ||
132 | struct GNUNET_TIME_Absolute start_time; | ||
128 | }; | 133 | }; |
129 | 134 | ||
130 | 135 | ||
@@ -415,6 +420,7 @@ setup_job (CURL *eh, | |||
415 | return NULL; | 420 | return NULL; |
416 | } | 421 | } |
417 | job = GNUNET_new (struct GNUNET_CURL_Job); | 422 | job = GNUNET_new (struct GNUNET_CURL_Job); |
423 | job->start_time = GNUNET_TIME_absolute_get (); | ||
418 | job->job_headers = all_headers; | 424 | job->job_headers = all_headers; |
419 | 425 | ||
420 | if ( (CURLE_OK != | 426 | if ( (CURLE_OK != |
@@ -743,6 +749,7 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx, | |||
743 | &n_completed))) | 749 | &n_completed))) |
744 | { | 750 | { |
745 | struct GNUNET_CURL_Job *job; | 751 | struct GNUNET_CURL_Job *job; |
752 | struct GNUNET_TIME_Relative duration; | ||
746 | long response_code; | 753 | long response_code; |
747 | void *response; | 754 | void *response; |
748 | 755 | ||
@@ -754,6 +761,7 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx, | |||
754 | (char **) &job)); | 761 | (char **) &job)); |
755 | GNUNET_assert (job->ctx == ctx); | 762 | GNUNET_assert (job->ctx == ctx); |
756 | response_code = 0; | 763 | response_code = 0; |
764 | duration = GNUNET_TIME_absolute_get_duration (job->start_time); | ||
757 | if (NULL != job->jcc_raw) | 765 | if (NULL != job->jcc_raw) |
758 | { | 766 | { |
759 | /* RAW mode, no parsing */ | 767 | /* RAW mode, no parsing */ |
@@ -777,6 +785,22 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx, | |||
777 | response); | 785 | response); |
778 | rc (response); | 786 | rc (response); |
779 | } | 787 | } |
788 | { | ||
789 | char *url = NULL; | ||
790 | |||
791 | if (CURLE_UNKNOWN_OPTION == | ||
792 | curl_easy_getinfo (job->easy_handle, | ||
793 | CURLINFO_EFFECTIVE_URL, | ||
794 | &url)) | ||
795 | url = "<unknown>"; | ||
796 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
797 | "HTTP request for `%s' finished with %u after %s\n", | ||
798 | url, | ||
799 | (unsigned int) response_code, | ||
800 | GNUNET_TIME_relative2s (duration, | ||
801 | true)); | ||
802 | /* Note: we MUST NOT free 'url' here */ | ||
803 | } | ||
780 | GNUNET_CURL_job_cancel (job); | 804 | GNUNET_CURL_job_cancel (job); |
781 | } | 805 | } |
782 | } | 806 | } |