commit 9089f3593f3988363a0b2284ae03a4745104f1ad
parent 0de0362118705bbbbd57389acb0495a1b03aa31b
Author: Sebastian <sebasjm@taler-systems.com>
Date: Mon, 27 Apr 2026 12:18:06 -0300
fix #11356 adding paivana header reponse for non-web
Diffstat:
1 file changed, 62 insertions(+), 0 deletions(-)
diff --git a/src/backend/paivana-httpd_templates.c b/src/backend/paivana-httpd_templates.c
@@ -26,6 +26,7 @@
#include "platform.h"
#include <curl/curl.h>
#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_uri_lib.h>
#include <gnunet/gnunet_curl_lib.h>
#include "paivana-httpd.h"
#include "paivana-httpd_daemon.h"
@@ -174,6 +175,57 @@ eq (const char *s1,
/**
+ * Create a taler://pay-template/ URI for the given @a con and @a template_id
+ * and @a instance_id.
+ *
+ * @param merchant_base_url URL to take host and path from;
+ * we cannot take it from the MHD connection as a browser
+ * may have changed 'http' to 'https' and we MUST be consistent
+ * with what the merchant's frontend used initially
+ * @param template_id the template id
+ * @return corresponding taler://pay-template/ URI, or NULL on missing "host"
+ */
+static char *
+make_taler_pay_template_uri (const char *merchant_base_url,
+ const char *template_id)
+{
+ struct GNUNET_Buffer buf = { 0 };
+ char *url;
+ struct GNUNET_Uri uri;
+
+ url = GNUNET_strdup (merchant_base_url);
+ if (-1 == GNUNET_uri_parse (&uri,
+ url))
+ {
+ GNUNET_break (0);
+ GNUNET_free (url);
+ return NULL;
+ }
+ GNUNET_assert (NULL != template_id);
+ GNUNET_buffer_write_str (&buf,
+ "taler");
+ if (0 == strcasecmp ("http",
+ uri.scheme))
+ GNUNET_buffer_write_str (&buf,
+ "+http");
+ GNUNET_buffer_write_str (&buf,
+ "://pay-template/");
+ GNUNET_buffer_write_str (&buf,
+ uri.host);
+ if (0 != uri.port)
+ GNUNET_buffer_write_fstr (&buf,
+ ":%u",
+ (unsigned int) uri.port);
+ if (NULL != uri.path)
+ GNUNET_buffer_write_path (&buf,
+ uri.path);
+ GNUNET_buffer_write_path (&buf,
+ template_id);
+ GNUNET_free (url);
+ return GNUNET_buffer_reap_str (&buf);
+}
+
+/**
* Try to initialize the paywall response.
*
* @param conn connection to create the response for
@@ -239,6 +291,7 @@ load_paywall (struct MHD_Connection *conn,
json_decref (data);
}
+
GNUNET_break (MHD_YES ==
MHD_add_response_header (reply,
MHD_HTTP_HEADER_CONTENT_TYPE,
@@ -255,6 +308,15 @@ load_paywall (struct MHD_Connection *conn,
MHD_add_response_header (reply,
MHD_HTTP_HEADER_CACHE_CONTROL,
"public, max-age=300"));
+
+ char *uri;
+ uri = make_taler_pay_template_uri(PH_merchant_base_url, t->template_id);
+ GNUNET_assert (MHD_YES ==
+ MHD_add_response_header (reply,
+ "Paivana",
+ uri));
+ GNUNET_free(uri);
+
{
struct ResponseCacheEntry *rce;