Class HTTP3Stream
- All Implemented Interfaces:
Stream, CyclicTimeouts.Expirable, Attachable
- Direct Known Subclasses:
HTTP3StreamClient
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumDefines the state of the stream for received frames,Nested classes/interfaces inherited from interface Stream
Stream.Client, Stream.Data, Stream.Server -
Constructor Summary
ConstructorsConstructorDescriptionHTTP3Stream(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.voiddemand()Demands moreDATAframes for this stream.longReturns the expiration time in nanoseconds.longgetId()Get the stream id.longGet the session this stream is associated to.booleanprotected booleanbooleanisClosed()booleanisLocal()protected voidnotIdle()protected abstract voidnotifyDataAvailable(boolean immediate) abstract voidnotifyFailure(long error, Throwable failure) protected abstract voidnotifyIdleTimeout(TimeoutException timeout, Promise<Boolean> promise) protected abstract voidnotifyTrailer(HeadersFrame frame) voidonData(Stream.Data data) voidvoidvoidonHeaders(HeadersFrame frame) voidonTrailer(HeadersFrame frame) readData()Reads request content bytes or response content bytes.voidAbruptly terminates this stream with the given error.voidsetAttachment(Object attachment) Attaches the given object for later retrieval.voidsetIdleTimeout(long idleTimeout) toString()trailer(HeadersFrame frame) Sends the given HEADERS frame containing the trailer headers.voidupdateClose(boolean update, boolean local) protected booleanvalidateAndUpdate(EnumSet<HTTP3Stream.FrameState> allowed, HTTP3Stream.FrameState target) protected CompletableFuture<Stream> writeFrame(Frame frame)
-
Constructor Details
-
HTTP3Stream
-
-
Method Details
-
getEndPoint
-
getAttachment
- Specified by:
getAttachmentin interfaceAttachable- Returns:
- the object attached to this instance
- See Also:
-
setAttachment
Description copied from interface:AttachableAttaches the given object for later retrieval.- Specified by:
setAttachmentin interfaceAttachable- Parameters:
attachment- the object to attach
-
getId
-
getSession
Description copied from interface:StreamGet the session this stream is associated to.- Specified by:
getSessionin 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.ExpirableReturns the expiration time in nanoseconds.
The value to return must be calculated taking into account the current nanoTime, for example:
expireNanoTime = NanoTime.now() + timeoutNanosReturning
Long.MAX_VALUEindicates that this entity does not expire.- Specified by:
getExpireNanoTimein interfaceCyclicTimeouts.Expirable- Returns:
- the expiration time in nanoseconds, or
Long.MAX_VALUEif this entity does not expire
-
notIdle
protected void notIdle() -
data
Description copied from interface:StreamSends the given DATA frame containing some or all the bytes of the request content or of the response content.
- Specified by:
datain interfaceStream- Parameters:
frame- the DATA frame containing some or all the bytes of the request or of the response.- Returns:
- the
CompletableFuturethat gets notified when the frame has been sent
-
write
-
readData
Description copied from interface:StreamReads request content bytes or response content bytes.
The returned
Stream.Dataobject 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.Dataobject is notnull, applications must call, either immediately or later (possibly asynchronously)Retainable.release()to notify the implementation that the bytes have been processed.Stream.Dataobjects may be stored away for later, asynchronous, processing (for example, to process them only when all of them have been received).- Specified by:
readDatain interfaceStream- Returns:
- a
Stream.Dataobject 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:StreamDemands more
DATAframes for this stream.Calling this method causes
Stream.Client.Listener.onDataAvailable(Stream.Client, boolean)on the client, orStream.Server.Listener.onDataAvailable(Stream.Server, boolean)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:StreamSends the given HEADERS frame containing the trailer headers.
- Specified by:
trailerin interfaceStream- Parameters:
frame- the HEADERS frame containing the trailer headers- Returns:
- the
CompletableFuturethat gets notified when the frame has been sent
-
hasDemand
public boolean hasDemand() -
onHeaders
-
hasDemandOrStall
protected boolean hasDemandOrStall() -
onData
-
onData
-
notifyDataAvailable
protected abstract void notifyDataAvailable(boolean immediate) -
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
-
toString
-