Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Opensearch desc : handle https protocol url with default port (443)
luccioman744c9a26156b
diff --git a/htroot/opensearchdescription.java b/htroot/opensearchdescription.javaindex 59a594ade..1e2444e8e 100644--- a/htroot/opensearchdescription.java+++ b/htroot/opensearchdescription.java@@ -25,6 +25,7 @@// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAimport net.yacy.cora.protocol.Domains;+import net.yacy.cora.protocol.HeaderFramework;import net.yacy.cora.protocol.RequestHeader;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;@@ -39,7 +40,7 @@ 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"); // returns host:port (if not defalt http/https ports)+ String thisaddress = header.get(HeaderFramework.HOST); // returns host:port (if not default http/https ports)String thisprotocol = "http";if (thisaddress == null) {thisaddress = Domains.LOCALHOST + ":" + sb.getConfig("port", "8090");@@ -49,6 +50,9 @@ public class opensearchdescription {thisprotocol = "https";}}+ /* YaCyDefaultServelt should have filled this custom header, making sure we know here wether original request is http or https+ * (when default ports (80 and 443) are used, there is no way to distinguish the two schemes relying only on the Host header) */+ thisprotocol = header.get(HeaderFramework.X_YACY_REQUEST_SCHEME, thisprotocol);final serverObjects prop = new serverObjects();prop.put("compareyacy", post != null && post.getBoolean("compare_yacy") ? 1 : 0);diff --git a/source/net/yacy/cora/protocol/HeaderFramework.java b/source/net/yacy/cora/protocol/HeaderFramework.javaindex 2aef01f6e..3c0f1fe62 100644--- a/source/net/yacy/cora/protocol/HeaderFramework.java+++ b/source/net/yacy/cora/protocol/HeaderFramework.java@@ -113,6 +113,8 @@ public class HeaderFramework extends TreeMap<String, String> implements Map<Stripublic static final String X_YACY_ORIGINAL_REQUEST_LINE = "X-Original-Request-Line";public static final String X_YACY_MEDIA_TITLE = "X-YaCy-Media-Title"; // can be attached to media files which do not have metadata; this will be used as titlepublic static final String X_YACY_MEDIA_KEYWORDS = "X-YaCy-Media-Keywords"; // can be attached to media files which do not have metadata; this will be used as keywords (space-separared list of words)+ /** Added when generating legacy request header to allow template servlets to know the original request scheme : "http" or "https" */+ public static final String X_YACY_REQUEST_SCHEME = "X-YaCy-Request-Scheme";public static final String SET_COOKIE = "Set-Cookie";public static final String SET_COOKIE2 = "Set-Cookie2";diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.javaindex 99d431aad..a1a914b1e 100644--- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java+++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java@@ -686,6 +686,9 @@ public class YaCyDefaultServlet extends HttpServlet {legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, request.getRemoteAddr());legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, target);legacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_EXT, targetExt);+ /* Add request scheme (http or https) to allow templates to know wether original request is http or https+ * (when default ports (80 and 443) are used, there is no way to distinguish the two schemes relying only on the Host header) */+ legacyRequestHeader.put(HeaderFramework.X_YACY_REQUEST_SCHEME, request.getScheme());Switchboard sb = Switchboard.getSwitchboard();if (legacyRequestHeader.containsKey(RequestHeader.AUTHORIZATION)) {if (HttpServletRequest.BASIC_AUTH.equalsIgnoreCase(request.getAuthType())) {