summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_get-tips-ID.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_get-tips-ID.c')
-rw-r--r--src/backend/taler-merchant-httpd_get-tips-ID.c97
1 files changed, 15 insertions, 82 deletions
diff --git a/src/backend/taler-merchant-httpd_get-tips-ID.c b/src/backend/taler-merchant-httpd_get-tips-ID.c
index f9e6c8cd..71c66d51 100644
--- a/src/backend/taler-merchant-httpd_get-tips-ID.c
+++ b/src/backend/taler-merchant-httpd_get-tips-ID.c
@@ -25,6 +25,7 @@
#include <taler/taler_json_lib.h>
#include <taler/taler_templating_lib.h>
#include "taler-merchant-httpd_get-tips-ID.h"
+#include "taler-merchant-httpd_helper.h"
#include "taler-merchant-httpd_mhd.h"
#include "taler-merchant-httpd_qr.h"
@@ -34,52 +35,18 @@ TMH_make_taler_tip_uri (struct MHD_Connection *con,
const struct TALER_TipIdentifierP *tip_id,
const char *instance_id)
{
- const char *host;
- const char *forwarded_host;
- const char *uri_path;
struct GNUNET_Buffer buf = { 0 };
- host = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "Host");
- forwarded_host = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "X-Forwarded-Host");
-
- uri_path = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "X-Forwarded-Prefix");
- if (NULL != forwarded_host)
- host = forwarded_host;
-
- if (NULL == host)
- {
- GNUNET_break (0);
- return NULL;
- }
-
GNUNET_assert (NULL != instance_id);
GNUNET_assert (NULL != tip_id);
-
- 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,
- "://tip/");
- GNUNET_buffer_write_str (&buf,
- host);
- if (NULL != uri_path)
- GNUNET_buffer_write_path (&buf,
- uri_path);
- if (0 != strcmp ("default",
- instance_id))
+ if (GNUNET_OK !=
+ TMH_taler_uri_by_connection (con,
+ "tip",
+ instance_id,
+ &buf))
{
- GNUNET_buffer_write_path (&buf,
- "instances");
- GNUNET_buffer_write_path (&buf,
- instance_id);
+ GNUNET_break (0);
+ return NULL;
}
/* Ensure previous part is slash-terminated */
GNUNET_buffer_write_path (&buf,
@@ -96,51 +63,17 @@ TMH_make_tip_status_url (struct MHD_Connection *con,
const struct TALER_TipIdentifierP *tip_id,
const char *instance_id)
{
- const char *host;
- const char *forwarded_host;
- const char *uri_path;
- struct GNUNET_Buffer buf = { 0 };
-
- host = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "Host");
- forwarded_host = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "X-Forwarded-Host");
-
- uri_path = MHD_lookup_connection_value (con,
- MHD_HEADER_KIND,
- "X-Forwarded-Prefix");
- if (NULL != forwarded_host)
- host = forwarded_host;
-
- if (NULL == host)
- {
- GNUNET_break (0);
- return NULL;
- }
+ struct GNUNET_Buffer buf;
GNUNET_assert (NULL != instance_id);
GNUNET_assert (NULL != tip_id);
-
- if (GNUNET_NO == TALER_mhd_is_https (con))
- GNUNET_buffer_write_str (&buf,
- "http://");
- else
- GNUNET_buffer_write_str (&buf,
- "https://");
- GNUNET_buffer_write_str (&buf,
- host);
- if (NULL != uri_path)
- GNUNET_buffer_write_path (&buf,
- uri_path);
- if (0 != strcmp ("default",
- instance_id))
+ if (GNUNET_OK !=
+ TMH_base_url_by_connection (con,
+ instance_id,
+ &buf))
{
- GNUNET_buffer_write_path (&buf,
- "instances");
- GNUNET_buffer_write_path (&buf,
- instance_id);
+ GNUNET_break (0);
+ return NULL;
}
GNUNET_buffer_write_path (&buf,
"tips/");