Class HTTP2Stream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Stream
,CyclicTimeouts.Expirable
,Attachable
,Callback
,Dumpable
,Invocable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An ordered list of frames belonging to the same stream.Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Callback
Callback.Completable, Callback.Completing, Callback.Nested
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.Task
Nested classes/interfaces inherited from interface org.eclipse.jetty.http2.api.Stream
Stream.Data, Stream.Listener
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking
-
Constructor Summary
ConstructorDescriptionHTTP2Stream
(HTTP2Session session, int streamId, MetaData.Request request, boolean local) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
commit()
void
Sends the given DATAframe
.void
demand()
Demands moreDATA
frames for this stream.dump()
void
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.boolean
void
Callback invoked when the operation fails.getAttribute
(String key) long
long
Returns the expiration time in nanoseconds.int
getId()
Get the stream unique id.long
Get theStream.Listener
associated with this stream.int
int
Get the session this stream is associated to.int
hashCode()
void
headers
(HeadersFrame frame, Callback callback) Sends the given HEADERSframe
.boolean
isClosed()
boolean
boolean
isLocal()
boolean
boolean
isOpen()
boolean
boolean
isReset()
boolean
void
notIdle()
protected void
notifyHeaders
(Stream stream, HeadersFrame frame) void
onClose()
protected void
onIdleTimeout
(TimeoutException timeout) void
process
(Stream.Data data) void
void
void
push
(PushPromiseFrame frame, Promise<Stream> promise, Stream.Listener listener) Sends the given PUSH_PROMISEframe
.readData()
Reads DATA frames from this stream, wrapping them in retainableStream.Data
objects.removeAttribute
(String key) void
reset
(ResetFrame frame, Callback callback) Sends the given RST_STREAMframe
.void
send
(HTTP2Stream.FrameList frameList, Callback callback) void
setAttachment
(Object attachment) Attaches the given object to this stream for later retrieval.void
setAttribute
(String key, Object value) void
setIdleTimeout
(long idleTimeout) void
setListener
(Stream.Listener listener) void
Callback invoked when the operation completes.toString()
boolean
updateClose
(boolean update, CloseState.Event event) int
updateRecvWindow
(int delta) int
updateSendWindow
(int delta) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.Callback
completeWith
-
Constructor Details
-
HTTP2Stream
-
-
Method Details
-
getId
public int getId()Description copied from interface:Stream
Get the stream unique id. -
equals
-
hashCode
public int hashCode() -
getAttachment
- Specified by:
getAttachment
in interfaceAttachable
- Returns:
- the object attached to this instance
- See Also:
-
setAttachment
Description copied from interface:Attachable
Attaches the given object to this stream for later retrieval.- Specified by:
setAttachment
in interfaceAttachable
- Parameters:
attachment
- the object to attach to this instance
-
isLocal
public boolean isLocal() -
getSession
Description copied from interface:Stream
Get the session this stream is associated to.- Specified by:
getSession
in interfaceStream
- Returns:
- the session this stream is associated to
-
headers
Description copied from interface:Stream
Sends the given HEADERS
frame
.Typically used to send an HTTP response or to send the HTTP response trailers.
-
send
-
push
Description copied from interface:Stream
Sends the given PUSH_PROMISE
frame
. -
data
Description copied from interface:Stream
Sends the given DATA
frame
. -
reset
Description copied from interface:Stream
Sends the given RST_STREAM
frame
. -
getAttribute
- Specified by:
getAttribute
in interfaceStream
- Parameters:
key
- the attribute key- Returns:
- an arbitrary object associated with the given key to this stream or null if no object can be found for the given key.
- See Also:
-
setAttribute
- Specified by:
setAttribute
in interfaceStream
- Parameters:
key
- the attribute keyvalue
- an arbitrary object to associate with the given key to this stream- See Also:
-
removeAttribute
- Specified by:
removeAttribute
in interfaceStream
- Parameters:
key
- the attribute key- Returns:
- the arbitrary object associated with the given key to this stream
- See Also:
-
isReset
public boolean isReset() -
isResetOrFailed
public boolean isResetOrFailed() -
isClosed
public boolean isClosed() -
isRemotelyClosed
public boolean isRemotelyClosed()- Specified by:
isRemotelyClosed
in interfaceStream
- Returns:
- whether the stream is closed remotely.
- See Also:
-
isLocallyClosed
public boolean isLocallyClosed() -
commit
public void commit() -
isCommitted
public boolean isCommitted() -
isOpen
public boolean isOpen() -
notIdle
public void notIdle() -
getExpireNanoTime
public long getExpireNanoTime()Description copied from interface:CyclicTimeouts.Expirable
Returns the expiration time in nanoseconds.
The value to return must be calculated taking into account the current nanoTime, for example:
expireNanoTime = NanoTime.now() + timeoutNanos
Returning
Long.MAX_VALUE
indicates that this entity does not expire.- Specified by:
getExpireNanoTime
in interfaceCyclicTimeouts.Expirable
- Returns:
- the expiration time in nanoseconds, or
Long.MAX_VALUE
if this entity does not expire
-
getIdleTimeout
public long getIdleTimeout()- Specified by:
getIdleTimeout
in interfaceStream
- Returns:
- the stream idle timeout
- See Also:
-
setIdleTimeout
public void setIdleTimeout(long idleTimeout) - Specified by:
setIdleTimeout
in interfaceStream
- Parameters:
idleTimeout
- the stream idle timeout- See Also:
-
onIdleTimeout
-
getListener
Description copied from interface:Stream
Get theStream.Listener
associated with this stream.- Specified by:
getListener
in interfaceStream
- Returns:
- the
Stream.Listener
associated with this stream
-
setListener
-
process
-
process
-
readData
Description copied from interface:Stream
Reads DATA frames from this stream, wrapping them in retainable
Stream.Data
objects.The returned
Stream.Data
object may benull
, indicating that the end of the read side of the stream has not yet been reached, which may happen in these cases:- not all the bytes have been received so far, for example the remote peer did not send them yet, or they are in-flight
- all the bytes have been received, but there is a trailer HEADERS frame to be received to indicate the end of the read side of the stream
When the returned
Stream.Data
object is notnull
, the flow control window has been enlarged by the DATA frame length; applications must call, either immediately or later (even asynchronously from a different thread)Retainable.release()
to notify the implementation that the bytes have been processed.Stream.Data
objects may be stored away for later, asynchronous, processing (for example, to process them only when all of them have been received).Once the returned
Stream.Data
object indicates that the end of the read side of the stream has been reached, further calls to this method will return aStream.Data
object with the same indication, although the instance may be different.- Specified by:
readData
in interfaceStream
- Returns:
- a
Stream.Data
object containing the DATA frame, or null if no DATA frame is available - See Also:
-
demand
public void demand()Description copied from interface:Stream
Demands more
DATA
frames for this stream.Calling this method causes
Stream.Listener.onDataAvailable(Stream)
to be invoked, possibly at a later time, when the stream has data to be read, but also when the stream has reached EOF.This method is idempotent: calling it when there already is an outstanding demand to invoke
Stream.Listener.onDataAvailable(Stream)
is a no-operation.The thread invoking this method may invoke directly
Stream.Listener.onDataAvailable(Stream)
, unless another thread that must invokeStream.Listener.onDataAvailable(Stream)
notices the outstanding demand first.It is always guaranteed that invoking this method from within
onDataAvailable(Stream)
will not cause aStackOverflowError
. -
processData
public void processData() -
getDataLength
public long getDataLength() -
updateClose
-
getSendWindow
public int getSendWindow() -
getRecvWindow
public int getRecvWindow() -
updateSendWindow
public int updateSendWindow(int delta) -
updateRecvWindow
public int updateRecvWindow(int delta) -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
onClose
public void onClose() -
succeeded
public void succeeded()Description copied from interface:Callback
Callback invoked when the operation completes.
-
failed
Description copied from interface:Callback
Callback invoked when the operation fails.
-
getInvocationType
- Specified by:
getInvocationType
in interfaceInvocable
- Returns:
- The InvocationType of this object
-
notifyHeaders
-
dump
-
dump
Description copied from interface:Dumpable
Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dump
in interfaceDumpable
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-
toString
-