Top Fields Constructors Methods
io.undertow.client.http

pack-priv final Class HttpRequestConduit

extends AbstractStreamSinkConduit<StreamSinkConduit>
Class Inheritance
Imports
io.undertow.client.ClientRequest, io.undertow.server.TruncatedResponseException, io.undertow.util.HeaderMap, .HttpString, org.jboss.logging.Logger, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, org.xnio.XnioWorker, org.xnio.channels.StreamSourceChannel, org.xnio.conduits.AbstractStreamSinkConduit, .Conduits, .StreamSinkConduit, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .FileChannel, java.util.Iterator, java.util.concurrent.atomic.AtomicIntegerFieldUpdater

Authors
David M. Lloyd, Emanuel Muckenhuber

Field Summary

Modifier and TypeField and Description
private int
private static final int
private static final int
private HttpString
private static final Logger
private static final int
private Iterator<HttpString>
private final ByteBufferPool
private PooledByteBuffer
private final ClientRequest
private volatile int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final AtomicIntegerFieldUpdater<HttpRequestConduit>
private String
private Iterator<String>

Constructor Summary

AccessConstructor and Description
pack-priv
HttpRequestConduit(final StreamSinkConduit next, final ByteBufferPool pool, final ClientRequest request)

Method Summary

Modifier and TypeMethod and Description
private int
doProcessWrite(int state, final ByteBuffer userData)

Handles writing out the header data.

public boolean
flush()

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

public void
public XnioWorker
getWorker()

Overrides org.xnio.conduits.AbstractConduit.getWorker.

Implements org.xnio.conduits.Conduit.getWorker.

Get the XNIO worker associated with this conduit.

private int
processWrite(int state, final ByteBuffer userData)

Handles writing out the header data.

public void
public long
transferFrom(final FileChannel
the file to read from
src
,
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
)

Overrides org.xnio.conduits.AbstractStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfer bytes into this conduit from the given file.

public long
transferFrom(final StreamSourceChannel
the source to read from
source
,
final long
the number of bytes to be transferred
count
,
final ByteBuffer
the buffer to copy through.
throughBuffer
)

Overrides org.xnio.conduits.AbstractStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfers bytes from the given channel source.

public void
truncateWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.truncateWrites.

Implements org.xnio.conduits.SinkConduit.truncateWrites.

Terminate writes and discard any outstanding write data.

public int
write(final ByteBuffer
the buffer containing data to write
src
)

Overrides org.xnio.conduits.AbstractStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

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

public long
write(final ByteBuffer[] srcs)

public long
write(final ByteBuffer[]
the buffers containing data to write
srcs
,
final int
the offset into the buffer array
offset
,
final int
the number of buffers to write
length
)

Overrides org.xnio.conduits.AbstractStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

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

public int
writeFinal(ByteBuffer
The data to write
src
)

Overrides org.xnio.conduits.AbstractStreamSinkConduit.writeFinal.

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

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

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 org.xnio.conduits.AbstractStreamSinkConduit.writeFinal.

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

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

Field Detail

charIndexback to summary
private int charIndex
FLAG_SHUTDOWNback to summary
private static final int FLAG_SHUTDOWN
FLAG_WRITINGback to summary
private static final int FLAG_WRITING
headerNameback to summary
private HttpString headerName
logback to summary
private static final Logger log
MASK_STATEback to summary
private static final int MASK_STATE
nameIteratorback to summary
private Iterator<HttpString> nameIterator
poolback to summary
private final ByteBufferPool pool
pooledBufferback to summary
private PooledByteBuffer pooledBuffer
requestback to summary
private final ClientRequest request
stateback to summary
private volatile int state
STATE_BODYback to summary
private static final int STATE_BODY
STATE_BUF_FLUSHback to summary
private static final int STATE_BUF_FLUSH
STATE_HDR_Dback to summary
private static final int STATE_HDR_D
STATE_HDR_DSback to summary
private static final int STATE_HDR_DS
STATE_HDR_EOL_CRback to summary
private static final int STATE_HDR_EOL_CR
STATE_HDR_EOL_LFback to summary
private static final int STATE_HDR_EOL_LF
STATE_HDR_FINAL_CRback to summary
private static final int STATE_HDR_FINAL_CR
STATE_HDR_FINAL_LFback to summary
private static final int STATE_HDR_FINAL_LF
STATE_HDR_NAMEback to summary
private static final int STATE_HDR_NAME
STATE_HDR_VALback to summary
private static final int STATE_HDR_VAL
STATE_STARTback to summary
private static final int STATE_START
STATE_URLback to summary
private static final int STATE_URL
stateUpdaterback to summary
private static final AtomicIntegerFieldUpdater<HttpRequestConduit> stateUpdater
stringback to summary
private String string
valueIteratorback to summary
private Iterator<String> valueIterator

Constructor Detail

HttpRequestConduitback to summary
pack-priv HttpRequestConduit(final StreamSinkConduit next, final ByteBufferPool pool, final ClientRequest request)

Method Detail

doProcessWriteback to summary
private int doProcessWrite(int state, final ByteBuffer userData) throws IOException

Handles writing out the header data. It can also take a byte buffer of user data, to enable both user data and headers to be written out in a single operation, which has a noticeable performance impact. It is up to the caller to note the current position of this buffer before and after they call this method, and use this to figure out how many bytes (if any) have been written.

flushback to summary
public boolean flush() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Doc from org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

Returns:boolean

true if everything is flushed, false otherwise

Exceptions
IOException:
if flush fails
freeBuffersback to summary
public void freeBuffers()
getWorkerback to summary
public XnioWorker getWorker()

Overrides org.xnio.conduits.AbstractConduit.getWorker.

Implements org.xnio.conduits.Conduit.getWorker.

Doc from org.xnio.conduits.Conduit.getWorker.

Get the XNIO worker associated with this conduit.

Returns:XnioWorker

the XNIO worker associated with this conduit

processWriteback to summary
private int processWrite(int state, final ByteBuffer userData) throws IOException

Handles writing out the header data. It can also take a byte buffer of user data, to enable both user data and headers to be written out in a single operation, which has a noticeable performance impact. It is up to the caller to note the current position of this buffer before and after they call this method, and use this to figure out how many bytes (if any) have been written.

terminateWritesback to summary
public void terminateWrites() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.terminateWrites.

Implements org.xnio.conduits.SinkConduit.terminateWrites.

Doc from org.xnio.conduits.SinkConduit.terminateWrites.

Signal that no more write data is forthcoming. The conduit must be flush()ed before it is considered to be shut down.

transferFromback to summary
public long transferFrom(final FileChannel src, final long position, final long count) throws IOException

Overrides org.xnio.conduits.AbstractStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Doc from org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfer bytes into this conduit from the given file.

Parameters
src:FileChannel

the file to read from

position:long

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

count:long

the number of bytes to be transferred

Returns:long

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

Exceptions
IOException:
if an I/O error occurs
transferFromback to summary
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException

Overrides org.xnio.conduits.AbstractStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Doc from org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfers bytes from the given channel source. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may 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 source which must be written to this channel to complete the operation.

Parameters
source:StreamSourceChannel

the source to read from

count:long

the number of bytes to be transferred

throughBuffer:ByteBuffer

the buffer to copy through.

Returns:long

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

Exceptions
IOException:
if an I/O error occurs
truncateWritesback to summary
public void truncateWrites() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.truncateWrites.

Implements org.xnio.conduits.SinkConduit.truncateWrites.

Doc from org.xnio.conduits.SinkConduit.truncateWrites.

Terminate writes and discard any outstanding write data. The conduit is terminated and flushed regardless of the outcome of this method.

Exceptions
IOException:
if channel termination failed for some reason
writeback to summary
public int write(final ByteBuffer src) throws IOException

Overrides org.xnio.conduits.AbstractStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Doc from org.xnio.conduits.StreamSinkConduit.write.

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

Parameters
src:ByteBuffer

the buffer containing data to write

Returns:int

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
writeback to summary
public long write(final ByteBuffer[] srcs) throws IOException
writeback to summary
public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException

Overrides org.xnio.conduits.AbstractStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Doc from org.xnio.conduits.StreamSinkConduit.write.

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

Parameters
srcs:ByteBuffer[]

the buffers containing data to write

offset:int

the offset into the buffer array

length:int

the number of buffers to write

Returns:long

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
writeFinalback to summary
public int writeFinal(ByteBuffer src) throws IOException

Overrides org.xnio.conduits.AbstractStreamSinkConduit.writeFinal.

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

Doc from org.xnio.conduits.StreamSinkConduit.writeFinal.

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer). If all the data is written out then the conduit will have its writes terminated. Semantically this method is equivalent to: int rem = src.remaining(); int written = conduit.write(src); if(written == rem) { conduit.terminateWrites() }

Parameters
src:ByteBuffer

The data to write

Returns:int

The amount of data that was actually written.

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

Overrides org.xnio.conduits.AbstractStreamSinkConduit.writeFinal.

Implements org.xnio.conduits.StreamSinkConduit.writeFinal.

Doc from org.xnio.conduits.StreamSinkConduit.writeFinal.

Writes some data to the conduit, with the same semantics as write(java.nio.ByteBuffer[], int, int). If all the data is written out then the conduit will have its writes terminated.

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