Package org.apache.catalina.connector
Class CoyoteInputStream
java.lang.Object
java.io.InputStream
javax.servlet.ServletInputStream
org.apache.catalina.connector.CoyoteInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
This class handles reading bytes.
- Author:
- Remy Maucherat
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
protected Object
clone()
Prevent cloning the facade.void
close()
Close the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.boolean
Has the end of this InputStream been reached?boolean
isReady()
Can data be read from this InputStream without blocking?int
read()
int
read
(byte[] b) int
read
(byte[] b, int off, int len) int
read
(ByteBuffer b) Transfers bytes from the buffer to the specified ByteBuffer.void
setReadListener
(ReadListener listener) Sets theReadListener
for thisServletInputStream
and thereby switches to non-blocking IO.Methods inherited from class javax.servlet.ServletInputStream
readLine
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Field Details
-
sm
-
ib
-
-
Constructor Details
-
CoyoteInputStream
-
-
Method Details
-
clone
Prevent cloning the facade.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
Transfers bytes from the buffer to the specified ByteBuffer. After the operation the position of the ByteBuffer will be returned to the one before the operation, the limit will be the position incremented by the number of the transferred bytes.- Parameters:
b
- the ByteBuffer into which bytes are to be written.- Returns:
- an integer specifying the actual number of bytes read, or -1 if the end of the stream is reached
- Throws:
IOException
- if an input or output exception has occurred
-
close
Close the stream Since we re-cycle, we can't allow the call to super.close() which would permanently disable us.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
isFinished
public boolean isFinished()Description copied from class:javax.servlet.ServletInputStream
Has the end of this InputStream been reached?- Specified by:
isFinished
in classServletInputStream
- Returns:
true
if all the data has been read from the stream, elsefalse
-
isReady
public boolean isReady()Description copied from class:javax.servlet.ServletInputStream
Can data be read from this InputStream without blocking? Returns If this method is called and returns false, the container will invokeReadListener.onDataAvailable()
when data is available.- Specified by:
isReady
in classServletInputStream
- Returns:
true
if data can be read without blocking, elsefalse
-
setReadListener
Description copied from class:javax.servlet.ServletInputStream
Sets theReadListener
for thisServletInputStream
and thereby switches to non-blocking IO. It is only valid to switch to non-blocking IO within async processing or HTTP upgrade processing.- Specified by:
setReadListener
in classServletInputStream
- Parameters:
listener
- The non-blocking IO read listener
-