gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: fix URL concatenation


From: gnunet
Subject: [libeufin] branch master updated: fix URL concatenation
Date: Wed, 13 Oct 2021 12:04:36 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 07e69ce  fix URL concatenation
07e69ce is described below

commit 07e69ce08561e1b300dd4b2eecc286b6f5179e3b
Author: ms <ms@taler.net>
AuthorDate: Wed Oct 13 12:04:23 2021 +0200

    fix URL concatenation
---
 .../kotlin/tech/libeufin/nexus/server/NexusServer.kt | 12 ++++--------
 util/src/main/kotlin/HTTP.kt                         | 20 +++++++++++++-------
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt 
b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
index cfa42f6..51b0a1d 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt
@@ -894,12 +894,10 @@ val nexusApp: Application.() -> Unit = {
                 FacadeShowInfo(
                     name = f.facadeName,
                     type = f.type,
-                    baseUrl = call.url {
-                        parameters.clear()
-                        encodedPath = call.request.getBaseUrl()
+                    baseUrl = URLBuilder(call.request.getBaseUrl()).apply {
                         pathComponents("facades", f.facadeName, f.type)
                         encodedPath += "/"
-                    },
+                    }.buildString(),
                     config = getFacadeState(f.type, f)
                 )
             }
@@ -921,12 +919,10 @@ val nexusApp: Application.() -> Unit = {
                         FacadeShowInfo(
                             name = it.facadeName,
                             type = it.type,
-                            baseUrl = call.url {
-                                parameters.clear()
-                                encodedPath = call.request.getBaseUrl()
+                            baseUrl = 
URLBuilder(call.request.getBaseUrl()).apply {
                                 pathComponents("facades", it.facadeName, 
it.type)
                                 encodedPath += "/"
-                            },
+                            }.buildString(),
                             config = getFacadeState(it.type, it)
                         )
                     )
diff --git a/util/src/main/kotlin/HTTP.kt b/util/src/main/kotlin/HTTP.kt
index 7c3528f..78b9e04 100644
--- a/util/src/main/kotlin/HTTP.kt
+++ b/util/src/main/kotlin/HTTP.kt
@@ -45,13 +45,17 @@ private fun internalServerError(
         ec = libeufinErrorCode
     )
 }
+
 /**
  * Get the base URL of a request; handles proxied case.
  */
 fun ApplicationRequest.getBaseUrl(): String {
-
-    val isProxied = this.headers.contains("X-Forwarded-Host")
-    return if (isProxied) {
+    return if (this.headers.contains("X-Forwarded-Host")) {
+        logger.info("Building X-Forwarded- base URL")
+        var prefix: String = this.headers.get("X-Forwarded-Prefix")
+            ?: throw internalServerError("Reverse proxy did not define 
X-Forwarded-Prefix")
+        if (!prefix.endsWith("/"))
+            prefix += "/"
         URLBuilder(
             protocol = URLProtocol(
                 name = this.headers.get("X-Forwarded-Proto") ?: throw 
internalServerError("Reverse proxy did not define X-Forwarded-Proto"),
@@ -60,10 +64,12 @@ fun ApplicationRequest.getBaseUrl(): String {
             host = this.headers.get("X-Forwarded-Host") ?: throw 
internalServerError(
                 "Reverse proxy did not define X-Forwarded-Host"
             ),
-            encodedPath = this.headers.get("X-Forwarded-Prefix") ?: throw 
internalServerError(
-                "Reverse proxy did not define X-Forwarded-Prefix"
-            )
-        ).toString()
+            encodedPath = prefix
+        ).apply {
+            // Gets dropped otherwise.
+            if (!encodedPath.endsWith("/"))
+                encodedPath += "/"
+        }.buildString()
     } else {
         this.call.url {
             parameters.clear()

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]