- java.lang.Object
-
- java.io.InputStream
-
- jakarta.servlet.ServletInputStream
-
- org.eclipse.jetty.server.HttpInput
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Runnable
public class HttpInput extends jakarta.servlet.ServletInputStream implements java.lang.Runnable
While this class is-a Runnable, it should never be dispatched in it's own thread. It is a runnable only so that the calling thread can use
ContextHandler.handle(Runnable)
to setup classloaders etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpInput.Content
A content represents the production of aHttpChannel
returned byHttpChannel.produceContent()
.static class
HttpInput.EofContent
EOF special content.static class
HttpInput.ErrorContent
Error special content.static interface
HttpInput.Interceptor
static class
HttpInput.SpecialContent
Abstract class that implements the standard special content behavior.static class
HttpInput.WrappingContent
Simple non-special content wrapper allow overriding the EOF flag.
-
Constructor Summary
Constructors Constructor Description HttpInput(HttpChannelState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInterceptor(HttpInput.Interceptor interceptor)
Set theHttpInput.Interceptor
, chaining it to the existing one if anHttpInput.Interceptor
is already set.int
available()
boolean
consumeAll()
long
getContentConsumed()
long
getContentReceived()
HttpInput.Interceptor
getInterceptor()
boolean
hasContent()
Check if this HttpInput instance has content stored internally, without fetching/parsing anything from the underlying channel.boolean
isAsync()
boolean
isError()
boolean
isFinished()
boolean
isReady()
boolean
onContentProducible()
int
read()
int
read(byte[] b, int off, int len)
void
recycle()
void
reopen()
void
run()
void
setInterceptor(HttpInput.Interceptor interceptor)
Set the interceptor.void
setReadListener(jakarta.servlet.ReadListener readListener)
java.lang.String
toString()
-
-
-
Constructor Detail
-
HttpInput
public HttpInput(HttpChannelState state)
-
-
Method Detail
-
recycle
public void recycle()
-
reopen
public void reopen()
-
getInterceptor
public HttpInput.Interceptor getInterceptor()
- Returns:
- The current Interceptor, or null if none set
-
setInterceptor
public void setInterceptor(HttpInput.Interceptor interceptor)
Set the interceptor.- Parameters:
interceptor
- The interceptor to use.
-
addInterceptor
public void addInterceptor(HttpInput.Interceptor interceptor)
Set theHttpInput.Interceptor
, chaining it to the existing one if anHttpInput.Interceptor
is already set.- Parameters:
interceptor
- the nextHttpInput.Interceptor
in a chain
-
getContentConsumed
public long getContentConsumed()
-
getContentReceived
public long getContentReceived()
-
consumeAll
public boolean consumeAll()
-
isError
public boolean isError()
-
isAsync
public boolean isAsync()
-
isFinished
public boolean isFinished()
- Specified by:
isFinished
in classjakarta.servlet.ServletInputStream
-
isReady
public boolean isReady()
- Specified by:
isReady
in classjakarta.servlet.ServletInputStream
-
setReadListener
public void setReadListener(jakarta.servlet.ReadListener readListener)
- Specified by:
setReadListener
in classjakarta.servlet.ServletInputStream
-
onContentProducible
public boolean onContentProducible()
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
hasContent
public boolean hasContent()
Check if this HttpInput instance has content stored internally, without fetching/parsing anything from the underlying channel.- Returns:
- true if the input contains content, false otherwise.
-
available
public int available()
- Overrides:
available
in classjava.io.InputStream
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-