aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-07-16 20:36:12 +0200
committerChristian Grothoff <christian@grothoff.org>2020-07-16 20:36:12 +0200
commitbbe0a0501959db1add350cae54b86cbd59d48c77 (patch)
tree7cc984130423428b38770f9da92c1daed2109f0d
parentee1fbffa1c42f7ac3fc897e73e90c525037dd915 (diff)
downloadgnunet-bbe0a0501959db1add350cae54b86cbd59d48c77.tar.gz
gnunet-bbe0a0501959db1add350cae54b86cbd59d48c77.zip
avoid boolean argument in GNUNET_CURL_job_add(), see #6188
-rw-r--r--src/curl/curl.c48
-rw-r--r--src/include/gnunet_curl_lib.h27
2 files changed, 56 insertions, 19 deletions
diff --git a/src/curl/curl.c b/src/curl/curl.c
index f43670944..b3d2af252 100644
--- a/src/curl/curl.c
+++ b/src/curl/curl.c
@@ -586,33 +586,27 @@ GNUNET_CURL_job_add2 (struct GNUNET_CURL_Context *ctx,
586 * CURLOPT_PRIVATE facility of the CURL @a eh. 586 * CURLOPT_PRIVATE facility of the CURL @a eh.
587 * 587 *
588 * This function modifies the CURL handle to add the 588 * This function modifies the CURL handle to add the
589 * "Content-Type: application/json" header if @a add_json is set. 589 * "Content-Type: application/json" header.
590 * 590 *
591 * @param ctx context to execute the job in 591 * @param ctx context to execute the job in
592 * @param eh curl easy handle for the request, will 592 * @param eh curl easy handle for the request, will
593 * be executed AND cleaned up 593 * be executed AND cleaned up
594 * @param add_json add "application/json" content type header
595 * @param jcc callback to invoke upon completion 594 * @param jcc callback to invoke upon completion
596 * @param jcc_cls closure for @a jcc 595 * @param jcc_cls closure for @a jcc
597 * @return NULL on error (in this case, @eh is still released!) 596 * @return NULL on error (in this case, @eh is still released!)
598 */ 597 */
599struct GNUNET_CURL_Job * 598struct GNUNET_CURL_Job *
600GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, 599GNUNET_CURL_job_add_with_ct_json (struct GNUNET_CURL_Context *ctx,
601 CURL *eh, 600 CURL *eh,
602 int add_json, 601 GNUNET_CURL_JobCompletionCallback jcc,
603 GNUNET_CURL_JobCompletionCallback jcc, 602 void *jcc_cls)
604 void *jcc_cls)
605{ 603{
606 struct GNUNET_CURL_Job *job; 604 struct GNUNET_CURL_Job *job;
607 struct curl_slist *job_headers = NULL; 605 struct curl_slist *job_headers = NULL;
608 606
609 if (GNUNET_YES == add_json) 607 GNUNET_assert (NULL != (job_headers =
610 { 608 curl_slist_append (NULL,
611 GNUNET_assert ( 609 "Content-Type: application/json")));
612 NULL != (job_headers =
613 curl_slist_append (NULL, "Content-Type: application/json")));
614 }
615
616 job = GNUNET_CURL_job_add2 (ctx, 610 job = GNUNET_CURL_job_add2 (ctx,
617 eh, 611 eh,
618 job_headers, 612 job_headers,
@@ -624,6 +618,32 @@ GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx,
624 618
625 619
626/** 620/**
621 * Schedule a CURL request to be executed and call the given @a jcc
622 * upon its completion. Note that the context will make use of the
623 * CURLOPT_PRIVATE facility of the CURL @a eh.
624 *
625 * @param ctx context to execute the job in
626 * @param eh curl easy handle for the request, will
627 * be executed AND cleaned up
628 * @param jcc callback to invoke upon completion
629 * @param jcc_cls closure for @a jcc
630 * @return NULL on error (in this case, @eh is still released!)
631 */
632struct GNUNET_CURL_Job *
633GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx,
634 CURL *eh,
635 GNUNET_CURL_JobCompletionCallback jcc,
636 void *jcc_cls)
637{
638 return GNUNET_CURL_job_add2 (ctx,
639 eh,
640 NULL,
641 jcc,
642 jcc_cls);
643}
644
645
646/**
627 * Cancel a job. Must only be called before the job completion 647 * Cancel a job. Must only be called before the job completion
628 * callback is called for the respective job. 648 * callback is called for the respective job.
629 * 649 *
diff --git a/src/include/gnunet_curl_lib.h b/src/include/gnunet_curl_lib.h
index 0bb337ee7..8f744512d 100644
--- a/src/include/gnunet_curl_lib.h
+++ b/src/include/gnunet_curl_lib.h
@@ -225,13 +225,9 @@ typedef void
225 * upon its completion. Note that the context will make use of the 225 * upon its completion. Note that the context will make use of the
226 * CURLOPT_PRIVATE facility of the CURL @a eh. 226 * CURLOPT_PRIVATE facility of the CURL @a eh.
227 * 227 *
228 * This function modifies the CURL handle to add the
229 * "Content-Type: application/json" header if @a add_json is set.
230 *
231 * @param ctx context to execute the job in 228 * @param ctx context to execute the job in
232 * @param eh curl easy handle for the request, will 229 * @param eh curl easy handle for the request, will
233 * be executed AND cleaned up 230 * be executed AND cleaned up
234 * @param add_json add "application/json" content type header
235 * @param jcc callback to invoke upon completion 231 * @param jcc callback to invoke upon completion
236 * @param jcc_cls closure for @a jcc 232 * @param jcc_cls closure for @a jcc
237 * @return NULL on error (in this case, @eh is still released!) 233 * @return NULL on error (in this case, @eh is still released!)
@@ -239,12 +235,33 @@ typedef void
239struct GNUNET_CURL_Job * 235struct GNUNET_CURL_Job *
240GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, 236GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx,
241 CURL *eh, 237 CURL *eh,
242 int add_json,
243 GNUNET_CURL_JobCompletionCallback jcc, 238 GNUNET_CURL_JobCompletionCallback jcc,
244 void *jcc_cls); 239 void *jcc_cls);
245 240
246 241
247/** 242/**
243 * Schedule a CURL request to be executed and call the given @a jcc
244 * upon its completion. Note that the context will make use of the
245 * CURLOPT_PRIVATE facility of the CURL @a eh.
246 *
247 * This function modifies the CURL handle to add the
248 * "Content-Type: application/json" header.
249 *
250 * @param ctx context to execute the job in
251 * @param eh curl easy handle for the request, will
252 * be executed AND cleaned up
253 * @param jcc callback to invoke upon completion
254 * @param jcc_cls closure for @a jcc
255 * @return NULL on error (in this case, @eh is still released!)
256 */
257struct GNUNET_CURL_Job *
258GNUNET_CURL_job_add_with_ct_json (struct GNUNET_CURL_Context *ctx,
259 CURL *eh,
260 GNUNET_CURL_JobCompletionCallback jcc,
261 void *jcc_cls);
262
263
264/**
248 * Force use of the provided username and password 265 * Force use of the provided username and password
249 * for client authentication for all operations performed 266 * for client authentication for all operations performed
250 * with @a ctx. 267 * with @a ctx.