Package org.omegazero.http.util
Class AbstractHTTPServerStream
java.lang.Object
org.omegazero.http.util.AbstractHTTPMessageStream
org.omegazero.http.util.AbstractHTTPServerStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HTTPMessageStream
,HTTPServerStream
public abstract class AbstractHTTPServerStream
extends AbstractHTTPMessageStream
implements HTTPServerStream
A
HTTPServerStream
with several basic methods implemented.- Since:
- 1.4.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Consumer<HTTPRequestData>
protected Consumer<HTTPMessageTrailers>
protected final HTTPServer
Fields inherited from class org.omegazero.http.util.AbstractHTTPMessageStream
closed, onError, onWritable, request
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractHTTPServerStream
(HTTPRequest request, HTTPServer server) Creates a newAbstractHTTPServerStream
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls theonRequestData
callback.void
callOnRequestEnded
(HTTPMessageTrailers trailers) Calls theonRequestEnded
callback.Returns theHTTPServer
that created thisHTTPServerStream
.void
onRequestData
(Consumer<HTTPRequestData> onRequestData) Sets a callback that is called when thisHTTPServerStream
receives data for the request.void
onRequestEnded
(Consumer<HTTPMessageTrailers> onRequestEnded) Sets a callback that is called when thisHTTPServerStream
has finished receiving the request and data, including optional trailers.void
Responds to thisHTTPServerStream
with a new HTTP response with the given status, data and headers, if no response was already sent.void
respond
(HTTPResponseData response) Responds to thisHTTPServerStream
with the given full response, if no response was already sent.Methods inherited from class org.omegazero.http.util.AbstractHTTPMessageStream
callOnError, callOnWritable, getRequest, internalError, isClosed, onError, onWritable
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, getRequest, isClosed, onError, onWritable, setReceiveData
Methods inherited from interface org.omegazero.http.util.HTTPServerStream
endResponse, sendResponseData, startResponse, startServerPush
-
Field Details
-
server
-
onRequestData
-
onRequestEnded
-
-
Constructor Details
-
AbstractHTTPServerStream
Creates a newAbstractHTTPServerStream
.- Parameters:
request
- The requestserver
- The server
-
-
Method Details
-
callOnRequestData
Calls theonRequestData
callback.- Parameters:
data
- The object to pass to the callback
-
callOnRequestEnded
Calls theonRequestEnded
callback.- Parameters:
trailers
- Optional trailers to pass to the callback
-
getServer
Description copied from interface:HTTPServerStream
Returns theHTTPServer
that created thisHTTPServerStream
.- Specified by:
getServer
in interfaceHTTPServerStream
- Returns:
- The
HTTPServer
-
onRequestData
Description copied from interface:HTTPServerStream
Sets a callback that is called when thisHTTPServerStream
receives data for the request.If
HTTPMessageData.isLastPacket()
istrue
for aHTTPRequestData
object passed to the callback, it is followed by aonRequestEnded
callback.- Specified by:
onRequestData
in interfaceHTTPServerStream
- Parameters:
onRequestData
- The callback
-
onRequestEnded
Description copied from interface:HTTPServerStream
Sets a callback that is called when thisHTTPServerStream
has finished receiving the request and data, including optional trailers.If this callback is called, it ends this
HTTPServerStream
and no further callbacks will be called.- Specified by:
onRequestEnded
in interfaceHTTPServerStream
- Parameters:
onRequestEnded
- The callback
-
respond
Responds to thisHTTPServerStream
with the given full response, if no response was already sent. This method implicitly closes thisHTTPServerStream
.See
HTTPResponder.respond(HTTPRequest, HTTPResponseData)
for additional information.- Specified by:
respond
in interfaceHTTPServerStream
- Parameters:
response
- The response- See Also:
- Implementation Note:
- Calls
HTTPResponder.respond(HTTPRequest, HTTPResponseData)
-
respond
Responds to thisHTTPServerStream
with a new HTTP response with the given status, data and headers, if no response was already sent. This method implicitly closes thisHTTPServerStream
.See
HTTPResponder.respond(HTTPRequest, int, byte[], String...)
for additional information.- Specified by:
respond
in interfaceHTTPServerStream
- Parameters:
status
- The status code of the responsedata
- The data to send in the responseheaders
- Headers to send in the response- See Also:
- Implementation Note:
- Calls
HTTPResponder.respond(HTTPRequest, int, byte[], String...)
-