From ef86866cee09c03bf426f1c84c15ecae0e5ba39d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 23 Aug 2020 16:52:26 +0200 Subject: add function GNUNET_CURL_extend_headers() --- src/curl/curl.c | 27 ++++++++++++++++++++++++++- src/include/gnunet_curl_lib.h | 22 ++++++++++++++++------ src/include/gnunet_setu_service.h | 1 - 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/curl/curl.c b/src/curl/curl.c index eb9dd6a29..d89c97176 100644 --- a/src/curl/curl.c +++ b/src/curl/curl.c @@ -471,6 +471,30 @@ setup_job (CURL *eh, } +/** + * Add @a extra_headers to the HTTP headers for @a job. + * + * @param[in,out] job the job to modify + * @param extra_headers headers to append + */ +void +GNUNET_CURL_extend_headers (struct GNUNET_CURL_Job *job, + const struct curl_slist *extra_headers) +{ + struct curl_slist *all_headers = job->job_headers; + + for (const struct curl_slist *curr = extra_headers; + NULL != curr; + curr = curr->next) + { + GNUNET_assert (NULL != + (all_headers = curl_slist_append (all_headers, + curr->data))); + } + job->job_headers = all_headers; +} + + /** * Schedule a CURL request to be executed and call the given @a jcc * upon its completion. Note that the context will make use of the @@ -864,7 +888,8 @@ do_benchmark (CURLMsg *cmsg) curl -w "foo%{size_request} -XPOST --data "ABC" $URL the CURLINFO_REQUEST_SIZE should be the whole size of the request including headers and body. - */GNUNET_break (size_curl <= size_long); + */// + GNUNET_break (size_curl <= size_long); urd = get_url_benchmark_data (url, (unsigned int) response_code); urd->count++; diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h index 9de58d608..f291d6b14 100644 --- a/src/include/gnunet_curl_lib.h +++ b/src/include/gnunet_curl_lib.h @@ -275,9 +275,8 @@ GNUNET_CURL_set_userpass (struct GNUNET_CURL_Context *ctx, /** - * Force use of the provided TLS client certificate - * for client authentication for all operations performed - * with @a ctx. + * Force use of the provided TLS client certificate for client authentication + * for all operations performed with @a ctx. * * Note that if the provided information is incorrect, * the earliest operation that could fail is @@ -298,9 +297,9 @@ GNUNET_CURL_set_tlscert (struct GNUNET_CURL_Context *ctx, /** - * Schedule a CURL request to be executed and call the given @a jcc - * upon its completion. Note that the context will make use of the - * CURLOPT_PRIVATE facility of the CURL @a eh. + * Schedule a CURL request to be executed and call the given @a jcc upon its + * completion. Note that the context will make use of the CURLOPT_PRIVATE + * facility of the CURL @a eh. * * This function modifies the CURL handle to add the * "Content-Type: application/json" header if @a add_json is set. @@ -344,6 +343,17 @@ GNUNET_CURL_job_add_raw (struct GNUNET_CURL_Context *ctx, void *jcc_cls); +/** + * Add @a extra_headers to the HTTP headers for @a job. + * + * @param[in,out] job the job to modify + * @param extra_headers headers to append + */ +void +GNUNET_CURL_extend_headers (struct GNUNET_CURL_Job *job, + const struct curl_slist *extra_headers); + + /** * Cancel a job. Must only be called before the job completion * callback is called for the respective job. diff --git a/src/include/gnunet_setu_service.h b/src/include/gnunet_setu_service.h index 459a6156b..634c5c40b 100644 --- a/src/include/gnunet_setu_service.h +++ b/src/include/gnunet_setu_service.h @@ -162,7 +162,6 @@ enum GNUNET_SETU_OptionType /** * Notify client also if we are sending a value to the other peer. - * FIXME: not implemented! */ GNUNET_SETU_OPTION_SYMMETRIC = 8 }; -- cgit v1.2.3