/**
* Gets the redirect location from the HTTP headers and uses that to modify the HttpPost so that it can be reused
* @param resp the HttpResponse that indicates a redirect (451)
* @param post the HttpPost that was originally sent to the server
* @return the HttpPost, updated with the redirect location
*/
private HttpPost getRedirect(HttpResponse resp,HttpPost post){
Header locHeader=resp.getFirstHeader("X-MS-Location");
if (locHeader != null) {
String loc=locHeader.getValue();
if (loc != null && loc.startsWith("http")) {
post.setURI(URI.create(loc));
return post;
}
}
return null;
}

Example 5

From project ardverk-dht, under directory /components/store/src/main/java/org/ardverk/dht/storage/message/.