Search in sources :

Example 6 with AccessLogEntry

use of com.yahoo.container.logging.AccessLogEntry in project vespa by vespa-engine.

the class AccessLogRequestLogTest method requireThatNoQueryPartIsHandledWhenRequestIsMalformed.

@Test
public void requireThatNoQueryPartIsHandledWhenRequestIsMalformed() {
    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    final String path = "/s>earch/";
    when(httpServletRequest.getRequestURI()).thenReturn(path);
    final String query = null;
    when(httpServletRequest.getQueryString()).thenReturn(query);
    final AccessLogEntry accessLogEntry = new AccessLogEntry();
    AccessLogRequestLog.populateAccessLogEntryFromHttpServletRequest(httpServletRequest, accessLogEntry);
    assertThat(accessLogEntry.getURI().toString(), is("/s%3Eearch/"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AccessLogEntry(com.yahoo.container.logging.AccessLogEntry) Test(org.testng.annotations.Test)

Example 7 with AccessLogEntry

use of com.yahoo.container.logging.AccessLogEntry in project vespa by vespa-engine.

the class AccessLogRequestLogTest method requireThatDoubleQuotingIsNotPerformed.

@Test
public void requireThatDoubleQuotingIsNotPerformed() {
    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    final String path = "/search/";
    when(httpServletRequest.getRequestURI()).thenReturn(path);
    final String query = "query=year%252010+%3B&customParameter=something";
    when(httpServletRequest.getQueryString()).thenReturn(query);
    final AccessLogEntry accessLogEntry = new AccessLogEntry();
    AccessLogRequestLog.populateAccessLogEntryFromHttpServletRequest(httpServletRequest, accessLogEntry);
    assertThat(accessLogEntry.getURI().toString(), is(path + '?' + query));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) AccessLogEntry(com.yahoo.container.logging.AccessLogEntry) Test(org.testng.annotations.Test)

Example 8 with AccessLogEntry

use of com.yahoo.container.logging.AccessLogEntry in project vespa by vespa-engine.

the class JDiscHttpServlet method dispatchHttpRequest.

private void dispatchHttpRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
    AccessLogEntry accessLogEntry = new AccessLogEntry();
    AccessLogRequestLog.populateAccessLogEntryFromHttpServletRequest(request, accessLogEntry);
    request.setAttribute(ATTRIBUTE_NAME_ACCESS_LOG_ENTRY, accessLogEntry);
    try {
        switch(request.getDispatcherType()) {
            case REQUEST:
                new HttpRequestDispatch(context, accessLogEntry, getMetricContext(request), request, response).dispatch();
                break;
            default:
                if (log.isLoggable(Level.INFO)) {
                    log.info("Unexpected " + request.getDispatcherType() + "; " + formatAttributes(request));
                }
                break;
        }
    } catch (OverloadException e) {
    // nop
    } catch (RuntimeException e) {
        throw new ExceptionWrapper(e);
    }
}
Also used : OverloadException(com.yahoo.jdisc.handler.OverloadException) AccessLogEntry(com.yahoo.container.logging.AccessLogEntry)

Aggregations

AccessLogEntry (com.yahoo.container.logging.AccessLogEntry)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 Test (org.testng.annotations.Test)5 AccessLogInterface (com.yahoo.container.logging.AccessLogInterface)1 OverloadException (com.yahoo.jdisc.handler.OverloadException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URISyntaxException (java.net.URISyntaxException)1 Test (org.junit.Test)1