Package org.omegazero.http.util
Class AbstractHTTPMessageStream
java.lang.Object
org.omegazero.http.util.AbstractHTTPMessageStream
- All Implemented Interfaces:
Closeable,AutoCloseable,HTTPMessageStream
- Direct Known Subclasses:
AbstractHTTPClientStream,AbstractHTTPServerStream
A
HTTPMessageStream with several basic methods implemented.- Since:
- 1.4.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Runnableprotected final HTTPRequest -
Constructor Summary
ConstructorsConstructorDescriptionAbstractHTTPMessageStream(HTTPRequest request) Creates a newAbstractHTTPMessageStream. -
Method Summary
Modifier and TypeMethodDescriptionvoidcallOnError(Exception err) Calls theonErrorcallback.voidCalls theonWritablecallback.Returns the request of thisHTTPMessageStream.protected voidCalled when a callback handler throws an exception.booleanisClosed()Returnstrueif thisHTTPMessageStreamhas closed, either forcibly (viaHTTPMessageStream.close()) 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.omegazero.http.util.HTTPMessageStream
close, close, setReceiveData
-
Field Details
-
request
-
closed
protected boolean closed -
onWritable
-
onError
-
-
Constructor Details
-
AbstractHTTPMessageStream
Creates a newAbstractHTTPMessageStream.- Parameters:
request- The request
-
-
Method Details
-
internalError
Called when a callback handler throws an exception. Calls theonErrorcallback and closes this stream with reason INTERNAL_ERROR.- Parameters:
e- The exception thrown by the callback handler
-
callOnWritable
public void callOnWritable()Calls theonWritablecallback. -
callOnError
Calls theonErrorcallback.- Parameters:
err- The object to pass to the callback
-
getRequest
Description copied from interface:HTTPMessageStreamReturns the request of thisHTTPMessageStream.- Specified by:
getRequestin interfaceHTTPMessageStream- Returns:
- The request
-
onWritable
Description copied from interface:HTTPMessageStreamSets a callback that is called when thisHTTPMessageStreamhas cleared its write buffer after asendDatacall returnedfalse.- Specified by:
onWritablein interfaceHTTPMessageStream- Parameters:
onWritable- The callback
-
onError
Description copied from interface:HTTPMessageStreamSets 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.- Specified by:
onErrorin interfaceHTTPMessageStream- Parameters:
onError- The callback
-
isClosed
public boolean isClosed()Description copied from interface:HTTPMessageStreamReturnstrueif thisHTTPMessageStreamhas closed, either forcibly (viaHTTPMessageStream.close()) or because the request transaction has completed.- Specified by:
isClosedin interfaceHTTPMessageStream- Returns:
trueif closed
-