Source:
private ExtendedHttpMethod followRedirects(HttpClient httpClient, int redirectCount, ExtendedHttpMethod httpMethod, org.apache.http.HttpResponse httpResponse, HttpContext httpContext, SubmitContext submitContext) throws Exception { EntityEnclosingRequestWrapper httpRequestWrapper = (EntityEnclosingRequestWrapper)httpContext.getAttribute(org.apache.http.protocol.ExecutionContext.HTTP_REQUEST); int statusCode = httpResponse.getStatusLine().getStatusCode(); ExtendedHttpMethod getMethod; if((statusCode != 303) && (httpRequestWrapper != null) && (httpRequestWrapper.getMethod().equals(RestRequestInterface.HttpMethod.POST.toString()))) getMethod = new ExtendedPostMethod(); else { getMethod = new ExtendedGetMethod(); } submitContext.setProperty("httpMethod", getMethod); AbstractHttpRequestInterface<?> httpRequest = (AbstractHttpRequestInterface<?>)submitContext.getProperty(WSDL_REQUEST); filterRequest(submitContext, httpRequest); getMethod .getMetrics() .getTotalTimer() .set(httpMethod.getMetrics().getTotalTimer().getStart(), httpMethod.getMetrics().getTotalTimer().getStop()); getMethod.getMetrics().setHttpMethod(httpMethod.getMethod()); captureMetrics(httpMethod, httpClient); String location = httpResponse.getFirstHeader("Location").getValue(); URI uri = new URI(new URI(httpMethod.getURI().toString(), true), location, true); java.net.URI newUri = HttpUtils.createUri(uri.getScheme(), uri.getEscapedUserinfo(), uri.getHost(), uri.getPort(), uri.getEscapedPath(), uri.getEscapedQuery(), uri.getEscapedFragment()); getMethod.setURI(newUri); getMethod.setHeader("Host",uri.getHost()); org.apache.http.HttpResponse response = submitRequest(getMethod, httpContext); if (isRedirectResponse(response.getStatusLine().getStatusCode())) { if (redirectCount == 10) { throw new Exception("Maximum number of Redirects reached [10]"); } try { getMethod = followRedirects(httpClient, redirectCount + 1, getMethod, response, httpContext, submitContext); } finally { } } for (Header header : httpMethod.getAllHeaders()) { getMethod.addHeader(header); } return getMethod; }

Target:
private ExtendedHttpMethod followRedirects(HttpClient httpClient, int redirectCount, ExtendedHttpMethod httpMethod, org.apache.http.HttpResponse httpResponse, HttpContext httpContext, SubmitContext submitContext) throws Exception { EntityEnclosingRequestWrapper httpRequestWrapper = (EntityEnclosingRequestWrapper)httpContext .getAttribute(org.apache.http.protocol.ExecutionContext.HTTP_REQUEST); ExtendedHttpMethod getMethod; if(isPostMethod(httpRequestWrapper, httpResponse)) getMethod = new ExtendedPostMethod(); else { getMethod = new ExtendedGetMethod(); } submitContext.setProperty("httpMethod", getMethod); AbstractHttpRequestInterface<?> httpRequest = (AbstractHttpRequestInterface<?>)submitContext.getProperty(WSDL_REQUEST); filterRequest(submitContext, httpRequest); getMethod .getMetrics() .getTotalTimer() .set(httpMethod.getMetrics().getTotalTimer().getStart(), httpMethod.getMetrics().getTotalTimer().getStop()); getMethod.getMetrics().setHttpMethod(httpMethod.getMethod()); captureMetrics(httpMethod, httpClient); String location = httpResponse.getFirstHeader("Location").getValue(); URI uri = new URI(new URI(httpMethod.getURI().toString(), true), location, true); java.net.URI newUri = HttpUtils.createUri(uri.getScheme(), uri.getEscapedUserinfo(), uri.getHost(), uri.getPort(), uri.getEscapedPath(), uri.getEscapedQuery(), uri.getEscapedFragment()); getMethod.setURI(newUri); getMethod.setHeader("Host",uri.getHost()); org.apache.http.HttpResponse response = submitRequest(getMethod, httpContext); if (isRedirectResponse(response.getStatusLine().getStatusCode())) { if (redirectCount == 10) { throw new Exception("Maximum number of Redirects reached [10]"); } try { getMethod = followRedirects(httpClient, redirectCount + 1, getMethod, response, httpContext, submitContext); } finally { } } for (Header header : httpMethod.getAllHeaders()) { getMethod.addHeader(header); } return getMethod; }