Source:
private boolean tryGetEnabledEndpointsForHost(String host, OutParam<EnumSet<AutodiscoverEndpoints>> endpoints) throws Exception { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( "Determining which endpoints are enabled for host %s", host)); for (int currentHop = 0; currentHop < AutodiscoverMaxRedirections; currentHop++) { URI autoDiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, host)); endpoints.setParam(EnumSet.of(AutodiscoverEndpoints.None)); HttpWebRequest request = null; try { request = new HttpClientWebRequest(httpClient, httpContext); if(getWebProxy() != null ){ request.setProxy(getWebProxy()); } try { request.setUrl(autoDiscoverUrl.toURL()); } catch (MalformedURLException e) { String strErr = String.format("Incorrect format : %s", url); throw new ServiceLocalException(strErr); } request.setRequestMethod("GET"); request.setAllowAutoRedirect(false); request.setPreAuthenticate(false); request.setUseDefaultCredentials(this.getUseDefaultCredentials()); prepareCredentials(request); request.prepareConnection(); try { request.executeRequest(); } catch (IOException e) { return false; } OutParam<URI> outParam = new OutParam<URI>(); if (this.tryGetRedirectionResponse(request, outParam)) { URI redirectUrl = outParam.getParam(); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned redirection to host '%s'", redirectUrl.getHost())); host = redirectUrl.getHost(); } else { endpoints.setParam(this.getEndpointsFromHttpWebResponse(request)); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned enabled endpoint flags: %s", endpoints.getParam().toString())); return true; } } finally { if (request != null) { try { request.close(); } catch (Exception e) { } } } } this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Maximum number of redirection hops %d exceeded", AutodiscoverMaxRedirections)); throw new MaximumRedirectionHopsExceededException(); }

Target:
private boolean tryGetEnabledEndpointsForHost(String host, OutParam<EnumSet<AutodiscoverEndpoints>> endpoints) throws Exception { this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( "Determining which endpoints are enabled for host %s", host)); for (int currentHop = 0; currentHop < AutodiscoverMaxRedirections; currentHop++) { URI autoDiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, host)); endpoints.setParam(EnumSet.of(AutodiscoverEndpoints.None)); HttpWebRequest request = null; try { request = new HttpClientWebRequest(httpClient, httpContext); request.setProxy(getWebProxy()); try { request.setUrl(autoDiscoverUrl.toURL()); } catch (MalformedURLException e) { String strErr = String.format("Incorrect format : %s", url); throw new ServiceLocalException(strErr); } request.setRequestMethod("GET"); request.setAllowAutoRedirect(false); request.setPreAuthenticate(false); request.setUseDefaultCredentials(this.getUseDefaultCredentials()); prepareCredentials(request); request.prepareConnection(); try { request.executeRequest(); } catch (IOException e) { return false; } OutParam<URI> outParam = new OutParam<URI>(); if (this.tryGetRedirectionResponse(request, outParam)) { URI redirectUrl = outParam.getParam(); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned redirection to host '%s'", redirectUrl.getHost())); host = redirectUrl.getHost(); } else { endpoints.setParam(this.getEndpointsFromHttpWebResponse(request)); this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Host returned enabled endpoint flags: %s", endpoints.getParam().toString())); return true; } } finally { if (request != null) { try { request.close(); } catch (Exception e) { } } } } this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format("Maximum number of redirection hops %d exceeded", AutodiscoverMaxRedirections)); throw new MaximumRedirectionHopsExceededException(); }