Top Description Inners Fields Constructors Methods
io.undertow.protocols.http2

public Class Http2DataStreamSinkChannel

extends Http2StreamSinkChannel
implements Http2Stream
Class Inheritance
All Implemented Interfaces
io.undertow.protocols.http2.Http2Stream
Known Direct Subclasses
io.undertow.protocols.http2.Http2HeadersStreamSinkChannel, io.undertow.protocols.http2.Http2PushPromiseStreamSinkChannel
Imports
io.undertow.UndertowMessages, io.undertow.connector.PooledByteBuffer, io.undertow.server.protocol.framed.SendFrameHeader, io.undertow.util.HeaderMap, .ImmediatePooledByteBuffer, org.xnio.ChannelListener, .ChannelListeners, java.io.IOException, java.nio.ByteBuffer

Headers channel
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private volatile ChannelListener<Http2DataStreamSinkChannel>
private volatile boolean
private boolean
private final HpackEncoder
private boolean
private final int
private final HeaderMap
private Http2DataStreamSinkChannel.TrailersProducer

Constructor Summary

AccessConstructor and Description
pack-priv
Http2DataStreamSinkChannel(Http2Channel channel, int streamId, int frameType)

pack-priv
Http2DataStreamSinkChannel(Http2Channel channel, int streamId, HeaderMap headers, int frameType)

Method Summary

Modifier and TypeMethod and Description
protected void
channelForciblyClosed()

Overrides io.undertow.protocols.http2.Http2StreamSinkChannel.channelForciblyClosed.

Called when a channel has been forcibly closed, and data (frames) have already been written.

protected SendFrameHeader
private HpackEncoder.State
public boolean
public ChannelListener<Http2DataStreamSinkChannel>
public HeaderMap
public Http2DataStreamSinkChannel.TrailersProducer
private void
protected void
private boolean
protected boolean
public void
public void
public long
write(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
,
int
The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
length
)

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from a subsequence of the given buffers.

public long
write(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
)

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from the given buffers.

public int
write(ByteBuffer
The buffer from which bytes are to be retrieved
src
)

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

protected void
public long
writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
,
int
The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length
offset
,
int
The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset
length
)

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal.

Implements org.xnio.channels.StreamSinkChannel.writeFinal.

Writes some data to the channel, with the same semantics as write(java.nio.ByteBuffer[], int, int).

public long
writeFinal(ByteBuffer[]
The buffers from which bytes are to be retrieved
srcs
)

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal.

Implements org.xnio.channels.StreamSinkChannel.writeFinal.

Writes some data to the channel, with the same semantics as write(java.nio.ByteBuffer[]).

public int
Inherited from io.undertow.protocols.http2.Http2StreamSinkChannel:
allocateAllclearHeadercreateFrameHeadergenerateSendFrameHeadergetStreamIdgrabFlowControlBytesrstStreamupdateFlowControlWindow

Field Detail

completionListenerback to summary
private volatile ChannelListener<Http2DataStreamSinkChannel> completionListener
completionListenerFailureback to summary
private volatile boolean completionListenerFailure
completionListenerReadyback to summary
private boolean completionListenerReady
encoderback to summary
private final HpackEncoder encoder
firstback to summary
private boolean first
frameTypeback to summary
private final int frameType
headersback to summary
private final HeaderMap headers
trailersProducerback to summary
private Http2DataStreamSinkChannel.TrailersProducer trailersProducer

Constructor Detail

Http2DataStreamSinkChannelback to summary
pack-priv Http2DataStreamSinkChannel(Http2Channel channel, int streamId, int frameType)
Http2DataStreamSinkChannelback to summary
pack-priv Http2DataStreamSinkChannel(Http2Channel channel, int streamId, HeaderMap headers, int frameType)

Method Detail

channelForciblyClosedback to summary
protected void channelForciblyClosed() throws IOException

Overrides io.undertow.protocols.http2.Http2StreamSinkChannel.channelForciblyClosed.

Doc from io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.channelForciblyClosed.

Called when a channel has been forcibly closed, and data (frames) have already been written. The action this should take is protocol dependent, e.g. for SPDY a RST_STREAM should be sent, for websockets the channel should be closed. By default this will just close the underlying channel

Annotations
@Override
createFrameHeaderImplback to summary
protected SendFrameHeader createFrameHeaderImpl()

Implements abstract io.undertow.protocols.http2.Http2StreamSinkChannel.createFrameHeaderImpl.

Annotations
@Override
encodeContinuationFrameback to summary
private HpackEncoder.State encodeContinuationFrame(HeaderMap headers, PooledByteBuffer current)
flushback to summary
public boolean flush() throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.flush.

Implements org.xnio.channels.SuspendableWriteChannel.flush.

Doc from org.xnio.channels.SuspendableWriteChannel.flush.

Flush any waiting partial send or write. If there is no data to flush, or if the flush completed successfully, this method will return true. If there is data to flush which cannot be immediately written, this method will return false. If this method returns true after shutdownWrites() was called on this channel, the write listener will no longer be invoked on this channel. If this is case and additionally this is a write-only channel or the read side was previously shut down, then the channel will automatically be closed.

Returns:boolean

true if the message was flushed, or false if the result would block

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
getCompletionListenerback to summary
public ChannelListener<Http2DataStreamSinkChannel> getCompletionListener()
getHeadersback to summary
public HeaderMap getHeaders()
getTrailersProducerback to summary
public Http2DataStreamSinkChannel.TrailersProducer getTrailersProducer()
handleFailedChannelback to summary
private void handleFailedChannel()
handleFlushCompleteback to summary
protected void handleFlushComplete(boolean finalFrame)

Overrides io.undertow.protocols.http2.Http2StreamSinkChannel.handleFlushComplete.

Annotations
@Override
isContinueStatusback to summary
private boolean isContinueStatus()
isFlushRequiredOnEmptyBufferback to summary
protected boolean isFlushRequiredOnEmptyBuffer()

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.isFlushRequiredOnEmptyBuffer.

setCompletionListenerback to summary
public void setCompletionListener(ChannelListener<Http2DataStreamSinkChannel> completionListener)
setTrailersProducerback to summary
public void setTrailersProducer(Http2DataStreamSinkChannel.TrailersProducer trailersProducer)
writeback to summary
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Doc from java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from a subsequence of the given buffers.

An attempt is made to write up to r bytes to this channel, where r is the total number of bytes remaining in the specified subsequence of the given buffer array, that is,

srcs[offset].remaining() + srcs[offset+1].remaining() + ... + srcs[offset+length-1].remaining()
srcs[offset].remaining()
    + srcs[offset+1].remaining()
    + ... + srcs[offset+length-1].remaining()
at the moment that this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. Up to the first srcs[offset].remaining() bytes of this sequence are written from buffer srcs[offset], up to the next srcs[offset+1].remaining() bytes are written from buffer srcs[offset+1], and so forth, until the entire byte sequence is written. As many bytes as possible are written from each buffer, hence the final position of each updated buffer, except the last updated buffer, is guaranteed to be equal to that buffer's limit.

Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer.

This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

offset:int

The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length

length:int

The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset

Returns:long

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
writeback to summary
public long write(ByteBuffer[] srcs) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.GatheringByteChannel.write.

Doc from java.nio.channels.GatheringByteChannel.write.

Writes a sequence of bytes to this channel from the given buffers.

An invocation of this method of the form c.write(srcs) behaves in exactly the same manner as the invocation

c.write(srcs, 0, srcs.length);
c.write(srcs, 0, srcs.length);
Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

Returns:long

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
writeback to summary
public int write(ByteBuffer src) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write.

Implements java.nio.channels.WritableByteChannel.write.

Doc from java.nio.channels.WritableByteChannel.write.

Writes a sequence of bytes to this channel from the given buffer.

An attempt is made to write up to r bytes to the channel, where r is the number of bytes remaining in the buffer, that is, src.remaining(), at the moment this method is invoked.

Suppose that a byte sequence of length n is written, where 0 <= n <= r. This byte sequence will be transferred from the buffer starting at index p, where p is the buffer's position at the moment this method is invoked; the index of the last byte written will be p + n - 1. Upon return the buffer's position will be equal to p + n; its limit will not have changed.

Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer.

This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.

Parameters
src:ByteBuffer

The buffer from which bytes are to be retrieved

Returns:int

The number of bytes written, possibly zero

Annotations
@Override
Exceptions
IOException:
If some other I/O error occurs
writeBeforeHeaderBlockback to summary
protected void writeBeforeHeaderBlock(ByteBuffer buffer)
writeFinalback to summary
public long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal.

Implements org.xnio.channels.StreamSinkChannel.writeFinal.

Doc from org.xnio.channels.StreamSinkChannel.writeFinal.

Writes some data to the channel, with the same semantics as write(java.nio.ByteBuffer[], int, int). If all the data is written out then the channel will have its writes shutdown. If an exception is thrown the caller is still responsible for closing the channel.

Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

offset:int

The offset within the buffer array of the first buffer from which bytes are to be retrieved; must be non-negative and no larger than srcs.length

length:int

The maximum number of buffers to be accessed; must be non-negative and no larger than srcs.length - offset

Returns:long

The amount of data that was actually written

Annotations
@Override
writeFinalback to summary
public long writeFinal(ByteBuffer[] srcs) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal.

Implements org.xnio.channels.StreamSinkChannel.writeFinal.

Doc from org.xnio.channels.StreamSinkChannel.writeFinal.

Writes some data to the channel, with the same semantics as write(java.nio.ByteBuffer[]). If all the data is written out then the channel will have its writes shutdown. If an exception is thrown the caller is still responsible for closing the channel.

Parameters
srcs:ByteBuffer[]

The buffers from which bytes are to be retrieved

Returns:long

The amount of data that was actually written

Annotations
@Override
writeFinalback to summary
public int writeFinal(ByteBuffer src) throws IOException

Overrides io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.writeFinal.

Implements org.xnio.channels.StreamSinkChannel.writeFinal.

Doc from org.xnio.channels.StreamSinkChannel.writeFinal.

Writes some data to the channel, with the same semantics as write(java.nio.ByteBuffer). If all the data is written out then the channel will have its writes shutdown. Semantically this method is equivalent to: int rem = src.remaining(); int written = channel.write(src); if(written == rem) { channel.shutdownWrites() } If an exception is thrown the caller is still responsible for closing the channel.

Parameters
src:ByteBuffer

The data to write

Returns:int

The amount of data that was actually written.

Annotations
@Override
io.undertow.protocols.http2 back to summary

public Interface Http2DataStreamSinkChannel.TrailersProducer


Method Summary

Modifier and TypeMethod and Description
public HeaderMap

Method Detail

getTrailersback to summary
public HeaderMap getTrailers()