HTTPHandler implements HttpHandler { void linkContext(ActionLog actionLog, HeaderMap headers) { String client = headers.getFirst(HTTPHandler.HEADER_CLIENT); if (client != null) actionLog.clients = List.of(client); String refId = headers.getFirst(HTTPHandler.HEADER_REF_ID); if (refId != null) actionLog.refIds = List.of(refId); String correlationId = headers.getFirst(HTTPHandler.HEADER_CORRELATION_ID); if (correlationId != null) actionLog.correlationIds = List.of(correlationId); if ("true".equals(headers.getFirst(HEADER_TRACE))) actionLog.trace = true; } HTTPHandler(LogManager logManager, SessionManager sessionManager, TemplateManager templateManager); @Override void handleRequest(HttpServerExchange exchange); static final HttpString HEADER_CORRELATION_ID; static final HttpString HEADER_CLIENT; static final HttpString HEADER_REF_ID; static final HttpString HEADER_TRACE; final RequestParser requestParser; final Route route; final List<Interceptor> interceptors; final WebContextImpl webContext; final HTTPErrorHandler errorHandler; final RequestBeanReader requestBeanReader; final ResponseBeanWriter responseBeanWriter; final RateControl rateControl; public WebSocketHandler webSocketHandler; public IPv4AccessControl accessControl; }
@Test void linkContext() { var actionLog = new ActionLog(null, null); var headers = new HeaderMap(); headers.put(HTTPHandler.HEADER_TRACE, "true"); headers.put(HTTPHandler.HEADER_CLIENT, "client"); handler.linkContext(actionLog, headers); assertThat(actionLog.trace).isTrue(); assertThat(actionLog.clients).containsExactly("client"); }