/** * Set the source conduit for this channel. The source channel will automatically be updated. * * @param conduit the source conduit for this channel */ protected void setSourceConduit(StreamSourceConduit conduit) { this.sourceChannel = conduit == null ? null : new ConduitStreamSourceChannel(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 decompresses the source data according to the configuration in the given inflater. * * @param delegate the compressed channel * @param inflater the inflater to use * @return a decompressed channel * @throws IOException if the channel could not be constructed */ protected StreamSourceChannel getInflatingChannel(final StreamSourceChannel delegate, final Inflater inflater) throws IOException { return new ConduitStreamSourceChannel(Configurable.EMPTY, new InflatingStreamSourceConduit(new StreamSourceChannelWrappingConduit(delegate), inflater)); }
/** * 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
/** * Get the inbound request. If there is no request body, calling this method * may cause the next request to immediately be processed. The {@link StreamSourceChannel#close()} or {@link StreamSourceChannel#shutdownReads()} * method must be called at some point after the request is processed to prevent resource leakage and to allow * the next request to proceed. Any unread content will be discarded. * * @return the channel for the inbound request, or {@code null} if another party already acquired the channel */ public StreamSourceChannel getRequestChannel() { if (requestChannel != null) { if(anyAreSet(state, FLAG_REQUEST_RESET)) { state &= ~FLAG_REQUEST_RESET; return requestChannel; } return null; } if (anyAreSet(state, FLAG_REQUEST_TERMINATED)) { return requestChannel = new ReadDispatchChannel(new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread()))); } final ConduitWrapper<StreamSourceConduit>[] wrappers = this.requestWrappers; final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel(); if (wrappers != null) { this.requestWrappers = null; final WrapperConduitFactory<StreamSourceConduit> factory = new WrapperConduitFactory<>(wrappers, requestWrapperCount, sourceChannel.getConduit(), this); sourceChannel.setConduit(factory.create()); } return requestChannel = new ReadDispatchChannel(sourceChannel); }
/** * Set the source conduit for this channel. The source channel will automatically be updated. * * @param conduit the source conduit for this channel */ protected void setSourceConduit(StreamSourceConduit conduit) { this.sourceChannel = conduit == null ? null : new ConduitStreamSourceChannel(this, conduit); }
@Override public ConduitStreamSourceChannel getSourceChannel() { return new ConduitStreamSourceChannel(null, null); }
@Override public ConduitStreamSourceChannel getSourceChannel() { return new ConduitStreamSourceChannel(null, null); }
@Override public ConduitStreamSourceChannel getSourceChannel() { return new ConduitStreamSourceChannel(null, null); }
private static ConduitStreamSourceChannel createSourceChannel() { final StreamSourceConduit sourceConduit = Mockito.mock( StreamSourceConduit.class ); final ConduitStreamSourceChannel sourceChannel = new ConduitStreamSourceChannel( null, sourceConduit ); return sourceChannel; }
@Override public ConduitStreamSourceChannel getSourceChannel() { return new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(worker.getIoThread())); }
@Override public ConduitStreamSourceChannel getSourceChannel() { return new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(worker.getIoThread())); }
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 decompresses the source data according to the configuration in the given inflater. * * @param delegate the compressed channel * @param inflater the inflater to use * @return a decompressed channel * @throws IOException if the channel could not be constructed */ protected StreamSourceChannel getInflatingChannel(final StreamSourceChannel delegate, final Inflater inflater) throws IOException { return new ConduitStreamSourceChannel(Configurable.EMPTY, new InflatingStreamSourceConduit(new StreamSourceChannelWrappingConduit(delegate), inflater)); }
/** * 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
/** * Get the inbound request. If there is no request body, calling this method * may cause the next request to immediately be processed. The {@link StreamSourceChannel#close()} or {@link StreamSourceChannel#shutdownReads()} * method must be called at some point after the request is processed to prevent resource leakage and to allow * the next request to proceed. Any unread content will be discarded. * * @return the channel for the inbound request, or {@code null} if another party already acquired the channel */ public StreamSourceChannel getRequestChannel() { if (requestChannel != null) { if(anyAreSet(state, FLAG_REQUEST_RESET)) { state &= ~FLAG_REQUEST_RESET; return requestChannel; } return null; } if (anyAreSet(state, FLAG_REQUEST_TERMINATED)) { return requestChannel = new ReadDispatchChannel(new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread()))); } final ConduitWrapper<StreamSourceConduit>[] wrappers = this.requestWrappers; final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel(); if (wrappers != null) { this.requestWrappers = null; final WrapperConduitFactory<StreamSourceConduit> factory = new WrapperConduitFactory<>(wrappers, requestWrapperCount, sourceChannel.getConduit(), this); sourceChannel.setConduit(factory.create()); } return requestChannel = new ReadDispatchChannel(sourceChannel); }
/** * Get the inbound request. If there is no request body, calling this method * may cause the next request to immediately be processed. The {@link StreamSourceChannel#close()} or {@link StreamSourceChannel#shutdownReads()} * method must be called at some point after the request is processed to prevent resource leakage and to allow * the next request to proceed. Any unread content will be discarded. * * @return the channel for the inbound request, or {@code null} if another party already acquired the channel */ public StreamSourceChannel getRequestChannel() { if (requestChannel != null) { if(anyAreSet(state, FLAG_REQUEST_RESET)) { state &= ~FLAG_REQUEST_RESET; return requestChannel; } return null; } if (anyAreSet(state, FLAG_REQUEST_TERMINATED)) { return requestChannel = new ReadDispatchChannel(new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread()))); } final ConduitWrapper<StreamSourceConduit>[] wrappers = this.requestWrappers; final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel(); if (wrappers != null) { this.requestWrappers = null; final WrapperConduitFactory<StreamSourceConduit> factory = new WrapperConduitFactory<>(wrappers, requestWrapperCount, sourceChannel.getConduit(), this); sourceChannel.setConduit(factory.create()); } return requestChannel = new ReadDispatchChannel(sourceChannel); }