Drop the unnecessary host page servlet name from URLs
We don't actually need to redirect clients to "/Gerrit" but can instead have the UrlRewriteFilter serve the host page to them when the URL is "" or "/". This cuts down on a redirect when visiting the homepage for the site, but it also makes URLs a tiny bit shorter by removing 6 letters. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -103,7 +103,7 @@ public class BecomeAnyAccountLoginServlet extends HttpServlet {
|
||||
c.setPath(req.getContextPath() + "/");
|
||||
new AccountCookie(account.getId(), false).set(c, server);
|
||||
rsp.addCookie(c);
|
||||
rsp.sendRedirect("Gerrit");
|
||||
rsp.sendRedirect(c.getPath());
|
||||
|
||||
} else {
|
||||
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
|
@@ -194,7 +194,6 @@ public class HostPageServlet extends HttpServlet {
|
||||
} else {
|
||||
reqUrl.setLength(0);
|
||||
reqUrl.append(canonicalUrl);
|
||||
reqUrl.append("Gerrit");
|
||||
if (hasScreenName(screen)) {
|
||||
reqUrl.append('#');
|
||||
reqUrl.append(screen.substring(1));
|
||||
@@ -213,7 +212,7 @@ public class HostPageServlet extends HttpServlet {
|
||||
if (hasScreenName(screen)) {
|
||||
final StringBuilder r = new StringBuilder();
|
||||
r.append(GerritServer.serverUrl(req));
|
||||
r.append("Gerrit#");
|
||||
r.append("#");
|
||||
r.append(screen.substring(1));
|
||||
rsp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
||||
rsp.setHeader("Location", r.toString());
|
||||
|
@@ -549,7 +549,6 @@ class OpenIdServiceImpl implements OpenIdService {
|
||||
final HttpServletResponse rsp) throws IOException {
|
||||
final StringBuilder rdr = new StringBuilder();
|
||||
rdr.append(GerritServer.serverUrl(req));
|
||||
rdr.append("Gerrit");
|
||||
final String token = req.getParameter(P_TOKEN);
|
||||
if (token != null && !token.startsWith("SignInFailure,")) {
|
||||
rdr.append('#');
|
||||
@@ -568,7 +567,6 @@ class OpenIdServiceImpl implements OpenIdService {
|
||||
final String errorDetail) throws IOException {
|
||||
final StringBuilder rdr = new StringBuilder();
|
||||
rdr.append(GerritServer.serverUrl(req));
|
||||
rdr.append("Gerrit");
|
||||
rdr.append('#');
|
||||
rdr.append("SignInFailure");
|
||||
rdr.append(',');
|
||||
|
@@ -52,9 +52,6 @@ public class UrlRewriteFilter implements Filter {
|
||||
|
||||
static {
|
||||
staticLinks = new HashMap<String, String>();
|
||||
staticLinks.put("", "");
|
||||
staticLinks.put("/", "");
|
||||
|
||||
staticLinks.put("/mine", Link.MINE);
|
||||
staticLinks.put("/starred", Link.MINE_STARRED);
|
||||
staticLinks.put("/settings", Link.SETTINGS);
|
||||
@@ -99,6 +96,8 @@ public class UrlRewriteFilter implements Filter {
|
||||
//
|
||||
chain.doFilter(req, rsp);
|
||||
} else if (staticExtension(pathInfo, req, rsp, chain)) {
|
||||
} else if ("".equals(pathInfo) || "/".equals(pathInfo)) {
|
||||
req.getRequestDispatcher("/Gerrit").forward(req, rsp);
|
||||
} else if (staticLink(pathInfo, req, rsp)) {
|
||||
} else if (bareChangeId(pathInfo, req, rsp)) {
|
||||
} else if (bareRevisionId(pathInfo, req, rsp)) {
|
||||
@@ -243,7 +242,7 @@ public class UrlRewriteFilter implements Filter {
|
||||
private static StringBuffer toGerrit(final HttpServletRequest req) {
|
||||
final StringBuffer url = new StringBuffer();
|
||||
url.append(req.getContextPath());
|
||||
url.append("/Gerrit");
|
||||
url.append("/");
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
@@ -272,7 +272,7 @@ class Receive extends AbstractGitCommand {
|
||||
msg.append("\nPlease complete a new agreement");
|
||||
msg.append(":\n\n ");
|
||||
msg.append(server.getCanonicalURL());
|
||||
msg.append("Gerrit#");
|
||||
msg.append("#");
|
||||
msg.append(Link.SETTINGS_AGREEMENTS);
|
||||
msg.append("\n");
|
||||
}
|
||||
@@ -296,7 +296,7 @@ class Receive extends AbstractGitCommand {
|
||||
msg.append("\nPlease review your contact information");
|
||||
msg.append(":\n\n ");
|
||||
msg.append(server.getCanonicalURL());
|
||||
msg.append("Gerrit#");
|
||||
msg.append("#");
|
||||
msg.append(Link.SETTINGS_CONTACT);
|
||||
msg.append("\n");
|
||||
}
|
||||
@@ -326,7 +326,7 @@ class Receive extends AbstractGitCommand {
|
||||
if (server.getCanonicalURL() != null) {
|
||||
msg.append(":\n\n ");
|
||||
msg.append(server.getCanonicalURL());
|
||||
msg.append("Gerrit#");
|
||||
msg.append("#");
|
||||
msg.append(Link.SETTINGS_AGREEMENTS);
|
||||
msg.append("\n");
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user