From f0524ce7d84deb47b01369a1a52bc4194347038e Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 31 Jan 2024 11:19:05 +0000 Subject: [PATCH 1/5] Issue 97 - download link --- src/fileshelter/ui/ShareUtils.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fileshelter/ui/ShareUtils.cpp b/src/fileshelter/ui/ShareUtils.cpp index e265b94..19abb47 100644 --- a/src/fileshelter/ui/ShareUtils.cpp +++ b/src/fileshelter/ui/ShareUtils.cpp @@ -26,12 +26,26 @@ namespace UserInterface::ShareUtils { + + static + std::string + getScheme() + { + const std::string xForwardedProto = wApp->environment().getHeaderValue("X-Forwarded-Proto"); + if (!xForwardedProto.empty()) + { + return xForwardedProto; // will be 'http' or 'https' + } + // Fallback if header is not set + return "http"; + } + static std::string computeURL(const std::string& internalPath) { - return wApp->environment().urlScheme() + "://" + wApp->environment().hostName() + (wApp->environment().deploymentPath() == "/" ? "" : wApp->environment().deploymentPath()) + internalPath; + return getScheme() + "://" + wApp->environment().hostName() + (wApp->environment().deploymentPath() == "/" ? "" : wApp->environment().deploymentPath()) + internalPath; } std::unique_ptr From f2a2fefae24c27cffa6626483f4fb6b0088db2dc Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 31 Jan 2024 11:32:39 +0000 Subject: [PATCH 2/5] Issue 97 - download link --- src/fileshelter/ui/ShareUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileshelter/ui/ShareUtils.cpp b/src/fileshelter/ui/ShareUtils.cpp index 19abb47..24a9662 100644 --- a/src/fileshelter/ui/ShareUtils.cpp +++ b/src/fileshelter/ui/ShareUtils.cpp @@ -31,7 +31,7 @@ namespace UserInterface::ShareUtils std::string getScheme() { - const std::string xForwardedProto = wApp->environment().getHeaderValue("X-Forwarded-Proto"); + const std::string xForwardedProto = wApp->environment().HeaderValue("X-Forwarded-Proto"); if (!xForwardedProto.empty()) { return xForwardedProto; // will be 'http' or 'https' From 5cacdaced596dfd59ac2c33c83ed06cf473d0b9f Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 31 Jan 2024 11:49:19 +0000 Subject: [PATCH 3/5] Issue 97 - download link --- src/fileshelter/ui/ShareUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileshelter/ui/ShareUtils.cpp b/src/fileshelter/ui/ShareUtils.cpp index 24a9662..6658bcc 100644 --- a/src/fileshelter/ui/ShareUtils.cpp +++ b/src/fileshelter/ui/ShareUtils.cpp @@ -31,7 +31,7 @@ namespace UserInterface::ShareUtils std::string getScheme() { - const std::string xForwardedProto = wApp->environment().HeaderValue("X-Forwarded-Proto"); + const std::string xForwardedProto = wApp->environment().headerValue("X-Forwarded-Proto"); if (!xForwardedProto.empty()) { return xForwardedProto; // will be 'http' or 'https' From 629dee7b083ae91e32ecb21a2a392fe4c1223ab6 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 31 Jan 2024 14:26:06 +0000 Subject: [PATCH 4/5] Issue 97 - comments --- src/fileshelter/ui/ShareUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fileshelter/ui/ShareUtils.cpp b/src/fileshelter/ui/ShareUtils.cpp index 6658bcc..42a9803 100644 --- a/src/fileshelter/ui/ShareUtils.cpp +++ b/src/fileshelter/ui/ShareUtils.cpp @@ -31,6 +31,8 @@ namespace UserInterface::ShareUtils std::string getScheme() { + // Necessary because the scheme in envonment does not pay attention to X-Forwarded_Proto by default + //and we have to use that beause you cannot get the full URL out of wLink as text const std::string xForwardedProto = wApp->environment().headerValue("X-Forwarded-Proto"); if (!xForwardedProto.empty()) { From 4bf66e974fdd509881339021ad0bb03dd9792563 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 2 Feb 2024 06:29:43 +0000 Subject: [PATCH 5/5] Issue 97 - generalised fallback if no rev proxy --- src/fileshelter/ui/ShareUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileshelter/ui/ShareUtils.cpp b/src/fileshelter/ui/ShareUtils.cpp index 42a9803..8ec2b5c 100644 --- a/src/fileshelter/ui/ShareUtils.cpp +++ b/src/fileshelter/ui/ShareUtils.cpp @@ -40,7 +40,7 @@ namespace UserInterface::ShareUtils } // Fallback if header is not set - return "http"; + return wApp->environment().urlScheme(); } static