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/"));
}
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));
}
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);
}
}
Aggregations