Search in sources :

Example 51 with WebAppStat

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());
}
Also used : WebAppStat(com.alibaba.druid.support.http.stat.WebAppStat)

Example 52 with WebAppStat

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;
}
Also used : WebSessionStat(com.alibaba.druid.support.http.stat.WebSessionStat) WebRequestStat(com.alibaba.druid.support.http.stat.WebRequestStat) WebAppStat(com.alibaba.druid.support.http.stat.WebAppStat) WebURIStat(com.alibaba.druid.support.http.stat.WebURIStat)

Example 53 with WebAppStat

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());
}
Also used : WebAppStat(com.alibaba.druid.support.http.stat.WebAppStat)

Example 54 with WebAppStat

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());
}
Also used : WebAppStat(com.alibaba.druid.support.http.stat.WebAppStat)

Example 55 with WebAppStat

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());
}
Also used : WebAppStat(com.alibaba.druid.support.http.stat.WebAppStat)

Aggregations

WebAppStat (com.alibaba.druid.support.http.stat.WebAppStat)113 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)3 MockFilterChain (org.springframework.mock.web.MockFilterChain)3 MockFilterConfig (org.springframework.mock.web.MockFilterConfig)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 MockServletContext (org.springframework.mock.web.MockServletContext)3 WebAppStatValue (com.alibaba.druid.support.http.stat.WebAppStatValue)1 WebRequestStat (com.alibaba.druid.support.http.stat.WebRequestStat)1 WebSessionStat (com.alibaba.druid.support.http.stat.WebSessionStat)1 WebURIStat (com.alibaba.druid.support.http.stat.WebURIStat)1 WebURIStatValue (com.alibaba.druid.support.http.stat.WebURIStatValue)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 MockHttpSession (org.springframework.mock.web.MockHttpSession)1