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 boolean
protected Runnable
protected final HTTPRequest
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractHTTPMessageStream
(HTTPRequest request) Creates a newAbstractHTTPMessageStream
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
callOnError
(Exception err) Calls theonError
callback.void
Calls theonWritable
callback.Returns the request of thisHTTPMessageStream
.protected void
Called when a callback handler throws an exception.boolean
isClosed()
Returnstrue
if thisHTTPMessageStream
has closed, either forcibly (viaHTTPMessageStream.close()
) 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
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 theonError
callback and closes this stream with reason INTERNAL_ERROR.- Parameters:
e
- The exception thrown by the callback handler
-
callOnWritable
public void callOnWritable()Calls theonWritable
callback. -
callOnError
Calls theonError
callback.- Parameters:
err
- The object to pass to the callback
-
getRequest
Description copied from interface:HTTPMessageStream
Returns the request of thisHTTPMessageStream
.- Specified by:
getRequest
in interfaceHTTPMessageStream
- Returns:
- The request
-
onWritable
Description copied from interface:HTTPMessageStream
Sets a callback that is called when thisHTTPMessageStream
has cleared its write buffer after asendData
call returnedfalse
.- Specified by:
onWritable
in interfaceHTTPMessageStream
- Parameters:
onWritable
- The callback
-
onError
Description copied from interface:HTTPMessageStream
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.- Specified by:
onError
in interfaceHTTPMessageStream
- Parameters:
onError
- The callback
-
isClosed
public boolean isClosed()Description copied from interface:HTTPMessageStream
Returnstrue
if thisHTTPMessageStream
has closed, either forcibly (viaHTTPMessageStream.close()
) or because the request transaction has completed.- Specified by:
isClosed
in interfaceHTTPMessageStream
- Returns:
true
if closed
-