gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] branch master updated: use url helpers fro


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] branch master updated: use url helpers from taler util
Date: Wed, 31 Jan 2018 18:39:35 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 07cc75f  use url helpers from taler util
07cc75f is described below

commit 07cc75f2055ba4ae77d8272ea2cedffbb54b6842
Author: Florian Dold <address@hidden>
AuthorDate: Wed Jan 31 18:39:29 2018 +0100

    use url helpers from taler util
---
 src/backend/taler-merchant-httpd.c               |  98 ----------------
 src/backend/taler-merchant-httpd.h               |  11 --
 src/backend/taler-merchant-httpd_check-payment.c |  22 ++--
 src/backend/taler-merchant-httpd_proposal.c      |   4 +-
 src/backend/taler-merchant-httpd_refund.c        |  24 ++--
 src/backend/taler-merchant-httpd_tip-authorize.c |  13 ++-
 src/lib/Makefile.am                              |   1 -
 src/lib/merchant_api_check_payment.c             |  15 ++-
 src/lib/merchant_api_common.c                    | 136 -----------------------
 src/lib/merchant_api_common.h                    |  49 --------
 src/lib/merchant_api_history.c                   |   4 +-
 src/lib/merchant_api_pay.c                       |   4 +-
 src/lib/merchant_api_pay_abort.c                 |   3 +-
 src/lib/merchant_api_proposal.c                  |   7 +-
 src/lib/merchant_api_refund.c                    |   4 +-
 src/lib/merchant_api_tip_authorize.c             |   4 +-
 src/lib/merchant_api_tip_pickup.c                |   4 +-
 src/lib/merchant_api_track_transaction.c         |   4 +-
 src/lib/merchant_api_track_transfer.c            |  19 +---
 19 files changed, 54 insertions(+), 372 deletions(-)

diff --git a/src/backend/taler-merchant-httpd.c 
b/src/backend/taler-merchant-httpd.c
index 0645d91..0302e05 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -1451,101 +1451,3 @@ main (int argc,
     return 3;
   return (GNUNET_OK == result) ? 0 : 1;
 }
-
-
-/**
- * Concatenate two strings and grow the first buffer (of size n)
- * if necessary.
- */
-#define STR_CAT_GROW(s, p, n) do { \
-    for (; strlen (s) + strlen (p) >= n; (n) = (n) * 2); \
-    (s) = GNUNET_realloc ((s), (n)); \
-    GNUNET_assert (NULL != (s)); \
-    strncat (s, p, n); \
-  } while (0)
-
-
-/**
- * Make an absolute URL to the backend.
- *
- * @param connection MHD connection to take header values from
- * @param path path of the url
- * @param ... NULL-terminated key-value pairs (char *) for query parameters
- * @returns the URL, must be freed with #GNUNET_free
- */
-char *
-TMH_make_absolute_backend_url (struct MHD_Connection *connection,
-                               const char *path,
-                               ...)
-{
-  static CURL *curl = NULL;
-  if (NULL == curl)
-  {
-    curl = curl_easy_init();
-    GNUNET_assert (NULL != curl);
-  }
-
-  size_t n = 256;
-  char *res = GNUNET_malloc (n);
-
-  GNUNET_assert (NULL != res);
-
-  // By default we assume we're running under HTTP
-  const char *proto = "http";
-  const char *forwarded_proto = MHD_lookup_connection_value (connection, 
MHD_HEADER_KIND, "X-Forwarded-Proto");
-
-  if (NULL != forwarded_proto)
-    proto = forwarded_proto;
-
-  const char *host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, 
"Host");
-  const char *forwarded_host = MHD_lookup_connection_value (connection, 
MHD_HEADER_KIND, "X-Forwarded-Host");
-
-  const char *forwarded_prefix = MHD_lookup_connection_value (connection, 
MHD_HEADER_KIND, "X-Forwarded-Prefix");
-
-  if (NULL != forwarded_host)
-    host = forwarded_host;
-
-  if (NULL == host)
-  {
-    // Should never happen, at last the host header should be defined
-    GNUNET_break (0);
-    return NULL;
-  }
-
-  STR_CAT_GROW (res, proto, n);
-  STR_CAT_GROW (res, "://", n);
-  STR_CAT_GROW (res, host, n);
-  STR_CAT_GROW (res, "/", n);
-  if (NULL != forwarded_prefix)
-    STR_CAT_GROW (res, forwarded_prefix, n);
-  STR_CAT_GROW (res, path, n);
-
-  va_list args;
-  va_start (args, path);
-
-  unsigned int iparam = 0;
-
-  while (1) {
-    char *key = va_arg (args, char *);
-    if (NULL == key)
-      break;
-    char *value = va_arg (args, char *);
-    if (NULL == value)
-      continue;
-    if (0 == iparam)
-      STR_CAT_GROW (res, "?", n);
-    else
-      STR_CAT_GROW (res, "&", n);
-    iparam++;
-    char *urlencoded_value = curl_easy_escape (curl, value, strlen (value));
-    STR_CAT_GROW (res, key, n);
-    STR_CAT_GROW (res, "=", n);
-    STR_CAT_GROW (res, urlencoded_value, n);
-    curl_free (urlencoded_value);
-  }
-
-  va_end (args);
-
-  return res;
-}
-
diff --git a/src/backend/taler-merchant-httpd.h 
b/src/backend/taler-merchant-httpd.h
index baac847..726dc62 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -359,15 +359,4 @@ struct MerchantInstance *
 TMH_lookup_instance_json (struct json_t *json);
 
 
-/**
- * Make an absolute URL to the backend.
- *
- * @param connection MHD connection to take header values from
- * @param path path of the url
- * @param ... NULL-terminated key-value pairs (char *) for query parameters
- * @returns the URL, must be freed with #GNUNET_free
- */
-char *
-TMH_make_absolute_backend_url (struct MHD_Connection *connection, const char 
*path, ...);
-
 #endif
diff --git a/src/backend/taler-merchant-httpd_check-payment.c 
b/src/backend/taler-merchant-httpd_check-payment.c
index 6b6940d..247f798 100644
--- a/src/backend/taler-merchant-httpd_check-payment.c
+++ b/src/backend/taler-merchant-httpd_check-payment.c
@@ -136,10 +136,11 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
 
   if (NULL == contract_url)
   {
-    final_contract_url = TMH_make_absolute_backend_url (connection, 
"/public/proposal",
-                                                        "instance", 
instance_str,
-                                                        "order_id", order_id,
-                                                        NULL);
+    final_contract_url = TALER_url_absolute_mhd (connection, 
"/public/proposal",
+                                                 "instance", instance_str,
+                                                 "order_id", order_id,
+                                                 NULL);
+    GNUNET_assert (NULL != final_contract_url);
   }
   else
   {
@@ -314,12 +315,13 @@ MH_handler_check_payment (struct TMH_RequestHandler *rh,
 
 do_pay:
   {
-    char *url = TMH_make_absolute_backend_url (connection, 
"public/trigger-pay",
-                                               "contract_url", 
final_contract_url,
-                                               "session_id", session_id,
-                                               "resource_url", resource_url,
-                                               "h_contract_terms", 
h_contract_terms_str,
-                                               NULL);
+    char *url = TALER_url_absolute_mhd (connection, "public/trigger-pay",
+                                        "contract_url", final_contract_url,
+                                        "session_id", session_id,
+                                        "resource_url", resource_url,
+                                        "h_contract_terms", 
h_contract_terms_str,
+                                        NULL);
+    GNUNET_assert (NULL != url);
     int ret = TMH_RESPONSE_reply_json_pack (connection,
                                             MHD_HTTP_OK,
                                             "{s:s, s:b}",
diff --git a/src/backend/taler-merchant-httpd_proposal.c 
b/src/backend/taler-merchant-httpd_proposal.c
index 390ddd1..e117b50 100644
--- a/src/backend/taler-merchant-httpd_proposal.c
+++ b/src/backend/taler-merchant-httpd_proposal.c
@@ -255,9 +255,7 @@ proposal_put (struct MHD_Connection *connection,
   {
     char *url;
 
-    url = TMH_make_absolute_backend_url (connection,
-                                         "/public/pay",
-                                         NULL);
+    url = TALER_url_absolute_mhd (connection, "/public/pay", NULL);
     json_object_set_new (order,
                          "pay_url",
                          json_string (url));
diff --git a/src/backend/taler-merchant-httpd_refund.c 
b/src/backend/taler-merchant-httpd_refund.c
index f875be1..a9f5427 100644
--- a/src/backend/taler-merchant-httpd_refund.c
+++ b/src/backend/taler-merchant-httpd_refund.c
@@ -287,19 +287,19 @@ MH_handler_refund_increase (struct TMH_RequestHandler *rh,
     char *refund_pickup_url;
     char *refund_redirect_url;
 
-    refund_pickup_url = TMH_make_absolute_backend_url (connection,
-                                                       "/public/refund",
-                                                       "instance",
-                                                       mi->id,
-                                                       "order_id",
-                                                       order_id,
-                                                       NULL);
+    refund_pickup_url = TALER_url_absolute_mhd (connection,
+                                                "/public/refund",
+                                                "instance",
+                                                mi->id,
+                                                "order_id",
+                                                order_id,
+                                                NULL);
     GNUNET_assert (NULL != refund_pickup_url);
-    refund_redirect_url = TMH_make_absolute_backend_url (connection,
-                                                         "public/trigger-pay",
-                                                         "refund_url",
-                                                         refund_pickup_url,
-                                                         NULL);
+    refund_redirect_url = TALER_url_absolute_mhd (connection,
+                                                  "public/trigger-pay",
+                                                  "refund_url",
+                                                  refund_pickup_url,
+                                                  NULL);
     GNUNET_assert (NULL != refund_redirect_url);
     ret = TMH_RESPONSE_reply_json_pack (connection,
                                         MHD_HTTP_OK,
diff --git a/src/backend/taler-merchant-httpd_tip-authorize.c 
b/src/backend/taler-merchant-httpd_tip-authorize.c
index 5eb274d..f751883 100644
--- a/src/backend/taler-merchant-httpd_tip-authorize.c
+++ b/src/backend/taler-merchant-httpd_tip-authorize.c
@@ -20,6 +20,7 @@
  */
 #include "platform.h"
 #include <jansson.h>
+#include <taler/taler_util.h>
 #include <taler/taler_json_lib.h>
 #include "taler-merchant-httpd.h"
 #include "taler-merchant-httpd_mhd.h"
@@ -329,9 +330,9 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
 
     if (NULL == json_object_get (tac->root, "pickup_url"))
     {
-      char *pickup_url = TMH_make_absolute_backend_url (connection,
-                                                         "tip-pickup",
-                                                         NULL);
+      char *pickup_url = TALER_url_absolute_mhd (connection,
+                                                 "tip-pickup",
+                                                 NULL);
       GNUNET_assert (NULL != pickup_url);
       json_object_set_new (tac->root, "pickup_url", json_string (pickup_url));
       GNUNET_free (pickup_url);
@@ -431,9 +432,9 @@ MH_handler_tip_authorize (struct TMH_RequestHandler *rh,
                            "pickup_url", tac->pickup_url);
     tip_token_str = json_dumps (tip_token, JSON_COMPACT);
     GNUNET_assert (NULL != tip_token_str);
-    tip_redirect_url = TMH_make_absolute_backend_url (connection, 
"public/trigger-pay",
-                                                      "tip_token", 
tip_token_str,
-                                                      NULL);
+    tip_redirect_url = TALER_url_absolute_mhd (connection, 
"public/trigger-pay",
+                                               "tip_token", tip_token_str,
+                                               NULL);
     GNUNET_assert (NULL != tip_redirect_url);
     /* FIXME:  This is pretty redundant, but we want to support some older
      * merchant implementations.  Newer ones should only get the
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index d407ee0..79f2674 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -14,7 +14,6 @@ libtalermerchant_la_LDFLAGS = \
   -no-undefined
 
 libtalermerchant_la_SOURCES = \
-  merchant_api_common.c merchant_api_common.h \
   merchant_api_proposal.c \
   merchant_api_pay.c \
   merchant_api_tip_authorize.c \
diff --git a/src/lib/merchant_api_check_payment.c 
b/src/lib/merchant_api_check_payment.c
index 0b5b314..98e844d 100644
--- a/src/lib/merchant_api_check_payment.c
+++ b/src/lib/merchant_api_check_payment.c
@@ -30,7 +30,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -206,13 +205,13 @@ TALER_MERCHANT_check_payment (struct GNUNET_CURL_Context 
*ctx,
   cpo->ctx = ctx;
   cpo->cb = check_payment_cb;
   cpo->cb_cls = check_payment_cb_cls;
-  cpo->url = MAH_make_url (backend_url, "/check-payment",
-                           "instance", instance,
-                           "order_id", order_id,
-                           "resource_url", resource_url,
-                           "session_id", session_id,
-                           "session_sig", session_sig,
-                           NULL);
+  cpo->url = TALER_url_join (backend_url, "/check-payment",
+                             "instance", instance,
+                             "order_id", order_id,
+                             "resource_url", resource_url,
+                             "session_id", session_id,
+                             "session_sig", session_sig,
+                             NULL);
   eh = curl_easy_init ();
   if (CURLE_OK != curl_easy_setopt (eh,
                                     CURLOPT_URL,
diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c
deleted file mode 100644
index c5b4a78..0000000
--- a/src/lib/merchant_api_common.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014-2017 GNUnet e.V. and INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 2.1, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
-
-  You should have received a copy of the GNU Lesser General Public License 
along with
-  TALER; see the file COPYING.LGPL.  If not, see
-  <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/merchant_api_common.c
- * @brief Shared functionality
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <gnunet/gnunet_util_lib.h>
-
-
-/**
- * Obtain the URL to use for an API request.
- *
- * @param base_url base URL of the exchange (i.e. "http://exchange/";)
- * @param path Taler API path (i.e. "/reserve/withdraw")
- * @return the full URL to use with cURL
- */
-char *
-MAH_path_to_url_ (const char *base_url,
-                 const char *path)
-{
-  char *url;
-
-  if ( ('/' == path[0]) &&
-       (0 < strlen (base_url)) &&
-       ('/' == base_url[strlen (base_url) - 1]) )
-    path++; /* avoid generating URL with "//" from concat */
-  GNUNET_asprintf (&url,
-                   "%s%s",
-                   base_url,
-                   path);
-  return url;
-}
-
-
-/**
- * Concatenate two strings and grow the first buffer (of size n)
- * if necessary.
- */
-#define STR_CAT_GROW(s, p, n) do { \
-    for (; strlen (s) + strlen (p) >= n; (n) = (n) * 2); \
-    (s) = GNUNET_realloc ((s), (n)); \
-    GNUNET_assert (NULL != (s)); \
-    strncat (s, p, n); \
-  } while (0)
-
-
-/**
- * Make an absolute URL with query parameters.
- *
- * @param base_url absolute base URL to use
- * @param path path of the url
- * @param ... NULL-terminated key-value pairs (char *) for query parameters
- * @returns the URL, must be freed with #GNUNET_free
- */
-char *
-MAH_make_url (const char *base_url,
-              const char *path,
-              ...)
-{
-  static CURL *curl = NULL;
-  if (NULL == curl)
-  {
-    curl = curl_easy_init();
-    GNUNET_assert (NULL != curl);
-  }
-
-  size_t n = 256;
-  char *res = GNUNET_malloc (n);
-
-  GNUNET_assert (NULL != res);
-
-  STR_CAT_GROW (res, base_url, n);
-
-  if ( ('/' == path[0]) &&
-       (0 < strlen (base_url)) &&
-       ('/' == base_url[strlen (base_url) - 1]) )
-  {
-   /* avoid generating URL with "//" from concat */
-    path++;
-  }
-  else if ( ('/' != path[0]) && 
-            ('/' != base_url[strlen (base_url) - 1]))
-  {
-    /* put '/' between path and base URL if necessary */
-    STR_CAT_GROW (res, "/", n);
-  }
-
-  STR_CAT_GROW (res, path, n);
-
-  va_list args;
-  va_start (args, path);
-
-  unsigned int iparam = 0;
-
-  while (1) {
-    char *key = va_arg (args, char *);
-    if (NULL == key)
-      break;
-    char *value = va_arg (args, char *);
-    if (NULL == value)
-      continue;
-    if (0 == iparam)
-      STR_CAT_GROW (res, "?", n);
-    else
-      STR_CAT_GROW (res, "&", n);
-    iparam++;
-    char *urlencoded_value = curl_easy_escape (curl, value, strlen (value));
-    STR_CAT_GROW (res, key, n);
-    STR_CAT_GROW (res, "=", n);
-    STR_CAT_GROW (res, urlencoded_value, n);
-    curl_free (urlencoded_value);
-  }
-
-  va_end (args);
-
-  return res;
-}
-
-/* end of merchant_api_common.c */
diff --git a/src/lib/merchant_api_common.h b/src/lib/merchant_api_common.h
deleted file mode 100644
index c94287f..0000000
--- a/src/lib/merchant_api_common.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-  This file is part of TALER
-  Copyright (C) 2014-2017 GNUnet e.V. and INRIA
-
-  TALER is free software; you can redistribute it and/or modify it under the
-  terms of the GNU Lesser General Public License as published by the Free 
Software
-  Foundation; either version 2.1, or (at your option) any later version.
-
-  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
-
-  You should have received a copy of the GNU Lesser General Public License 
along with
-  TALER; see the file COPYING.LGPL.  If not, see
-  <http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/merchant_api_common.h
- * @brief Shared functions
- * @author Christian Grothoff
- */
-#ifndef MERCHANT_API_COMMON_H
-#define MERCHANT_API_COMMON_H
-
-/**
- * Obtain the URL to use for an API request.
- *
- * @param base_url base URL of the exchange (i.e. "http://exchange/";)
- * @param path Taler API path (i.e. "/reserve/withdraw")
- * @return the full URL to use with cURL
- */
-char *
-MAH_path_to_url_ (const char *base_url,
-                 const char *path);
-
-/**
- * Make an absolute URL with query parameters.
- *
- * @param base_url absolute base URL to use
- * @param path path of the url
- * @param ... NULL-terminated key-value pairs (char *) for query parameters
- * @returns the URL, must be freed with #GNUNET_free
- */
-char *
-MAH_make_url (const char *base_url,
-              const char *path,
-              ...);
-
-#endif
diff --git a/src/lib/merchant_api_history.c b/src/lib/merchant_api_history.c
index 8aa38dc..0a3e01a 100644
--- a/src/lib/merchant_api_history.c
+++ b/src/lib/merchant_api_history.c
@@ -27,7 +27,6 @@
 #include <gnunet/gnunet_curl_lib.h>
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -167,8 +166,7 @@ TALER_MERCHANT_history (struct GNUNET_CURL_Context *ctx,
   ho->cb = history_cb;
   ho->cb_cls = history_cb_cls;
   seconds = date.abs_value_us / 1000LL / 1000LL;
-  base = MAH_path_to_url_ (backend_url,
-                          "/history");
+  base = TALER_url_join (backend_url, "/history", NULL);
   GNUNET_asprintf (&ho->url,
                    "%s?date=%llu&instance=%s&start=%d&delta=%d",
                    base,
diff --git a/src/lib/merchant_api_pay.c b/src/lib/merchant_api_pay.c
index 9b05467..849b22b 100644
--- a/src/lib/merchant_api_pay.c
+++ b/src/lib/merchant_api_pay.c
@@ -29,7 +29,6 @@
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
 #include <taler/taler_exchange_service.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -564,8 +563,7 @@ request_pay_generic (struct GNUNET_CURL_Context *ctx,
   ph->abort_cb_cls = abort_cb_cls;
   ph->pay_cb = pay_cb;
   ph->pay_cb_cls = pay_cb_cls;
-  ph->url = MAH_path_to_url_ (merchant_url,
-                             "/public/pay");
+  ph->url = TALER_url_join (merchant_url, "/public/pay", NULL);
   ph->num_coins = num_coins;
   ph->coins = GNUNET_new_array (num_coins,
                                 struct TALER_MERCHANT_PaidCoin);
diff --git a/src/lib/merchant_api_pay_abort.c b/src/lib/merchant_api_pay_abort.c
index d9fb2e1..eb7d219 100644
--- a/src/lib/merchant_api_pay_abort.c
+++ b/src/lib/merchant_api_pay_abort.c
@@ -440,8 +440,7 @@ TALER_MERCHANT_pay_wallet (struct GNUNET_CURL_Context *ctx,
   ph->ctx = ctx;
   ph->cb = pay_cb;
   ph->cb_cls = pay_cb_cls;
-  ph->url = MAH_path_to_url_ (merchant_url,
-                             "/pay");
+  ph->url = TALER_url_join (merchant_url, "/pay", NULL);
   ph->num_coins = num_coins;
   ph->coins = GNUNET_new_array (num_coins,
                                 struct TALER_MERCHANT_PaidCoin);
diff --git a/src/lib/merchant_api_proposal.c b/src/lib/merchant_api_proposal.c
index 936e0eb..8f4f67f 100644
--- a/src/lib/merchant_api_proposal.c
+++ b/src/lib/merchant_api_proposal.c
@@ -29,7 +29,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -215,8 +214,7 @@ TALER_MERCHANT_order_put (struct GNUNET_CURL_Context *ctx,
   po->ctx = ctx;
   po->cb = proposal_cb;
   po->cb_cls = proposal_cb_cls;
-  po->url = MAH_path_to_url_ (backend_url,
-                             "/order");
+  po->url = TALER_url_join (backend_url, "/order", NULL);
   req = json_pack ("{s:O}",
                    "order", (json_t *) order);
   eh = curl_easy_init ();
@@ -373,8 +371,7 @@ TALER_MERCHANT_proposal_lookup (struct GNUNET_CURL_Context 
*ctx,
   plo->ctx = ctx;
   plo->cb = plo_cb;
   plo->cb_cls = plo_cb_cls;
-  base = MAH_path_to_url_ (backend_url,
-                          "/public/proposal");
+  base = TALER_url_join (backend_url, "/public/proposal", NULL);
   if (NULL != nonce)
   {
     char *nonce_str;
diff --git a/src/lib/merchant_api_refund.c b/src/lib/merchant_api_refund.c
index 0307c42..01fa6bd 100644
--- a/src/lib/merchant_api_refund.c
+++ b/src/lib/merchant_api_refund.c
@@ -30,7 +30,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 struct TALER_MERCHANT_RefundLookupOperation
@@ -196,8 +195,7 @@ TALER_MERCHANT_refund_increase (struct GNUNET_CURL_Context 
*ctx,
   rio->ctx = ctx;
   rio->cb = cb;
   rio->cb_cls = cb_cls;
-  rio->url = MAH_path_to_url_ (backend_url,
-                              "/refund");
+  rio->url = TALER_url_join (backend_url, "/refund", NULL);
   req = json_pack ("{s:o, s:s, s:s, s:s}",
                    "refund", TALER_JSON_from_amount (refund),
                    "order_id", order_id,
diff --git a/src/lib/merchant_api_tip_authorize.c 
b/src/lib/merchant_api_tip_authorize.c
index e9b263b..f27d06f 100644
--- a/src/lib/merchant_api_tip_authorize.c
+++ b/src/lib/merchant_api_tip_authorize.c
@@ -29,7 +29,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -203,8 +202,7 @@ TALER_MERCHANT_tip_authorize (struct GNUNET_CURL_Context 
*ctx,
   tao->ctx = ctx;
   tao->cb = authorize_cb;
   tao->cb_cls = authorize_cb_cls;
-  tao->url = MAH_path_to_url_ (backend_url,
-                               "/tip-authorize");
+  tao->url = TALER_url_join (backend_url, "/tip-authorize", NULL);
   te_obj = json_pack ("{"
                       " s:o," /* amount */
                       " s:s," /* instance */
diff --git a/src/lib/merchant_api_tip_pickup.c 
b/src/lib/merchant_api_tip_pickup.c
index 4ca3b80..3bf38e4 100644
--- a/src/lib/merchant_api_tip_pickup.c
+++ b/src/lib/merchant_api_tip_pickup.c
@@ -29,7 +29,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -282,8 +281,7 @@ TALER_MERCHANT_tip_pickup (struct GNUNET_CURL_Context *ctx,
   tpo->ctx = ctx;
   tpo->cb = pickup_cb;
   tpo->cb_cls = pickup_cb_cls;
-  tpo->url = MAH_path_to_url_ (backend_url,
-                               "/public/tip-pickup");
+  tpo->url = TALER_url_join (backend_url, "/public/tip-pickup", NULL);
   if (NULL == (tpo->json_enc =
                json_dumps (tp_obj,
                            JSON_COMPACT)))
diff --git a/src/lib/merchant_api_track_transaction.c 
b/src/lib/merchant_api_track_transaction.c
index d48916a..e38660c 100644
--- a/src/lib/merchant_api_track_transaction.c
+++ b/src/lib/merchant_api_track_transaction.c
@@ -30,7 +30,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -152,8 +151,7 @@ TALER_MERCHANT_track_transaction (struct 
GNUNET_CURL_Context *ctx,
   tdo->ctx = ctx;
   tdo->cb = track_transaction_cb;
   tdo->cb_cls = track_transaction_cb_cls;
-  base = MAH_path_to_url_ (backend_url,
-                          "/track/transaction");
+  base = TALER_url_join (backend_url, "/track/transaction", NULL);
   GNUNET_asprintf (&tdo->url,
                    "%s?order_id=%s&instance=%s",
                    base,
diff --git a/src/lib/merchant_api_track_transfer.c 
b/src/lib/merchant_api_track_transfer.c
index c55d544..7c78532 100644
--- a/src/lib/merchant_api_track_transfer.c
+++ b/src/lib/merchant_api_track_transfer.c
@@ -30,7 +30,6 @@
 #include "taler_merchant_service.h"
 #include <taler/taler_json_lib.h>
 #include <taler/taler_signatures.h>
-#include "merchant_api_common.h"
 
 
 /**
@@ -236,7 +235,6 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context 
*ctx,
   struct TALER_MERCHANT_TrackTransferHandle *tdo;
   CURL *eh;
   char *wtid_str;
-  char *base;
 
   wtid_str = GNUNET_STRINGS_data_to_string_alloc (wtid,
                                                   sizeof (struct 
TALER_WireTransferIdentifierRawP));
@@ -244,17 +242,12 @@ TALER_MERCHANT_track_transfer (struct GNUNET_CURL_Context 
*ctx,
   tdo->ctx = ctx;
   tdo->cb = track_transfer_cb; // very last to be called
   tdo->cb_cls = track_transfer_cb_cls;
-  /* TODO: do we need to escape 'exchange_url' here? */
-  base = MAH_path_to_url_ (backend_url,
-                          "/track/transfer");
-  GNUNET_asprintf (&tdo->url,
-                   "%s?wtid=%s&exchange=%s&instance=%s&wire_method=%s",
-                   base,
-                   wtid_str,
-                   exchange_url,
-                  instance,
-                  wire_method);
-  GNUNET_free (base);
+  tdo->url = TALER_url_join (backend_url, "/track/transfer",
+                             "wtid", wtid_str,
+                             "exchange", exchange_url,
+                             "instance", instance,
+                             "wire_method", wire_method,
+                             NULL);
   GNUNET_free (wtid_str);
   eh = curl_easy_init ();
   GNUNET_assert (CURLE_OK ==

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]