Skip to content

Commit

Permalink
Fixed host name can't be null
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed Sep 26, 2012
1 parent 66a15e9 commit d7c91c4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,14 @@ private void increaseTimeouts(HttpParams requestParams) {
private void detectRedirect(String originalUrl, Context context, HttpContext httpContext) {
HttpUriRequest request = (HttpUriRequest) httpContext.getAttribute(ExecutionContext.HTTP_REQUEST);
HttpHost host = (HttpHost) httpContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
String redirectedUrl = host.toURI() + request.getURI();

// Sometimes the request doesn't contain the "http://host" part
String redirectedUrl;
if (request.getURI().getScheme() == null) {
redirectedUrl = host.toURI() + request.getURI();
} else {
redirectedUrl = request.getURI().toString();
}

redirectFrom = originalUrl.substring(0, originalUrl.indexOf("/rest/"));
redirectTo = redirectedUrl.substring(0, redirectedUrl.indexOf("/rest/"));
Expand Down

0 comments on commit d7c91c4

Please sign in to comment.