@Override public void completed(final ClientConnection connection) { final ServerConnection serverConnection = exchange.getConnection(); //we attach to the connection so it can be re-used serverConnection.putAttachment(clientAttachmentKey, connection); serverConnection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection serverConnection) { IoUtils.safeClose(connection); } }); connection.getCloseSetter().set(new ChannelListener<Channel>() { @Override public void handleEvent(Channel channel) { serverConnection.removeAttachment(clientAttachmentKey); } }); callback.completed(exchange, new ProxyConnection(connection, uri.getPath() == null ? "/" : uri.getPath())); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(final ClientConnection connection) { final ServerConnection serverConnection = exchange.getConnection(); //we attach to the connection so it can be re-used serverConnection.putAttachment(clientAttachmentKey, connection); serverConnection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection serverConnection) { IoUtils.safeClose(connection); } }); connection.getCloseSetter().set(new ChannelListener<Channel>() { @Override public void handleEvent(Channel channel) { serverConnection.removeAttachment(clientAttachmentKey); } }); callback.completed(exchange, new ProxyConnection(connection, uri.getPath() == null ? "/" : uri.getPath())); }
@Override public void completed(final ClientConnection connection) { final ServerConnection serverConnection = exchange.getConnection(); //we attach to the connection so it can be re-used serverConnection.putAttachment(clientAttachmentKey, connection); serverConnection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection serverConnection) { IoUtils.safeClose(connection); } }); connection.getCloseSetter().set(new ChannelListener<Channel>() { @Override public void handleEvent(Channel channel) { serverConnection.removeAttachment(clientAttachmentKey); } }); callback.completed(exchange, new ProxyConnection(connection, uri.getPath() == null ? "/" : uri.getPath())); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }
public UndertowHttpChannel(final HttpServerExchange exchange, final OnOpen onOpen, final OnError onError, final OnClose onClose) { super(Methods.HEAD.equals(exchange.getRequestMethod()), onOpen, onError, onClose); this.exchange = exchange.setPersistent(true).dispatch(); this.exchange.getConnection().addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection _) { notifyClose(); } }); }
@Override public void completed(HttpServerExchange exchange, ProxyConnection result) { if (holder != null) { holder.connection = result; } else { final ExclusiveConnectionHolder newHolder = new ExclusiveConnectionHolder(); newHolder.connection = result; ServerConnection connection = exchange.getConnection(); connection.putAttachment(exclusiveConnectionKey, newHolder); connection.addCloseListener(new ServerConnection.CloseListener() { @Override public void closed(ServerConnection connection) { ClientConnection clientConnection = newHolder.connection.getConnection(); if (clientConnection.isOpen()) { safeClose(clientConnection); } } }); } callback.completed(exchange, result); }