gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: taler:// URI syntax with correct


From: gnunet
Subject: [taler-merchant] branch master updated: taler:// URI syntax with correct slashes and instance path
Date: Mon, 27 Jul 2020 16:42:35 +0200

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 ca5b95c  taler:// URI syntax with correct slashes and instance path
ca5b95c is described below

commit ca5b95cb8423b5313be4f16e094bfe78d1127b85
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Mon Jul 27 20:12:23 2020 +0530

    taler:// URI syntax with correct slashes and instance path
---
 src/backend/taler-merchant-httpd_get-orders-ID.c   | 46 +++++++++++-----------
 ...-merchant-httpd_private-post-orders-ID-refund.c | 45 ++++++++++-----------
 2 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c 
b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 64c4f18..2c7ec57 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -612,8 +612,8 @@ TMH_make_taler_pay_uri (struct MHD_Connection *con,
   const char *host;
   const char *forwarded_host;
   const char *uri_path;
-  const char *uri_instance_id;
-  char *result;
+  struct GNUNET_Buffer buf = { 0 };
+
 
   host = MHD_lookup_connection_value (con,
                                       MHD_HEADER_KIND,
@@ -625,35 +625,37 @@ TMH_make_taler_pay_uri (struct MHD_Connection *con,
   uri_path = MHD_lookup_connection_value (con,
                                           MHD_HEADER_KIND,
                                           "X-Forwarded-Prefix");
-  if (NULL == uri_path)
-    uri_path = "-";
   if (NULL != forwarded_host)
     host = forwarded_host;
-  if (0 == strcmp (instance_id,
-                   "default"))
-    uri_instance_id = "-";
-  else
-    uri_instance_id = instance_id;
+
   if (NULL == host)
   {
-    /* Should never happen, at least the host header should be defined */
     GNUNET_break (0);
     return NULL;
   }
 
+  GNUNET_assert (NULL != instance_id);
   GNUNET_assert (NULL != order_id);
-  GNUNET_assert (0 < GNUNET_asprintf (&result,
-                                      "%s://pay/%s/%s/%s/%s%s%s",
-                                      (GNUNET_YES == TALER_mhd_is_https (con))
-                                      ? "taler"
-                                      : "taler+http",
-                                      host,
-                                      uri_path,
-                                      uri_instance_id,
-                                      order_id,
-                                      (NULL == session_id) ? "" : "/",
-                                      (NULL == session_id) ? "" : session_id));
-  return result;
+
+  GNUNET_buffer_write_str (&buf, "taler");
+  if (GNUNET_NO == TALER_mhd_is_https (con))
+    GNUNET_buffer_write_str (&buf, "+http");
+  GNUNET_buffer_write_str (&buf, "://pay/");
+  GNUNET_buffer_write_str (&buf, host);
+  if (NULL != uri_path)
+    GNUNET_buffer_write_path (&buf, uri_path);
+  if (0 != strcmp ("default", instance_id))
+  {
+    GNUNET_buffer_write_path (&buf, "instances");
+    GNUNET_buffer_write_path (&buf, instance_id);
+  }
+  GNUNET_buffer_write_path (&buf, order_id);
+  if (NULL != session_id)
+    GNUNET_buffer_write_path (&buf, session_id);
+  /* ensure final slash */
+  GNUNET_buffer_write_path (&buf, "");
+
+  return GNUNET_buffer_reap_str (&buf);
 }
 
 
diff --git a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c 
b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
index 0e59246..92b7590 100644
--- a/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
+++ b/src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c
@@ -50,17 +50,20 @@ make_taler_refund_uri (struct MHD_Connection *connection,
   const char *host;
   const char *forwarded_host;
   const char *uri_path;
-  const char *uri_instance_id;
-  char *result;
+  struct GNUNET_Buffer buf = { 0 };
 
   GNUNET_assert (NULL != instance_id);
   GNUNET_assert (NULL != order_id);
+
   host = MHD_lookup_connection_value (connection,
                                       MHD_HEADER_KIND,
-                                      MHD_HTTP_HEADER_HOST);
+                                      "Host");
   forwarded_host = MHD_lookup_connection_value (connection,
                                                 MHD_HEADER_KIND,
                                                 "X-Forwarded-Host");
+  uri_path = MHD_lookup_connection_value (connection,
+                                          MHD_HEADER_KIND,
+                                          "X-Forwarded-Prefix");
   if (NULL != forwarded_host)
     host = forwarded_host;
   if (NULL == host)
@@ -69,27 +72,21 @@ make_taler_refund_uri (struct MHD_Connection *connection,
     GNUNET_break (0);
     return NULL;
   }
-  uri_path = MHD_lookup_connection_value (connection,
-                                          MHD_HEADER_KIND,
-                                          "X-Forwarded-Prefix");
-  if (NULL == uri_path)
-    uri_path = "-";
-  if (0 == strcmp (instance_id,
-                   "default"))
-    uri_instance_id = "-";
-  else
-    uri_instance_id = instance_id;
-  GNUNET_assert (0 < GNUNET_asprintf (&result,
-                                      "%s://refund/%s/%s/%s/%s",
-                                      (GNUNET_YES == TALER_mhd_is_https (
-                                         connection))
-                                      ? "taler"
-                                      : "taler+http",
-                                      host,
-                                      uri_path,
-                                      uri_instance_id,
-                                      order_id));
-  return result;
+  GNUNET_buffer_write_str (&buf, "taler");
+  if (GNUNET_NO == TALER_mhd_is_https (connection))
+    GNUNET_buffer_write_str (&buf, "+http");
+  GNUNET_buffer_write_str (&buf, "://refund/");
+  GNUNET_buffer_write_str (&buf, host);
+  if (NULL != uri_path)
+    GNUNET_buffer_write_path (&buf, uri_path);
+  if (0 != strcmp ("default", instance_id))
+  {
+    GNUNET_buffer_write_path (&buf, "instances");
+    GNUNET_buffer_write_path (&buf, instance_id);
+  }
+  GNUNET_buffer_write_path (&buf, order_id);
+
+  return GNUNET_buffer_reap_str (&buf);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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