From 4a0075084de92d34b83a88b2bcd69568c7b2bf7e Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 26 Oct 2023 15:24:50 -0300 Subject: use x-forward-port in case base url is not on standard port --- src/backend/taler-merchant-httpd_helper.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index 3e525245..2e06a432 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -742,6 +742,7 @@ TMH_base_url_by_connection (struct MHD_Connection *connection, { const char *host; const char *forwarded_host; + const char *forwarded_port; const char *uri_path; memset (buf, @@ -773,6 +774,16 @@ TMH_base_url_by_connection (struct MHD_Connection *connection, GNUNET_buffer_write_str (buf, host); } + forwarded_port = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, + "X-Forwarded-Port"); + if (NULL != forwarded_port) + { + GNUNET_buffer_write_str (buf, + ":"); + GNUNET_buffer_write_str (buf, + forwarded_port); + } uri_path = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Prefix"); @@ -799,6 +810,7 @@ TMH_taler_uri_by_connection (struct MHD_Connection *connection, { const char *host; const char *forwarded_host; + const char *forwarded_port; const char *uri_path; memset (buf, @@ -810,6 +822,9 @@ TMH_taler_uri_by_connection (struct MHD_Connection *connection, forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Host"); + forwarded_port = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, + "X-Forwarded-Port"); uri_path = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Prefix"); @@ -833,6 +848,13 @@ TMH_taler_uri_by_connection (struct MHD_Connection *connection, "/"); GNUNET_buffer_write_str (buf, host); + if (NULL != forwarded_port) + { + GNUNET_buffer_write_str (buf, + ":"); + GNUNET_buffer_write_str (buf, + forwarded_port); + } if (NULL != uri_path) GNUNET_buffer_write_path (buf, uri_path); -- cgit v1.2.3