From ca5b95cb8423b5313be4f16e094bfe78d1127b85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 27 Jul 2020 20:12:23 +0530 Subject: taler:// URI syntax with correct slashes and instance path --- ...-merchant-httpd_private-post-orders-ID-refund.c | 45 ++++++++++------------ 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'src/backend/taler-merchant-httpd_private-post-orders-ID-refund.c') 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 0e592467..92b7590c 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); } -- cgit v1.2.3