/** * @param url URL Only protocol and url authority are used (protocol://[user:pass@]host:[port]) * @param hasProxy has proxy * @param proxyHost proxy host * @param proxyPort proxy port * @param proxyUser proxy user * @param proxyPass proxy password */ public HttpClientKey(URL url, boolean hasProxy, String proxyHost, int proxyPort, String proxyUser, String proxyPass) { // N.B. need to separate protocol from authority otherwise http://server would match https://erver (<= sic, not typo error) // could use separate fields, but simpler to combine them this.target = url.getProtocol()+"://"+url.getAuthority(); this.hasProxy = hasProxy; this.proxyHost = proxyHost; this.proxyPort = proxyPort; this.proxyUser = proxyUser; this.proxyPass = proxyPass; this.hashCode = getHash(); }
HttpClientKey key = new HttpClientKey(url, useProxy, proxyHost, proxyPort, proxyUser, proxyPass); clientContext.setAttribute(CONTEXT_ATTRIBUTE_CLIENT_KEY, key); CloseableHttpClient httpClient = null; log.debug("Created new HttpClient: @"+System.identityHashCode(httpClient) + " " + key.toString()); log.debug("Reusing the HttpClient: @"+System.identityHashCode(httpClient) + " " + key.toString());