diff options
Diffstat (limited to 'src/bank-lib')
-rw-r--r-- | src/bank-lib/bank_api_admin.c | 11 | ||||
-rw-r--r-- | src/bank-lib/bank_api_common.c | 29 | ||||
-rw-r--r-- | src/bank-lib/bank_api_common.h | 12 | ||||
-rw-r--r-- | src/bank-lib/bank_api_credit.c | 18 | ||||
-rw-r--r-- | src/bank-lib/bank_api_debit.c | 19 | ||||
-rw-r--r-- | src/bank-lib/bank_api_transfer.c | 17 |
6 files changed, 45 insertions, 61 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c index d81c54dd6..d78cbaa20 100644 --- a/src/bank-lib/bank_api_admin.c +++ b/src/bank-lib/bank_api_admin.c @@ -202,8 +202,15 @@ TALER_BANK_admin_add_incoming (struct GNUNET_CURL_Context *ctx, aai = GNUNET_new (struct TALER_BANK_AdminAddIncomingHandle); aai->cb = res_cb; aai->cb_cls = res_cb_cls; - aai->request_url = TALER_BANK_path_to_url_ (account_base_url, - "/admin/add-incoming"); + aai->request_url = TALER_url_join (account_base_url, + "admin/add-incoming", + NULL); + if (NULL == aai->request_url) + { + GNUNET_free (aai); + GNUNET_break (0); + return NULL; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting administrative transaction at `%s' for reserve %s\n", aai->request_url, diff --git a/src/bank-lib/bank_api_common.c b/src/bank-lib/bank_api_common.c index 5e7ce6876..abdeee31a 100644 --- a/src/bank-lib/bank_api_common.c +++ b/src/bank-lib/bank_api_common.c @@ -68,33 +68,4 @@ TALER_BANK_setup_auth_ (CURL *easy, } -/** - * Obtain the URL to use for an API request. - * FIXME: duplicates MAH_path_to_url2, and likely also logic in util! - * FIXME: duplicates TEAH_path_to_url2, and likely also logic in util! - * - * @param u base URL of the bank. - * @param path Taler API path (i.e. "/history"). - * - * @return the full URL to use with cURL, must be - * freed by the caller. - */ -char * -TALER_BANK_path_to_url_ (const char *u, - const char *path) -{ - char *url; - - if ( ('/' == path[0]) && - (0 < strlen (u)) && - ('/' == u[strlen (u) - 1]) ) - path++; /* avoid generating URL with "//" from concat */ - GNUNET_asprintf (&url, - "%s%s", - u, - path); - return url; -} - - /* end of bank_api_common.c */ diff --git a/src/bank-lib/bank_api_common.h b/src/bank-lib/bank_api_common.h index d2d022bd0..de7f7d659 100644 --- a/src/bank-lib/bank_api_common.h +++ b/src/bank-lib/bank_api_common.h @@ -51,16 +51,4 @@ TALER_BANK_setup_auth_ (CURL *easy, const struct TALER_BANK_AuthenticationData *auth); -/** - * Obtain the URL to use for an API request. - * - * @param u base URL of the bank - * @param path Taler API path (i.e. "/history") - * @return the full URL to use with cURL - */ -char * -TALER_BANK_path_to_url_ (const char *u, - const char *path); - - #endif diff --git a/src/bank-lib/bank_api_credit.c b/src/bank-lib/bank_api_credit.c index be4c1972e..95e91d7db 100644 --- a/src/bank-lib/bank_api_credit.c +++ b/src/bank-lib/bank_api_credit.c @@ -257,19 +257,27 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, ( (0 == start_row) && (0 < num_results) ) ) GNUNET_asprintf (&url, - "/history/incoming?delta=%lld", + "history/incoming?delta=%lld", (long long) num_results); else GNUNET_asprintf (&url, - "/history/incoming?delta=%lld&start=%llu", + "history/incoming?delta=%lld&start=%llu", (long long) num_results, start_row); hh = GNUNET_new (struct TALER_BANK_CreditHistoryHandle); hh->hcb = hres_cb; hh->hcb_cls = hres_cb_cls; + hh->request_url = TALER_url_join (bank_base_url, + url, + NULL); + GNUNET_free (url); + if (NULL == hh->request_url) + { + GNUNET_free (hh); + GNUNET_break (0); + return NULL; + } hh->bank_base_url = GNUNET_strdup (bank_base_url); - hh->request_url = TALER_BANK_path_to_url_ (bank_base_url, - url); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting history at `%s'\n", hh->request_url); @@ -285,7 +293,6 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, GNUNET_break (0); TALER_BANK_credit_history_cancel (hh); curl_easy_cleanup (eh); - GNUNET_free (url); return NULL; } hh->job = GNUNET_CURL_job_add2 (ctx, @@ -293,7 +300,6 @@ TALER_BANK_credit_history (struct GNUNET_CURL_Context *ctx, NULL, &handle_history_finished, hh); - GNUNET_free (url); return hh; } diff --git a/src/bank-lib/bank_api_debit.c b/src/bank-lib/bank_api_debit.c index 1afe0e457..652dde8d5 100644 --- a/src/bank-lib/bank_api_debit.c +++ b/src/bank-lib/bank_api_debit.c @@ -254,19 +254,26 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx, ( (0 == start_row) && (0 < num_results) ) ) GNUNET_asprintf (&url, - "/history/outgoing?delta=%lld", + "history/outgoing?delta=%lld", (long long) num_results); else GNUNET_asprintf (&url, - "/history/outgoing?delta=%lld&start=%llu", + "history/outgoing?delta=%lld&start=%llu", (long long) num_results, start_row); hh = GNUNET_new (struct TALER_BANK_DebitHistoryHandle); hh->hcb = hres_cb; hh->hcb_cls = hres_cb_cls; - hh->request_url = TALER_BANK_path_to_url_ (account_base_url, - url); - + hh->request_url = TALER_url_join (account_base_url, + url, + NULL); + GNUNET_free (url); + if (NULL == hh->request_url) + { + GNUNET_free (hh); + GNUNET_break (0); + return NULL; + } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Requesting history at `%s'\n", hh->request_url); @@ -282,7 +289,6 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx, GNUNET_break (0); TALER_BANK_debit_history_cancel (hh); curl_easy_cleanup (eh); - GNUNET_free (url); return NULL; } hh->job = GNUNET_CURL_job_add2 (ctx, @@ -290,7 +296,6 @@ TALER_BANK_debit_history (struct GNUNET_CURL_Context *ctx, NULL, &handle_history_finished, hh); - GNUNET_free (url); return hh; } diff --git a/src/bank-lib/bank_api_transfer.c b/src/bank-lib/bank_api_transfer.c index 96ed0071f..a23e515ff 100644 --- a/src/bank-lib/bank_api_transfer.c +++ b/src/bank-lib/bank_api_transfer.c @@ -288,6 +288,18 @@ TALER_BANK_execute_wire_transfer (struct GNUNET_CURL_Context *ctx, } TALER_amount_ntoh (&amount, &wp->amount); + weh = GNUNET_new (struct TALER_BANK_WireExecuteHandle); + weh->cb = cc; + weh->cb_cls = cc_cls; + weh->request_url = TALER_url_join (bank_base_url, + "transfer", + NULL); + if (NULL == weh->request_url) + { + GNUNET_free (weh); + GNUNET_break (0); + return NULL; + } transfer_obj = json_pack ("{s:o, s:o, s:s, s:o, s:s}", "request_uid", GNUNET_JSON_from_data_auto ( &wp->request_uid), @@ -300,11 +312,6 @@ TALER_BANK_execute_wire_transfer (struct GNUNET_CURL_Context *ctx, GNUNET_break (0); return NULL; } - weh = GNUNET_new (struct TALER_BANK_WireExecuteHandle); - weh->cb = cc; - weh->cb_cls = cc_cls; - weh->request_url = TALER_BANK_path_to_url_ (bank_base_url, - "/transfer"); weh->post_ctx.headers = curl_slist_append (weh->post_ctx.headers, "Content-Type: application/json"); |