@Override protected void doSessionClosed(IoSessionEx session) throws Exception { // if iosession is not being closed then a higher level is asking to close out this http session, likely for upgrade if (!session.isClosing()) { IoFilterChain filterChain = session.getFilterChain(); removeBridgeFilters(filterChain); } DefaultHttpSession httpSession = SESSION_KEY.remove(session); if (httpSession != null && !httpSession.isClosing()) { httpSession.reset(new IOException(LoggingUtils.EARLY_TERMINATION_OF_IOSESSION_MESSAGE).fillInStackTrace()); } }
@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); } }
@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); } } }
@Override protected void doExceptionCaught(final IoSessionEx session, Throwable cause) throws Exception { DefaultHttpSession httpSession = SESSION_KEY.get(session); if (httpSession != null && !httpSession.isClosing()) {
httpResponse.setBlockPadding(session.getParameter(".kbp") != null); boolean complete = (session.getCurrentWriteRequest() == null) && session.getWriteRequestQueue().isEmpty(session) && session.isClosing(); IoBufferAllocatorEx<? extends HttpBuffer> allocator = session.getBufferAllocator(); HttpBuffer unsharedEmpty = allocator.wrap(allocator.allocate(0)); String contentLength = session.getWriteHeader(HEADER_CONTENT_LENGTH); if (contentLength == null) { if (session.isClosing() || session.isWriteShutdown()) { long scheduledWriteBytes = session.getScheduledWriteBytes(); httpResponse.setHeader(HEADER_CONTENT_LENGTH, valueOf(scheduledWriteBytes));