From 89017e17e4f92bafe55e9891241ace3aee71d70d Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 25 Nov 2016 11:10:03 +0100 Subject: [PATCH] Converted ajax URL to relative and added a check on the response status. This makes YaCy easier to configure when running behind a reverse Proxy. The check on status avoids trying to update the page with error text content when the server returned a 404 or 500 error message for example. --- htroot/Crawler_p.java | 2 +- htroot/HostBrowser.java | 2 +- htroot/IndexControlURLs_p.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java index 5d9ba52c2..4d1bae75d 100644 --- a/htroot/Crawler_p.java +++ b/htroot/Crawler_p.java @@ -93,7 +93,7 @@ public class Crawler_p { Segment segment = sb.index; Fulltext fulltext = segment.fulltext(); - String localSolr = "/solr/select?core=collection1&q=*:*&start=0&rows=3"; + String localSolr = "solr/select?core=collection1&q=*:*&start=0&rows=3"; String remoteSolr = env.getConfig(SwitchboardConstants.FEDERATED_SERVICE_SOLR_INDEXING_URL, localSolr); if (!remoteSolr.endsWith("/")) remoteSolr = remoteSolr + "/"; prop.put("urlpublictextSolrURL", fulltext.connectedLocalSolr() ? localSolr : remoteSolr + "collection1/select?&q=*:*&start=0&rows=3"); diff --git a/htroot/HostBrowser.java b/htroot/HostBrowser.java index d95565634..b90b2d8f0 100644 --- a/htroot/HostBrowser.java +++ b/htroot/HostBrowser.java @@ -288,7 +288,7 @@ public class HostBrowser { int c = 0; for (Entry entry: statMap.entrySet()) { prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_key", entry.getKey()); prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_count", entry.getValue()); - prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_a", "http://localhost:" + sb.getConfigInt("port", 8090) + "/solr/collection1/select?q=host_s:" + host + " AND " + facetentry.getKey() + ":" + entry.getKey() + "&defType=edismax&start=0&rows=1000&fl=sku,crawldepth_i"); + prop.put("hostanalysis_facets_" + fc + "_facet_" + c + "_a", "solr/collection1/select?q=host_s:" + host + " AND " + facetentry.getKey() + ":" + entry.getKey() + "&defType=edismax&start=0&rows=1000&fl=sku,crawldepth_i"); c++; } prop.put("hostanalysis_facets_" + fc + "_facet", c); diff --git a/htroot/IndexControlURLs_p.html b/htroot/IndexControlURLs_p.html index 598341f61..d1d5964ea 100644 --- a/htroot/IndexControlURLs_p.html +++ b/htroot/IndexControlURLs_p.html @@ -21,10 +21,10 @@ function search(query) { else if (window.ActiveXObject) { // IE self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } - self.xmlHttpReq.open('GET', "/solr/select?q=sku:\"" + query + "\" OR host_s:\"" + query + "\" OR host_dnc_s:\"" + query + "\" OR host_organization_s:\"" + query + "\" OR host_organizationdnc_s:\"" + query + "\" OR host_subdomain_s:\"" + query + "\" OR url_paths_sxt:\"" + query + "\" OR url_file_name_s:\"" + query + "\"&start=0&rows=100&wt=yjson", true); + self.xmlHttpReq.open('GET', "solr/select?q=sku:\"" + query + "\" OR host_s:\"" + query + "\" OR host_dnc_s:\"" + query + "\" OR host_organization_s:\"" + query + "\" OR host_organizationdnc_s:\"" + query + "\" OR host_subdomain_s:\"" + query + "\" OR url_paths_sxt:\"" + query + "\" OR url_file_name_s:\"" + query + "\"&start=0&rows=100&wt=yjson", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { - if (self.xmlHttpReq.readyState == 4) { + if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) { updatepage(self.xmlHttpReq.responseText); } }