Permalink
Browse files

further avoid to set connect info properties as header value

following comment "use of properties as header values is discouraged"
in case where (proxy)HTTPClient overwrites values with supplied url.
Use defined request.referer procedure in response class.
  • Loading branch information...
reger24 committed Mar 4, 2017
1 parent cd4d891 commit ce8702546260a405e09fa8081c5874b45e27cf7d
@@ -791,24 +791,14 @@ public String getCharacterEncoding() {
public DigestURL referrerURL() {
if (this.requestHeader == null) return null;
try {
final String r = this.requestHeader.get(RequestHeader.REFERER, null);
if (r == null) return null;
return new DigestURL(r);
} catch (final Exception e) {
return null;
}
return this.requestHeader.referer();
}
public byte[] referrerHash() {
if (this.requestHeader == null) return null;
final String u = this.requestHeader.get(RequestHeader.REFERER, "");
if (u == null || u.isEmpty()) return null;
try {
return new DigestURL(u).hash();
} catch (final Exception e) {
return null;
}
final DigestURL url = this.requestHeader.referer();
if (url == null) return null;
return url.hash();
}
public boolean validResponseStatus() {
@@ -154,9 +154,6 @@ public void service (ServletRequest req, ServletResponse res) throws ServletExce
prop.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
prop.put(HeaderFramework.CONNECTION_PROP_CLIENT_HTTPSERVLETREQUEST, request);
yacyRequestHeader.put(HeaderFramework.HOST, hostwithport );
yacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, proxyurl.getPath());
// 4 & 5 get & index target url
final ByteArrayOutputStream tmpproxyout = new ByteArrayOutputStream();
HTTPDProxyHandler.doGet(prop, yacyRequestHeader, tmpproxyout, ClientIdentification.yacyProxyAgent);
@@ -125,9 +125,6 @@ public void service (ServletRequest req, ServletResponse res) throws ServletExce
prop.put(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
prop.put(HeaderFramework.CONNECTION_PROP_CLIENT_HTTPSERVLETREQUEST, request);
yacyRequestHeader.put(HeaderFramework.HOST, hostwithport );
yacyRequestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, proxyurl.getPath());
final ByteArrayOutputStream tmpproxyout = new ByteArrayOutputStream();
HTTPDProxyHandler.doGet(prop, yacyRequestHeader, tmpproxyout, ClientIdentification.yacyProxyAgent);
@@ -256,7 +256,8 @@ private static void handleIncomingCookies(final ResponseHeader respondHeader, fi
}
/**
* Get a page from the remote server as proxy request for the client
* Get a page from the remote server as proxy request for the client.
* The target url is expected in the conProp CONNECTION_PROP_DIGESTURL
*
* @param conProp a collection of properties about the connection, like URL
* @param requestHeader The header lines of the connection from the request
@@ -298,8 +299,6 @@ public static void doGet(final HashMap<String, Object> conProp, final RequestHea
log.finest(reqID + " using redirector to " + url);
}
conProp.put(HeaderFramework.CONNECTION_PROP_DIGESTURL, url);
requestHeader.put(HeaderFramework.HOST, url.getHost() + ":" + url.getPort());
requestHeader.put(HeaderFramework.CONNECTION_PROP_PATH, url.getPath());
}
@@ -401,7 +400,7 @@ public static void doGet(final HashMap<String, Object> conProp, final RequestHea
* Get requested proxied page from the web
*
* @param conProp
* @param url
* @param url requested target url
* @param requestHeader
* @param cachedResponseHeader
* @param respond

0 comments on commit ce87025

Please sign in to comment.