in web/src/main/java/org/apache/shiro/web/servlet/ShiroHttpServletResponse.java [233:275]
private String toAbsolute(String location) {
if (location == null) {
return (location);
}
boolean leadingSlash = location.startsWith("/");
if (leadingSlash || !hasScheme(location)) {
StringBuilder buf = new StringBuilder();
String scheme = request.getScheme();
String name = request.getServerName();
int port = request.getServerPort();
try {
buf.append(scheme).append("://").append(name);
if ((scheme.equals("http") && port != 80)
|| (scheme.equals("https") && port != 443)) {
buf.append(':').append(port);
}
if (!leadingSlash) {
String relativePath = request.getRequestURI();
int pos = relativePath.lastIndexOf('/');
relativePath = relativePath.substring(0, pos);
String encodedURI = URLEncoder.encode(relativePath, getCharacterEncoding());
buf.append(encodedURI).append('/');
}
buf.append(location);
} catch (IOException e) {
IllegalArgumentException iae = new IllegalArgumentException(location);
iae.initCause(e);
throw iae;
}
return buf.toString();
} else {
return location;
}
}