summaryrefslogtreecommitdiff
path: root/src/bank-lib
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-01-16 21:57:40 +0100
committerChristian Grothoff <christian@grothoff.org>2020-01-16 21:57:40 +0100
commita9ae2171b897dfc9635e9ab72a04d65379bf2208 (patch)
tree11d67216d1c5594a4048d333b56ac40b4cf0acd1 /src/bank-lib
parentdd6bad739a7b7539952af6bebb74bfe3ffa0f9d7 (diff)
downloadexchange-a9ae2171b897dfc9635e9ab72a04d65379bf2208.tar.gz
exchange-a9ae2171b897dfc9635e9ab72a04d65379bf2208.tar.bz2
exchange-a9ae2171b897dfc9635e9ab72a04d65379bf2208.zip
reuse TALER_url_join
Diffstat (limited to 'src/bank-lib')
-rw-r--r--src/bank-lib/bank_api_admin.c11
-rw-r--r--src/bank-lib/bank_api_common.c29
-rw-r--r--src/bank-lib/bank_api_common.h12
-rw-r--r--src/bank-lib/bank_api_credit.c18
-rw-r--r--src/bank-lib/bank_api_debit.c19
-rw-r--r--src/bank-lib/bank_api_transfer.c17
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 d81c54dd..d78cbaa2 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 5e7ce687..abdeee31 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 d2d022bd..de7f7d65 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 be4c1972..95e91d7d 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 1afe0e45..652dde8d 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 96ed0071..a23e515f 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");