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 voidclose()voidclose(MessageStreamClosedException.CloseReason closeReason) Terminates thisHTTPMessageStreamat any time, causing no further callbacks to be called and the transaction with the peer to end abnormally.Returns the request of thisHTTPMessageStream.booleanisClosed()Returnstrueif thisHTTPMessageStreamhas closed, either forcibly (viaclose()) or because the request transaction has completed.voidSets a callback that is called when thisHTTPMessageStreamencounters a fatal error.voidonWritable(Runnable onWritable) Sets a callback that is called when thisHTTPMessageStreamhas cleared its write buffer after asendDatacall returnedfalse.voidsetReceiveData(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-trueto continue receiving data
-
onWritable
Sets a callback that is called when thisHTTPMessageStreamhas cleared its write buffer after asendDatacall returnedfalse.- Parameters:
onWritable- The callback
-
onError
Sets a callback that is called when thisHTTPMessageStreamencounters a fatal error. This includes exceptions thrown by other callback handlers. Usually, thisHTTPMessageStreamis closed after this callback is called.- Parameters:
onError- The callback
-
isClosed
boolean isClosed()Returnstrueif thisHTTPMessageStreamhas closed, either forcibly (viaclose()) or because the request transaction has completed.- Returns:
trueif closed
-
close
default void close()Callsclose(MessageStreamClosedException.CloseReason)with reasonMessageStreamClosedException.CloseReason.UNKNOWN.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
close
Terminates thisHTTPMessageStreamat 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
HTTPMessageStreamended (successfully or abnormally) has no effects.- Parameters:
closeReason- An optional reason this message stream is being closed
-