/** * Helper method performing loop detection * @param acceptSession - session parameter * @return - whether a loop was detected or not */ private boolean validateNoLoopDetected(DefaultHttpSession acceptSession) { List<String> viaHeaders = acceptSession.getReadHeaders(HEADER_VIA); if (viaHeaders != null && viaHeaders.stream().anyMatch(h -> h.equals(viaHeader))) { LOGGER.warn("Connection to " + getConnectURIs().iterator().next() + " failed due to loop detection [" + acceptSession + "->]"); acceptSession.setStatus(HttpStatus.SERVER_LOOP_DETECTED); acceptSession.close(true); return false; } return true; }
Map<String,List<String>> requestHeaders = new HashMap<>(session.getReadHeaders()); req.setHeaders(requestHeaders); HttpUtils.restrictHeaders(req, HTTPXE_ENVELOPE_HEADERS); Map<String,List<String>> sessionHeaders = new HashMap<>(httpSession.getReadHeaders()); sessionHeaders.put(HEADER_CONTENT_TYPE, Collections.singletonList(CONTENT_TYPE_APPLICATION_X_MESSAGE_HTTP)); httpSession.setReadHeaders(sessionHeaders);
@Override protected void doSessionClosed(IoSessionEx session) throws Exception { DefaultHttpSession httpSession = HTTP_SESSION_KEY.remove(session); if (httpSession != null) { boolean connectionClose = hasCloseHeader(httpSession.getReadHeaders(HttpHeaders.HEADER_CONNECTION)); if (!httpSession.isClosing() && !connectionClose) { httpSession.setStatus(HttpStatus.SERVER_GATEWAY_TIMEOUT); httpSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); return; } if (connectionClose && !httpSession.isClosing()) { httpSession.getProcessor().remove(httpSession); } if (!session.isClosing()) { IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); } } }
boolean serverToClose = hasCloseHeader(session.getReadHeaders(HEADER_CONNECTION)); boolean upgrade = session.getStatus() == INFO_SWITCHING_PROTOCOLS;