From: Mathieu Baudier Date: Fri, 6 Nov 2015 19:32:23 +0000 (+0000) Subject: Fix bot handling on canonical links X-Git-Tag: argeo-commons-2.1.30~37 X-Git-Url: https://git.argeo.org/?a=commitdiff_plain;h=1339280e5c79d505b283855b9373488380acd29f;p=lgpl%2Fargeo-commons.git Fix bot handling on canonical links git-svn-id: https://svn.argeo.org/commons/trunk@8553 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java index 1d0f0be44..f88ba6789 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/kernel/NodeHttp.java @@ -57,7 +57,8 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { String userAgent = request.getHeader("User-Agent").toLowerCase(); boolean isBot = false; boolean isCompatibleBrowser = false; - if (userAgent.contains("bot")) { + if (userAgent.contains("bot") || userAgent.contains("facebook") + || userAgent.contains("twitter")) { isBot = true; } else if (userAgent.contains("webkit") || userAgent.contains("gecko") @@ -70,15 +71,14 @@ class NodeHttp implements KernelConstants, ArgeoJcrConstants { isCompatibleBrowser = true; } - if (isCompatibleBrowser) {// redirect - response.setHeader("Location", "/#" + path); - response.setStatus(HttpServletResponse.SC_FOUND); - } else { - if (isBot && log.isDebugEnabled()) - log.debug(request.getHeader("User-Agent") + " is a bot"); - // TODO pure html - throw new UnsupportedOperationException(); - } + if (isBot) + log.warn("# BOT " + request.getHeader("User-Agent")); + if (isCompatibleBrowser && log.isTraceEnabled()) + log.trace("# BWS " + request.getHeader("User-Agent")); + // if (isCompatibleBrowser) {// redirect + response.setHeader("Location", "/#" + path); + response.setStatus(HttpServletResponse.SC_FOUND); + // } } }