Top Description Inners Fields Constructors Methods
io.undertow.conduits

public Class ChunkedStreamSourceConduit

extends AbstractStreamSourceConduit<StreamSourceConduit>
Class Inheritance
Imports
io.undertow.UndertowMessages, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, io.undertow.server.Connectors, .HttpServerExchange, io.undertow.server.protocol.http.HttpAttachments, .HttpServerConnection, io.undertow.util.Attachable, .AttachmentKey, .HeaderMap, .PooledAdaptor, org.xnio.IoUtils, org.xnio.channels.StreamSinkChannel, org.xnio.conduits.AbstractStreamSourceConduit, .ConduitReadableByteChannel, .PushBackStreamSourceConduit, .StreamSourceConduit, java.io.Closeable, .IOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .FileChannel

Channel to de-chunkify data
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface

Field Summary

Modifier and TypeField and Description
private final ChunkedStreamSourceConduit.BufferWrapper
private final PushBackStreamSourceConduit
private final ChunkReader<T extends Conduit>
private final Closeable
private boolean
private final HttpServerExchange
private final ConduitListener<? super ChunkedStreamSourceConduit>
private boolean
private long
public static final AttachmentKey<HeaderMap>
TRAILERS

Deprecated
If the response has HTTP footers they are attached to the exchange under this key.

Constructor Summary

AccessConstructor and Description
public
ChunkedStreamSourceConduit(final StreamSourceConduit next, final PushBackStreamSourceConduit channel, final ByteBufferPool pool, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, Attachable attachable, Closeable closeable)

public
protected
ChunkedStreamSourceConduit(final StreamSourceConduit next, final ChunkedStreamSourceConduit.BufferWrapper bufferWrapper, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, final Attachable attachable, final HttpServerExchange exchange, final Closeable closeable, PushBackStreamSourceConduit channel)

Method Summary

Modifier and TypeMethod and Description
public boolean
public long
read(final ByteBuffer[]
the buffers to fill with data from the conduit
dsts
,
final int
the offset into the buffer array
offset
,
final int
the number of buffers to fill
length
)

Overrides org.xnio.conduits.AbstractStreamSourceConduit.read.

Implements org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffers.

public int
read(final ByteBuffer
the buffer to fill with data from the conduit
dst
)

Overrides org.xnio.conduits.AbstractStreamSourceConduit.read.

Implements org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffer.

public void
terminateReads()

Overrides org.xnio.conduits.AbstractSourceConduit.terminateReads.

Implements org.xnio.conduits.SourceConduit.terminateReads.

Indicate that no more data will be read from this conduit.

public long
transferTo(final long
the position within the file from which the transfer is to begin
position
,
final long
the number of bytes to be transferred
count
,
final FileChannel
the file to write to
target
)

Overrides org.xnio.conduits.AbstractStreamSourceConduit.transferTo.

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given file from this channel.

public long
transferTo(final long
the number of bytes to be transferred
count
,
final ByteBuffer
the buffer to copy through.
throughBuffer
,
final StreamSinkChannel
the destination to write to
target
)

Overrides org.xnio.conduits.AbstractStreamSourceConduit.transferTo.

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given channel target.

private void
updateRemainingAllowed(final int written)

Field Detail

bufferWrapperback to summary
private final ChunkedStreamSourceConduit.BufferWrapper bufferWrapper
channelback to summary
private final PushBackStreamSourceConduit channel
chunkReaderback to summary
private final ChunkReader<T extends Conduit> chunkReader
closeableback to summary
private final Closeable closeable
closedback to summary
private boolean closed
exchangeback to summary
private final HttpServerExchange exchange
finishListenerback to summary
private final ConduitListener<? super ChunkedStreamSourceConduit> finishListener
finishListenerInvokedback to summary
private boolean finishListenerInvoked
remainingAllowedback to summary
private long remainingAllowed
TRAILERSback to summary
public static final AttachmentKey<HeaderMap> TRAILERS

Deprecated

If the response has HTTP footers they are attached to the exchange under this key. They will only be available once the exchange has been fully read.

Annotations
@Deprecated

Constructor Detail

ChunkedStreamSourceConduitback to summary
public ChunkedStreamSourceConduit(final StreamSourceConduit next, final PushBackStreamSourceConduit channel, final ByteBufferPool pool, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, Attachable attachable, Closeable closeable)
ChunkedStreamSourceConduitback to summary
public ChunkedStreamSourceConduit(final StreamSourceConduit next, final HttpServerExchange exchange, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener)
ChunkedStreamSourceConduitback to summary
protected ChunkedStreamSourceConduit(final StreamSourceConduit next, final ChunkedStreamSourceConduit.BufferWrapper bufferWrapper, final ConduitListener<? super ChunkedStreamSourceConduit> finishListener, final Attachable attachable, final HttpServerExchange exchange, final Closeable closeable, PushBackStreamSourceConduit channel)

Method Detail

isFinishedback to summary
public boolean isFinished()
readback to summary
public long read(final ByteBuffer[] dsts, final int offset, final int length) throws IOException

Overrides org.xnio.conduits.AbstractStreamSourceConduit.read.

Implements org.xnio.conduits.StreamSourceConduit.read.

Doc from org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffers.

Parameters
dsts:ByteBuffer[]

the buffers to fill with data from the conduit

offset:int

the offset into the buffer array

length:int

the number of buffers to fill

Returns:long

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or this conduit's terminateReads() method was previously called

Annotations
@Override
Exceptions
IOException:
if an error occurs
readback to summary
public int read(final ByteBuffer dst) throws IOException

Overrides org.xnio.conduits.AbstractStreamSourceConduit.read.

Implements org.xnio.conduits.StreamSourceConduit.read.

Doc from org.xnio.conduits.StreamSourceConduit.read.

Read a sequence of bytes from this conduit to the given buffer.

Parameters
dst:ByteBuffer

the buffer to fill with data from the conduit

Returns:int

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached or this conduit's terminateReads() method was previously called

Annotations
@Override
Exceptions
IOException:
if an error occurs
terminateReadsback to summary
public void terminateReads() throws IOException

Overrides org.xnio.conduits.AbstractSourceConduit.terminateReads.

Implements org.xnio.conduits.SourceConduit.terminateReads.

Doc from org.xnio.conduits.SourceConduit.terminateReads.

Indicate that no more data will be read from this conduit. If unread data exists, an exception may be thrown.

Annotations
@Override
Exceptions
IOException:
if there was a problem
transferToback to summary
public long transferTo(final long position, final long count, final FileChannel target) throws IOException

Overrides org.xnio.conduits.AbstractStreamSourceConduit.transferTo.

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Doc from org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given file from this channel.

Parameters
position:long

the position within the file from which the transfer is to begin

count:long

the number of bytes to be transferred

target:FileChannel

the file to write to

Returns:long

the number of bytes (possibly 0) that were actually transferred

Exceptions
IOException:
if an I/O error occurs
transferToback to summary
public long transferTo(final long count, final ByteBuffer throughBuffer, final StreamSinkChannel target) throws IOException

Overrides org.xnio.conduits.AbstractStreamSourceConduit.transferTo.

Implements org.xnio.conduits.StreamSourceConduit.transferTo.

Doc from org.xnio.conduits.StreamSourceConduit.transferTo.

Transfers bytes into the given channel target. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may possibly be empty or may contain data. If this method returns a value less than count, then the remaining data in throughBuffer may contain data read from this channel which must be written to target to complete the operation.

Parameters
count:long

the number of bytes to be transferred

throughBuffer:ByteBuffer

the buffer to copy through.

target:StreamSinkChannel

the destination to write to

Returns:long

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
updateRemainingAllowedback to summary
private void updateRemainingAllowed(final int written) throws IOException
io.undertow.conduits back to summary

pack-priv Interface ChunkedStreamSourceConduit.BufferWrapper


Method Summary

Modifier and TypeMethod and Description
public PooledByteBuffer
public void

Method Detail

allocateback to summary
public PooledByteBuffer allocate()
pushBackback to summary
public void pushBack(PooledByteBuffer pooled)