public HttpUriRequest getRedirect( final HttpRequest request, final HttpResponse response, final HttpContext context) throws ProtocolException { final URI uri = getLocationURI(request, response, context); final String method = request.getRequestLine().getMethod(); if (method.equalsIgnoreCase(HttpHeadHC4.METHOD_NAME)) { return new HttpHeadHC4(uri); } else if (method.equalsIgnoreCase(HttpGetHC4.METHOD_NAME)) { return new HttpGetHC4(uri); } else { final int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_TEMPORARY_REDIRECT) { return RequestBuilder.copy(request).setUri(uri).build(); } else { return new HttpGetHC4(uri); } } }