Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

make more use of the new ServletRequest interface methodes getScheme, getServerPort (in QuickCrawlLink_p & YaCyDefaultServlet)

regerd631fbc019b4
diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.java
index 35b8d1aa0..31c0cbc1c 100644
--- a/htroot/QuickCrawlLink_p.java
+++ b/htroot/QuickCrawlLink_p.java
@@ -39,7 +39,6 @@ import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.util.NumberTools;
import net.yacy.crawler.data.CrawlProfile;
import net.yacy.crawler.retrieval.Request;
import net.yacy.search.Switchboard;
@@ -62,16 +61,15 @@ public class QuickCrawlLink_p {
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env;
- int port = sb.getConfigInt("port", 8090);
+ int port;
// get the http host header
if (header.containsKey(HeaderFramework.HOST)) {
- final String hostSocket = header.get(HeaderFramework.HOST);
- final int pos = hostSocket.indexOf(':', 0);
- if (pos != -1) {
- port = NumberTools.parseIntDecSubstring(hostSocket, pos + 1);
- }
+ port = header.getServerPort();
+ } else {
+ port = sb.getConfigInt("port", 8090);
}
+
prop.put("mode_host", Domains.LOCALHOST);
prop.put("mode_port", port);
diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
index e7fb99fe1..16eab41a4 100644
--- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java
+++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
@@ -711,23 +711,11 @@ public class YaCyDefaultServlet extends HttpServlet {
public static String getContext(final RequestHeader header, final Switchboard sb) {
String protocol = "http";
String hostAndPort = null;
- if(header != null) {
- if(hostAndPort == null){
- hostAndPort = header.get(HeaderFramework.HOST);
-
- /* We can try here to figure out if we are using http or https, relying on the port used.
- * This only works port is not standard (80 or 443) : if so HeaderFramework.X_YACY_REQUEST_SCHEME will be more reliable */
- final String sslport;
- if(sb != null) {
- sslport = ":" + sb.getConfigInt("port.ssl", 8443);
- } else {
- sslport = ":8443";
- }
- if (hostAndPort != null && hostAndPort.endsWith(sslport)) { // connection on ssl port, use https protocol
- protocol = "https";
- }
- }
+ if (header != null) {
+ hostAndPort = header.get(HeaderFramework.HOST);
+ protocol = header.getScheme();
}
+
/* Host and port still null : let's use the default local ones */
if (hostAndPort == null) {
if(sb != null) {