From a9527877121e6445095e9a68946658cd56043bc7 Mon Sep 17 00:00:00 2001 From: reger Date: Mon, 11 Jul 2016 02:33:12 +0200 Subject: [PATCH] adjust opensearchdescription to return url with protocol it was call on fix http://mantis.tokeek.de/view.php?id=669 --- htroot/opensearchdescription.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.java index de72ff1c1..59a594ade 100644 --- a/htroot/opensearchdescription.java +++ b/htroot/opensearchdescription.java @@ -39,9 +39,16 @@ public class opensearchdescription { String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, ""); if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", ""); - String thisaddress = header.get("Host", Domains.LOCALHOST); - if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + env.getLocalPort(); - String thisprotocol = env.getConfigBool("server.https", false) ? "https" : "http"; + String thisaddress = header.get("Host"); // returns host:port (if not defalt http/https ports) + String thisprotocol = "http"; + if (thisaddress == null) { + thisaddress = Domains.LOCALHOST + ":" + sb.getConfig("port", "8090"); + } else { + final String sslport = ":" + sb.getConfig("port.ssl", "8443"); + if (thisaddress.endsWith(sslport)) { // connection on ssl port, use https protocol + thisprotocol = "https"; + } + } final serverObjects prop = new serverObjects(); prop.put("compareyacy", post != null && post.getBoolean("compare_yacy") ? 1 : 0);