/** * 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; }
@Override public void operationComplete(ConnectFuture future) { String connectURI = getConnectURIs().iterator().next(); if (future.isConnected()) { DefaultHttpSession connectSession = (DefaultHttpSession) future.getSession(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Connected to " + connectURI + " [" + acceptSession + "->" + connectSession + "]"); } if (acceptSession == null || acceptSession.isClosing()) { connectSession.close(true); } else { AttachedSessionManager attachedSessionManager = attachSessions(acceptSession, connectSession); connectSession.getCloseFuture().addListener(new Upgrader(connectSession, acceptSession)); acceptSession.getCloseFuture().addListener(new Upgrader(acceptSession, connectSession)); flushQueuedMessages(acceptSession, attachedSessionManager); } } else { LOGGER.warn("Connection to " + connectURI + " failed [" + acceptSession + "->]"); acceptSession.setStatus(HttpStatus.SERVER_GATEWAY_TIMEOUT); acceptSession.close(true); } }
acceptSession.setStatus(CLIENT_NOT_FOUND); acceptSession.close(false); return;
httpSession.setStatus(httpResponse.getStatus()); httpSession.setVersion(httpResponse.getVersion()); Map<String,List<String>> remainingHttpxeLevelHeaders = httpResponse.getHeaders();
@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); } } }
HttpStatus httpStatus = httpResponse.getStatus(); httpSession.setStatus(httpStatus); httpSession.setReason(httpResponse.getReason()); httpSession.setVersion(httpResponse.getVersion());