use of com.alibaba.druid.support.http.stat.WebAppStat in project druid by alibaba.
the class UserAgentBotStat method test_archiveOrgBot.
public void test_archiveOrgBot() throws Exception {
WebAppStat stat = new WebAppStat("");
stat.computeUserAgent("Mozilla/5.0 (compatible; archive.org_bot +http://www.archive.org/details/archive.org_bot)");
Assert.assertEquals(1, stat.getBotCount());
}
use of com.alibaba.druid.support.http.stat.WebAppStat in project druid by alibaba.
the class StatHandlerInterceptor method preHandle.
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
final WebAppStat webAppStat = getWebAppStat(request);
String requestURI = getRequestURI(request);
long startNano = System.nanoTime();
long startMillis = System.currentTimeMillis();
WebRequestStat requestStat = new WebRequestStat(startNano, startMillis);
WebRequestStat.set(requestStat);
WebSessionStat sessionStat = getSessionStat(request);
webAppStat.beforeInvoke();
WebURIStat uriStat = webAppStat.getURIStat(requestURI, false);
if (uriStat == null) {
int index = requestURI.indexOf(";jsessionid=");
if (index != -1) {
requestURI = requestURI.substring(0, index);
uriStat = webAppStat.getURIStat(requestURI, false);
}
}
if (isProfileEnable()) {
Profiler.initLocal();
Profiler.enter(requestURI, Profiler.PROFILE_TYPE_WEB);
}
// 第一次访问时,uriStat这里为null,是为了防止404攻击。
if (uriStat != null) {
uriStat.beforeInvoke();
}
// 第一次访问时,sessionId为null,如果缺省sessionCreate=false,sessionStat就为null。
if (sessionStat != null) {
sessionStat.beforeInvoke();
}
return true;
}
use of com.alibaba.druid.support.http.stat.WebAppStat in project druid by alibaba.
the class UserAgentBotStat method test_YandexBot.
public void test_YandexBot() throws Exception {
WebAppStat stat = new WebAppStat("");
stat.computeUserAgent("Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)");
Assert.assertEquals(1, stat.getBotCount());
}
use of com.alibaba.druid.support.http.stat.WebAppStat in project druid by alibaba.
the class UserAgentBotStat method test_Yeti.
public void test_Yeti() throws Exception {
WebAppStat stat = new WebAppStat("");
stat.computeUserAgent("Yeti/1.0 (NHN Corp.; http://help.naver.com/robots/)");
Assert.assertEquals(1, stat.getBotCount());
}
use of com.alibaba.druid.support.http.stat.WebAppStat in project druid by alibaba.
the class UserAgentBotStat method test_unkownBot2.
public void test_unkownBot2() throws Exception {
WebAppStat stat = new WebAppStat("");
stat.computeUserAgent("Mozilla/5.0 (compatible; MJ12bot/v1.4.2; http://www.majestic12.co.uk/bot.php?+)");
Assert.assertEquals(1, stat.getBotCount());
}
Aggregations