Allow disabling certain features of HostPageServlet
The user agent detection might not always be reliable for some environments, so permit disabling it if the server administrator wants the check to happen in the browser rather than the server. The server administrator may also wish to disable the automatic refresh logic associated with the site header, footer and CSS. For example, these assets might never change anyway without doing a full server restart, so checking the modification time on each incoming request is not worth the system call. Change-Id: Id2db1f53bb30e9cfac79f9d64d37e58737428094 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -1736,6 +1736,25 @@ should expire.
|
||||
+
|
||||
By default, unset, so no Expiry-Date header is generated.
|
||||
|
||||
|
||||
[[site]]Section site
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
[[site.checkUserAgent]]site.checkUserAgent::
|
||||
+
|
||||
If true the server checks the User-Agent HTTP header and sends the
|
||||
correct JavaScript to the client as part of the initial page load.
|
||||
This usually reduces a round-trip for the client, allowing the UI to
|
||||
start more quickly. If false, a tiny JavaScript loader is sent to the
|
||||
client instead to determine the correct code to use. Default is true.
|
||||
|
||||
[[site.refreshHeaderFooter]]site.refreshHeaderFooter::
|
||||
+
|
||||
If true the server checks the site header, footer and CSS files for
|
||||
updated versions. If false, a server restart is required to change
|
||||
any of these resources. Default is true, allowing automatic reloads.
|
||||
|
||||
|
||||
[[sshd]] Section sshd
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.httpd.HtmlDomUtil;
|
||||
import com.google.gerrit.httpd.WebSession;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gwt.user.server.rpc.RPCServletUtils;
|
||||
import com.google.gwtexpui.linker.server.Permutation;
|
||||
@@ -29,6 +30,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.slf4j.Logger;
|
||||
@@ -70,12 +72,14 @@ public class HostPageServlet extends HttpServlet {
|
||||
private final Document template;
|
||||
private final String noCacheName;
|
||||
private final PermutationSelector selector;
|
||||
private final boolean refreshHeaderFooter;
|
||||
private volatile Page page;
|
||||
|
||||
@Inject
|
||||
HostPageServlet(final Provider<CurrentUser> cu, final Provider<WebSession> w,
|
||||
final SitePaths sp, final ThemeFactory themeFactory,
|
||||
final GerritConfig gc, final ServletContext servletContext)
|
||||
final GerritConfig gc, final ServletContext servletContext,
|
||||
@GerritServerConfig final Config cfg)
|
||||
throws IOException, ServletException {
|
||||
currentUser = cu;
|
||||
session = w;
|
||||
@@ -83,6 +87,7 @@ public class HostPageServlet extends HttpServlet {
|
||||
signedOutTheme = themeFactory.getSignedOutTheme();
|
||||
signedInTheme = themeFactory.getSignedInTheme();
|
||||
site = sp;
|
||||
refreshHeaderFooter = cfg.getBoolean("site", "refreshHeaderFooter", true);
|
||||
|
||||
final String pageName = "HostPage.html";
|
||||
template = HtmlDomUtil.parseFile(getClass(), pageName);
|
||||
@@ -99,7 +104,7 @@ public class HostPageServlet extends HttpServlet {
|
||||
|
||||
final String src = "gerrit/gerrit.nocache.js";
|
||||
selector = new PermutationSelector("gerrit");
|
||||
if (IS_DEV) {
|
||||
if (IS_DEV || !cfg.getBoolean("site", "checkUserAgent", true)) {
|
||||
noCacheName = src;
|
||||
} else {
|
||||
final Element devmode = HtmlDomUtil.find(template, "gerrit_gwtdevmode");
|
||||
@@ -140,7 +145,7 @@ public class HostPageServlet extends HttpServlet {
|
||||
|
||||
private Page get() {
|
||||
Page p = page;
|
||||
if (p.isStale()) {
|
||||
if (refreshHeaderFooter && p.isStale()) {
|
||||
final Page newPage;
|
||||
try {
|
||||
newPage = new Page();
|
||||
|
Reference in New Issue
Block a user