Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fix double-escaped urls from proxy-usage
sixcooleradd0e428048b
diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.javaindex 7509fd243..b3c1fa2f2 100644--- a/source/net/yacy/cora/protocol/http/HTTPClient.java+++ b/source/net/yacy/cora/protocol/http/HTTPClient.java@@ -391,8 +391,19 @@ public class HTTPClient {* @throws IOException*/public void GET(final String uri) throws IOException {+ GET(new MultiProtocolURL(uri));+ }++ /**+ * This method GETs a page from the server.+ * to be used for streaming out+ * Please take care to call finish()!+ *+ * @param url the url to get+ * @throws IOException+ */+ public void GET(final MultiProtocolURL url) throws IOException {if (this.currentRequest != null) throw new IOException("Client is in use!");- final MultiProtocolURL url = new MultiProtocolURL(uri);final String urix = url.toNormalform(true);HttpGet httpGet = null;try {@@ -413,7 +424,17 @@ public class HTTPClient {* @throws IOException*/public HttpResponse HEADResponse(final String uri) throws IOException {- final MultiProtocolURL url = new MultiProtocolURL(uri);+ return HEADResponse(new MultiProtocolURL(uri));+ }++ /**+ * This method gets HEAD response+ *+ * @param url the url to Response from+ * @return the HttpResponse+ * @throws IOException+ */+ public HttpResponse HEADResponse(final MultiProtocolURL url) throws IOException {final HttpHead httpHead = new HttpHead(url.toNormalform(true));setHost(url.getHost()); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_serviceexecute(httpHead);@@ -433,8 +454,21 @@ public class HTTPClient {* @throws IOException*/public void POST(final String uri, final InputStream instream, final long length) throws IOException {+ POST(new MultiProtocolURL(uri), instream, length);+ }++ /**+ * This method POSTs a page from the server.+ * to be used for streaming out+ * Please take care to call finish()!+ *+ * @param url the url to post+ * @param instream the input to post+ * @param length the contentlength+ * @throws IOException+ */+ public void POST(final MultiProtocolURL url, final InputStream instream, final long length) throws IOException {if (this.currentRequest != null) throw new IOException("Client is in use!");- final MultiProtocolURL url = new MultiProtocolURL(uri);final HttpPost httpPost = new HttpPost(url.toNormalform(true));String host = url.getHost();if (host == null) host = Domains.LOCALHOST;diff --git a/source/net/yacy/http/ProxyHandler.java b/source/net/yacy/http/ProxyHandler.javaindex 64e0c8275..3830b2360 100644--- a/source/net/yacy/http/ProxyHandler.java+++ b/source/net/yacy/http/ProxyHandler.java@@ -108,13 +108,13 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {// send requesttry {String queryString = request.getQueryString() != null ? "?" + request.getQueryString() : "";- String url = request.getRequestURL().toString() + queryString;+ DigestURL digestURI = new DigestURL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getPathInfo() + queryString);if (request.getMethod().equals(HeaderFramework.METHOD_GET)) {- client.GET(url);+ client.GET(digestURI);} else if (request.getMethod().equals(HeaderFramework.METHOD_POST)) {- client.POST(url, request.getInputStream(), request.getContentLength());+ client.POST(digestURI, request.getInputStream(), request.getContentLength());} else if (request.getMethod().equals(HeaderFramework.METHOD_HEAD)) {- client.HEADResponse(url);+ client.HEADResponse(digestURI);} else {throw new ServletException("Unsupported Request Method");}@@ -128,7 +128,6 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {cleanResponseHeader(clientresponse);// TODO: is this fast, if not, use value from ProxyCacheHandler- DigestURL digestURI = new DigestURL(url);ResponseHeader cachedResponseHeader = Cache.getResponseHeader(digestURI.hash());// the cache does either not exist or is (supposed to be) stale@@ -137,7 +136,7 @@ public class ProxyHandler extends AbstractRemoteHandler implements Handler {// delete the cacheResponseHeader rh = Cache.getResponseHeader(digestURI.hash());if (rh != null && (sizeBeforeDelete = rh.getContentLength()) == 0) {- byte[] b = Cache.getContent(new DigestURL(url).hash());+ byte[] b = Cache.getContent(digestURI.hash());if (b != null) sizeBeforeDelete = b.length;}Cache.delete(digestURI.hash());