/** * 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; }
private void doRedirectReceived(final IoSessionEx session, DefaultHttpSession httpSession, HttpMessage httpContent) throws URISyntaxException { if (httpContent.isComplete()) { if (shouldFollowRedirects(httpSession)) { followRedirect(httpSession, session); } else { httpSession.close(false); } } }
@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.close(false); return;