Package org.omegazero.http.util
Interface HTTPMessageStream
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
HTTPClientStream
,HTTPServerStream
- All Known Implementing Classes:
AbstractHTTPClientStream
,AbstractHTTPMessageStream
,AbstractHTTPServerStream
A
HTTPMessageStream
represents a single HTTP request transaction.- Since:
- 1.4.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
close()
void
close
(MessageStreamClosedException.CloseReason closeReason) Terminates thisHTTPMessageStream
at any time, causing no further callbacks to be called and the transaction with the peer to end abnormally.Returns the request of thisHTTPMessageStream
.boolean
isClosed()
Returnstrue
if thisHTTPMessageStream
has closed, either forcibly (viaclose()
) or because the request transaction has completed.void
Sets a callback that is called when thisHTTPMessageStream
encounters a fatal error.void
onWritable
(Runnable onWritable) Sets a callback that is called when thisHTTPMessageStream
has cleared its write buffer after asendData
call returnedfalse
.void
setReceiveData
(boolean receiveData) Sets whether this stream should continue receiving data.
-
Method Details
-
getRequest
HTTPRequest getRequest()Returns the request of thisHTTPMessageStream
.- Returns:
- The request
-
setReceiveData
void setReceiveData(boolean receiveData) Sets whether this stream should continue receiving data.Disabling this will attempt to reduce or block incoming data passed to the data callback, if supported by the underlying protocol or transport.
- Parameters:
receiveData
-true
to continue receiving data
-
onWritable
Sets a callback that is called when thisHTTPMessageStream
has cleared its write buffer after asendData
call returnedfalse
.- Parameters:
onWritable
- The callback
-
onError
Sets a callback that is called when thisHTTPMessageStream
encounters a fatal error. This includes exceptions thrown by other callback handlers. Usually, thisHTTPMessageStream
is closed after this callback is called.- Parameters:
onError
- The callback
-
isClosed
boolean isClosed()Returnstrue
if thisHTTPMessageStream
has closed, either forcibly (viaclose()
) or because the request transaction has completed.- Returns:
true
if closed
-
close
default void close()Callsclose(MessageStreamClosedException.CloseReason)
with reasonMessageStreamClosedException.CloseReason.UNKNOWN
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
close
Terminates thisHTTPMessageStream
at any time, causing no further callbacks to be called and the transaction with the peer to end abnormally.An optional reason can be specified in the closeReason parameter, which may be passed on to the peer, if supported by the underlying protocol.
Calling this method after this
HTTPMessageStream
ended (successfully or abnormally) has no effects.- Parameters:
closeReason
- An optional reason this message stream is being closed
-