
Code: Select all
private @NotNull HttpRoutePlanner proxyRoutePlanner(String proxyHostname, int proxyPort) {
String nonProxyHostsProperty = System.getProperty("http.nonProxyHosts");
String[] nonProxyHosts = nonProxyHostsProperty != null ? nonProxyHostsProperty.split("\\|") : new String[0];
HttpHost proxyHost = new HttpHost(proxyHostname, proxyPort);
return (httpHost, httpRequest, httpContext) -> {
if (Arrays.stream(nonProxyHosts).anyMatch(nonProxyHost -> FilenameUtils.wildcardMatch(httpHost.getHostName(), nonProxyHost, IOCase.INSENSITIVE))) {
return new HttpRoute(httpHost);
}
return new HttpRoute(httpHost, proxyHost);
};
}
- Die Methode speichert zunächst eine Liste von 'Non -Proxy' Hostnamen in ein Array von String s, nachdem sie von der http.nonproxyhostes -systems -codes -systems -symboles -system -achte it it tods tods tods the code systems -Eigenschaft. Httphost Objekt Verwenden Sie den ProxyHostName und proxyport übergeben in die ProxyroutePlanner () -Methode. Diese httphost -Methode wird später in der Methode beim Erstellen einer "Proxy" -Route ().
Code: Select all
HttpRoute(httpHost, proxyHost)
Was genau läuft die Rückgabe Anweisung des enthaltenden ProxyroutePlanner () Methode? Gibt es eine andere anonyme Funktion zurück, die noch etwas anderes zurückgibt (ein httproute Objekt)? Httphost befindet sich in der Liste der "Nicht -Proxy" -Hosts. Wenn dies der Fall ist, gibt es ein "Nicht -Proxy" -Httproute (httoHost) zurück, ansonsten für "Proxy" -Hosts, es gibt ein 'Proxy' httProute (httphost, proxyHost) Objekt zurück. Aber woher kommt diese Argumente? Httproute < /code>, das aussieht, wie
erneut aus der enthaltenden ProxyroutePlanner () < /code> -Methode zurückgegeben wird, dies ist jedoch nicht sinnvoll. Der Rückgabetyp der ProxyroutePlanner () ist nicht httproute , aber httproutePlanner ! und diese Objekte sind nicht einmal verwandt. Ich verstehe nichts. Könnte mir jemand bitte helfen zu verstehen, was mit dieser Funktion los ist? Jede Hilfe/Einsicht wäre sehr geschätzt. Vielen Dank für Ihre Zeit und Geduld im Voraus!