/** * Set the sink conduit for this channel. The sink channel will automatically be updated. * * @param conduit the sink conduit for this channel */ protected void setSinkConduit(StreamSinkConduit conduit) { this.sinkChannel = conduit == null ? null : new ConduitStreamSinkChannel(this, conduit); }
public Http2ServerConnection(Http2Channel channel, Http2StreamSourceChannel requestChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.requestChannel = requestChannel; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; this.rootHandler = rootHandler; responseChannel = requestChannel.getResponseChannel(); originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(channel, originalSourceConduit); }
/** * Create a stream channel that compresses to the destination according to the configuration in the given inflater. * * @param delegate the channel to compress to * @param deflater the deflater to use * @return a compressed channel * @throws IOException if the channel could not be constructed */ protected StreamSinkChannel getDeflatingChannel(final StreamSinkChannel delegate, final Deflater deflater) throws IOException { return new ConduitStreamSinkChannel(Configurable.EMPTY, new DeflatingStreamSinkConduit(new StreamSinkChannelWrappingConduit(delegate), deflater)); }
/** * Channel that is used when the request is already half closed * @param channel * @param undertowOptions * @param bufferSize * @param rootHandler */ public Http2ServerConnection(Http2Channel channel, Http2DataStreamSinkChannel sinkChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.rootHandler = rootHandler; this.requestChannel = null; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; responseChannel = sinkChannel; originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread())); } @Override
final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit); long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel); targetChannel.shutdownWrites();
/** * Set the sink conduit for this channel. The sink channel will automatically be updated. * * @param conduit the sink conduit for this channel */ protected void setSinkConduit(StreamSinkConduit conduit) { this.sinkChannel = conduit == null ? null : new ConduitStreamSinkChannel(this, conduit); }
private static ConduitStreamSinkChannel createSinkChannel() throws IOException { final StreamSinkConduit sinkConduit = Mockito.mock( StreamSinkConduit.class ); Mockito.when( sinkConduit.write( Matchers.any( ByteBuffer.class ) ) ).thenReturn( 1 ); final ConduitStreamSinkChannel sinkChannel = new ConduitStreamSinkChannel( null, sinkConduit ); return sinkChannel; }
public Http2ServerConnection(Http2Channel channel, Http2StreamSourceChannel requestChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.requestChannel = requestChannel; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; this.rootHandler = rootHandler; responseChannel = requestChannel.getResponseChannel(); originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(channel, originalSourceConduit); }
public Http2ServerConnection(Http2Channel channel, Http2StreamSourceChannel requestChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.requestChannel = requestChannel; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; this.rootHandler = rootHandler; responseChannel = requestChannel.getResponseChannel(); originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(channel, originalSourceConduit); }
/** * Create a stream channel that compresses to the destination according to the configuration in the given inflater. * * @param delegate the channel to compress to * @param deflater the deflater to use * @return a compressed channel * @throws IOException if the channel could not be constructed */ protected StreamSinkChannel getDeflatingChannel(final StreamSinkChannel delegate, final Deflater deflater) throws IOException { return new ConduitStreamSinkChannel(Configurable.EMPTY, new DeflatingStreamSinkConduit(new StreamSinkChannelWrappingConduit(delegate), deflater)); }
/** * Channel that is used when the request is already half closed * @param channel * @param undertowOptions * @param bufferSize * @param rootHandler */ public Http2ServerConnection(Http2Channel channel, Http2DataStreamSinkChannel sinkChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.rootHandler = rootHandler; this.requestChannel = null; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; responseChannel = sinkChannel; originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread())); } @Override
/** * Channel that is used when the request is already half closed * @param channel * @param undertowOptions * @param bufferSize * @param rootHandler */ public Http2ServerConnection(Http2Channel channel, Http2DataStreamSinkChannel sinkChannel, OptionMap undertowOptions, int bufferSize, HttpHandler rootHandler) { this.channel = channel; this.rootHandler = rootHandler; this.requestChannel = null; this.undertowOptions = undertowOptions; this.bufferSize = bufferSize; responseChannel = sinkChannel; originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel); originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel); this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit); this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread())); } @Override
final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit); long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel); targetChannel.shutdownWrites();
final ConduitStreamSinkChannel targetChannel = new ConduitStreamSinkChannel(null, conduit); long transferred = sourceFileChannel.transferTo(0, resource.getContentLength(), targetChannel); targetChannel.shutdownWrites();
@Override public ConduitStreamSinkChannel getSinkChannel() { ConduitStreamSinkChannel sinkChannel = new ConduitStreamSinkChannel( Configurable.EMPTY, new BufferedStreamSinkConduit( new NullStreamSinkConduit(worker.getIoThread()), new PooledAdaptor(bufferPool.allocate()) ) ); sinkChannel.setCloseListener(conduitStreamSinkChannel -> { for (CloseListener l : closeListeners) { try { l.closed(InVMConnection.this); } catch (Throwable e) { UndertowLogger.REQUEST_LOGGER.exceptionInvokingCloseListener(l, e); } } }); return sinkChannel; }
@Override public ConduitStreamSinkChannel getSinkChannel() { ConduitStreamSinkChannel sinkChannel = new ConduitStreamSinkChannel( Configurable.EMPTY, new BufferedStreamSinkConduit( new NullStreamSinkConduit(worker.getIoThread()), new PooledAdaptor(bufferPool.allocate()) ) ); sinkChannel.setCloseListener(conduitStreamSinkChannel -> { for (CloseListener l : closeListeners) { try { l.closed(InVMConnection.this); } catch (Throwable e) { UndertowLogger.REQUEST_LOGGER.exceptionInvokingCloseListener(l, e); } } }); return sinkChannel; }