Class HTTP3Stream
- All Implemented Interfaces:
Stream
,CyclicTimeouts.Expirable
,Attachable
- Direct Known Subclasses:
HTTP3StreamClient
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static enum
Defines the state of the stream for received frames,Nested classes/interfaces inherited from interface org.eclipse.jetty.http3.api.Stream
Stream.Client, Stream.Data, Stream.Server
-
Constructor Summary
ConstructorDescriptionHTTP3Stream
(HTTP3Session session, QuicStreamEndPoint endPoint, boolean local) -
Method Summary
Modifier and TypeMethodDescriptionSends the given DATA frame containing some or all the bytes of the request content or of the response content.void
demand()
Demands moreDATA
frames for this stream.long
Returns the expiration time in nanoseconds.long
getId()
Get the stream id.long
Get the session this stream is associated to.boolean
protected boolean
boolean
isClosed()
boolean
isLocal()
protected void
notIdle()
protected abstract void
protected abstract void
notifyFailure
(long error, Throwable failure) protected abstract void
notifyIdleTimeout
(TimeoutException timeout, Promise<Boolean> promise) protected abstract void
notifyTrailer
(HeadersFrame frame) void
onData
(Stream.Data data) void
void
void
onHeaders
(HeadersFrame frame) void
onTrailer
(HeadersFrame frame) readData()
Reads request content bytes or response content bytes.void
Abruptly terminates this stream with the given error.void
setAttachment
(Object attachment) Attaches the given object to this stream for later retrieval.void
setIdleTimeout
(long idleTimeout) toString()
trailer
(HeadersFrame frame) Sends the given HEADERS frame containing the trailer headers.void
updateClose
(boolean update, boolean local) protected boolean
validateAndUpdate
(EnumSet<HTTP3Stream.FrameState> allowed, HTTP3Stream.FrameState target) protected CompletableFuture<Stream>
writeFrame
(Frame frame)
-
Constructor Details
-
HTTP3Stream
-
-
Method Details
-
getEndPoint
-
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
-
getId
public long getId()Description copied from interface:Stream
Get the stream id. -
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
-
isLocal
public boolean isLocal() -
getIdleTimeout
public long getIdleTimeout() -
setIdleTimeout
public void setIdleTimeout(long idleTimeout) -
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
-
notIdle
protected void notIdle() -
data
Description copied from interface:Stream
Sends the given DATA frame containing some or all the bytes of the request content or of the response content.
- Specified by:
data
in interfaceStream
- Parameters:
frame
- the DATA frame containing some or all the bytes of the request or of the response.- Returns:
- the
CompletableFuture
that gets notified when the frame has been sent
-
write
-
readData
Description copied from interface:Stream
Reads request content bytes or response content bytes.
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
, applications must call, either immediately or later (possibly asynchronously)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).- Specified by:
readData
in interfaceStream
- Returns:
- a
Stream.Data
object containing the request bytes or the response bytes, or null if no bytes are available - See Also:
-
demand
public void demand()Description copied from interface:Stream
Demands more
DATA
frames for this stream.Calling this method causes
Stream.Client.Listener.onDataAvailable(Stream.Client)
on the client, orStream.Server.Listener.onDataAvailable(Stream.Server)
on the server, 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
onDataAvailable(Stream)
is a no-operation.The thread invoking this method may invoke directly
onDataAvailable(Stream)
, unless another thread that must invokeonDataAvailable(Stream)
notices the outstanding demand first.It is always guaranteed that invoking this method from within
onDataAvailable(Stream)
will not cause aStackOverflowError
. -
trailer
Description copied from interface:Stream
Sends the given HEADERS frame containing the trailer headers.
- Specified by:
trailer
in interfaceStream
- Parameters:
frame
- the HEADERS frame containing the trailer headers- Returns:
- the
CompletableFuture
that gets notified when the frame has been sent
-
hasDemand
public boolean hasDemand() -
onHeaders
-
hasDemandOrStall
protected boolean hasDemandOrStall() -
onData
-
onData
-
notifyDataAvailable
protected abstract void notifyDataAvailable() -
onTrailer
-
notifyTrailer
-
notifyIdleTimeout
-
onFailure
-
notifyFailure
-
validateAndUpdate
protected boolean validateAndUpdate(EnumSet<HTTP3Stream.FrameState> allowed, HTTP3Stream.FrameState target) -
writeFrame
-
isClosed
public boolean isClosed() -
updateClose
public void updateClose(boolean update, boolean local) -
reset
Description copied from interface:Stream
Abruptly terminates this stream with the given error.
-
toString
-