diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_helper.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_helper.c | 79 |
1 files changed, 45 insertions, 34 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index 2e06a432..ac181234 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -748,48 +748,59 @@ TMH_base_url_by_connection (struct MHD_Connection *connection, memset (buf, 0, sizeof (*buf)); - if (GNUNET_YES == TALER_mhd_is_https (connection)) - GNUNET_buffer_write_str (buf, "https://"); - else - GNUNET_buffer_write_str (buf, "http://"); - host = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_HOST); - forwarded_host = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - "X-Forwarded-Host"); - if (NULL != forwarded_host) + if (NULL != TMH_base_url) { GNUNET_buffer_write_str (buf, - forwarded_host); + TMH_base_url); } else { - if (NULL == host) + if (GNUNET_YES == + TALER_mhd_is_https (connection)) + GNUNET_buffer_write_str (buf, + "https://"); + else + GNUNET_buffer_write_str (buf, + "http://"); + host = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, + MHD_HTTP_HEADER_HOST); + forwarded_host = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, + "X-Forwarded-Host"); + if (NULL != forwarded_host) { - GNUNET_buffer_clear (buf); - GNUNET_break (0); - return GNUNET_SYSERR; + GNUNET_buffer_write_str (buf, + forwarded_host); } - 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); + else + { + if (NULL == host) + { + GNUNET_buffer_clear (buf); + GNUNET_break (0); + return GNUNET_SYSERR; + } + 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"); + if (NULL != uri_path) + GNUNET_buffer_write_path (buf, + uri_path); } - uri_path = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - "X-Forwarded-Prefix"); - if (NULL != uri_path) - GNUNET_buffer_write_path (buf, - uri_path); if (0 != strcmp (instance, "default")) { |