public class InputBuffer
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
trailers
Trailer headers, if any.
|
| Constructor and Description |
|---|
InputBuffer() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
append(HttpContent httpContent)
|
boolean |
areTrailersAvailable() |
int |
available() |
int |
availableChar() |
protected HttpContent |
blockingRead()
Read next chunk of data in this thread, block if needed.
|
void |
close() |
void |
fillFully(int length)
/**
Fill the buffer (blocking) up to the requested length.
|
protected void |
finished()
When invoked, this method will call
ReadHandler.onAllDataRead()
on the current ReadHandler (if any). |
Buffer |
getBuffer()
Returns the duplicate of the underlying
Buffer used to buffer
incoming request data. |
ReadHandler |
getReadHandler() |
protected java.util.concurrent.Executor |
getThreadPool() |
java.util.Map<java.lang.String,java.lang.String> |
getTrailers() |
void |
initialize(HttpHeader httpHeader,
FilterChainContext ctx)
Per-request initialization required for the InputBuffer to function
properly.
|
void |
initiateAsyncronousDataReceiving()
Initiates asynchronous data receiving.
|
boolean |
isAsyncEnabled()
Deprecated.
will always return true
|
boolean |
isClosed() |
boolean |
isFinished() |
void |
mark(int readAheadLimit)
Supported with binary and character data.
|
boolean |
markSupported()
Only supported with binary data.
|
void |
notifyAvailable(ReadHandler handler)
Installs a
ReadHandler that will be notified when any data
becomes available to read without blocking. |
void |
notifyAvailable(ReadHandler handler,
int size)
Installs a
ReadHandler that will be notified when the specified
amount of data is available to be read without blocking. |
void |
processingChars()
This method should be called if the InputBuffer is being used in conjunction
with a
Reader implementation. |
int |
read(byte[] b,
int off,
int len) |
int |
read(char[] cbuf,
int off,
int len) |
int |
read(java.nio.CharBuffer target) |
Buffer |
readBuffer() |
Buffer |
readBuffer(int size) |
int |
readByte()
This method always blocks.
|
int |
readChar() |
boolean |
ready() |
int |
readyData()
Depending on the InputBuffer mode, method will return either
number of available bytes or characters ready to be read without blocking.
|
void |
recycle()
Recycle this
InputBuffer for reuse. |
void |
replayPayload(Buffer buffer) |
void |
reset()
Only supported with binary data.
|
void |
setAsyncEnabled(boolean asyncEnabled)
Deprecated.
InputBuffer always supports async mode
|
void |
setDefaultEncoding(java.lang.String encoding)
Set the default character encoding for this InputBuffer, which
would be applied if no encoding was explicitly set on HTTP
HttpRequestPacket and character decoding
wasn't started yet. |
long |
skip(long n)
Skips the specified number of bytes/characters.
|
long |
skip(long n,
boolean block)
Deprecated.
pls. use
skip(long), the block parameter will be ignored |
void |
terminate()
Invoke
ReadHandler.onError(Throwable) (assuming a ReadHandler
is available) } passing a {#link CancellationException}
if the current Connection is open, or a {#link EOFException} if
the connection was unexpectedly closed. |
protected void |
updateInputContentBuffer(Buffer buffer) |
protected java.util.Map<java.lang.String,java.lang.String> trailers
public void initialize(HttpHeader httpHeader, FilterChainContext ctx)
Per-request initialization required for the InputBuffer to function properly.
httpHeader - the header from which input will be obtained.ctx - the FilterChainContext for the chain processing this requestpublic void setDefaultEncoding(java.lang.String encoding)
HttpRequestPacket and character decoding
wasn't started yet.public void recycle()
Recycle this InputBuffer for reuse.
public void processingChars()
This method should be called if the InputBuffer is being used in conjunction
with a Reader implementation. If this method is not called,
any character-based methods called on this InputBuffer will
throw a IllegalStateException.
public int readByte()
throws java.io.IOException
java.io.IOExceptionInputStream.read()public int read(byte[] b,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionInputStream.read(byte[], int, int)public int readyData()
public int available()
InputStream.available()public Buffer getBuffer()
Buffer used to buffer
incoming request data. The content of the returned buffer will be that
of the underlying buffer. Changes to returned buffer's content will be
visible in the underlying buffer, and vice versa; the two buffers'
position, limit, and mark values will be independent.Buffer used to buffer incoming request data.public Buffer readBuffer()
Buffer used to buffer incoming request
data. Unlike getBuffer(), this method detaches the returned
Buffer, so user code becomes responsible for handling
the Buffer.public Buffer readBuffer(int size)
public ReadHandler getReadHandler()
ReadHandler current in use, if any.public int read(java.nio.CharBuffer target)
throws java.io.IOException
java.io.IOExceptionReader.read(java.nio.CharBuffer)public int readChar()
throws java.io.IOException
java.io.IOExceptionReader.read()public int read(char[] cbuf,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionReader.read(char[], int, int)public boolean ready()
Reader.ready()public void fillFully(int length)
throws java.io.IOException
length - how much content should attempt to buffer,
-1 means buffer entire request.java.io.IOException - if an error occurs reading data from the wire.public int availableChar()
public void mark(int readAheadLimit)
Supported with binary and character data.
InputStream.mark(int),
Reader.mark(int)public boolean markSupported()
Only supported with binary data.
InputStream.markSupported()public void reset()
throws java.io.IOException
Only supported with binary data.
java.io.IOExceptionInputStream.reset()public void close()
throws java.io.IOException
java.io.IOExceptionCloseable.close()public long skip(long n,
boolean block)
throws java.io.IOException
skip(long), the block parameter will be ignoredjava.io.IOExceptionInputStream.skip(long),
Reader.skip(long)public long skip(long n)
throws java.io.IOException
java.io.IOExceptionInputStream.skip(long),
Reader.skip(long)public java.util.Map<java.lang.String,java.lang.String> getTrailers()
public boolean areTrailersAvailable()
protected void finished()
ReadHandler.onAllDataRead()
on the current ReadHandler (if any).
This method shouldn't be invoked by developers directly.public void replayPayload(Buffer buffer)
public boolean isFinished()
true if all request data has been read, otherwise
returns false.public boolean isClosed()
true if this InputBuffer is closed, otherwise
returns false.public void notifyAvailable(ReadHandler handler)
ReadHandler that will be notified when any data
becomes available to read without blocking.handler - the ReadHandler to invoke.java.lang.IllegalArgumentException - if handler is null.java.lang.IllegalStateException - if an attempt is made to register a handler
before an existing registered handler has been invoked or if all request
data has already been read.public void notifyAvailable(ReadHandler handler, int size)
ReadHandler that will be notified when the specified
amount of data is available to be read without blocking.handler - the ReadHandler to invoke.size - the minimum number of bytes that must be available before
the ReadHandler is notified.java.lang.IllegalArgumentException - if handler is null,
or if size is less or equal to zero.java.lang.IllegalStateException - if an attempt is made to register a handler
before an existing registered handler has been invoked.public boolean append(HttpContent httpContent) throws java.io.IOException
httpContent - the HttpContent to appendtrue if ReadHandler
callback was invoked, otherwise returns false.java.io.IOException - if an error occurs appending the Bufferpublic boolean isAsyncEnabled()
public void setAsyncEnabled(boolean asyncEnabled)
InputBuffer.asyncEnabled - true if this InputBuffer
is to be used to process asynchronous request data.public void terminate()
Invoke ReadHandler.onError(Throwable) (assuming a ReadHandler
is available) } passing a {#link CancellationException}
if the current Connection is open, or a {#link EOFException} if
the connection was unexpectedly closed.
public void initiateAsyncronousDataReceiving()
protected java.util.concurrent.Executor getThreadPool()
Executor, which will be used for notifying user
registered ReadHandler.protected HttpContent blockingRead() throws java.io.IOException
HttpContentjava.io.IOException - if an error occurs reading data from the wire.protected void updateInputContentBuffer(Buffer buffer)
Copyright © 2018 Oracle Corporation. All Rights Reserved.