diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-07-16 20:36:12 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-07-16 20:36:12 +0200 |
commit | bbe0a0501959db1add350cae54b86cbd59d48c77 (patch) | |
tree | 7cc984130423428b38770f9da92c1daed2109f0d /src/curl | |
parent | ee1fbffa1c42f7ac3fc897e73e90c525037dd915 (diff) | |
download | gnunet-bbe0a0501959db1add350cae54b86cbd59d48c77.tar.gz gnunet-bbe0a0501959db1add350cae54b86cbd59d48c77.zip |
avoid boolean argument in GNUNET_CURL_job_add(), see #6188
Diffstat (limited to 'src/curl')
-rw-r--r-- | src/curl/curl.c | 48 |
1 files changed, 34 insertions, 14 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 | */ |
599 | struct GNUNET_CURL_Job * | 598 | struct GNUNET_CURL_Job * |
600 | GNUNET_CURL_job_add (struct GNUNET_CURL_Context *ctx, | 599 | GNUNET_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 | */ | ||
632 | struct GNUNET_CURL_Job * | ||
633 | GNUNET_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 | * |