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 HTTPServerFields 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 TypeMethodDescriptionvoidCalls theonRequestDatacallback.voidcallOnRequestEnded(HTTPMessageTrailers trailers) Calls theonRequestEndedcallback.Returns theHTTPServerthat created thisHTTPServerStream.voidonRequestData(Consumer<HTTPRequestData> onRequestData) Sets a callback that is called when thisHTTPServerStreamreceives data for the request.voidonRequestEnded(Consumer<HTTPMessageTrailers> onRequestEnded) Sets a callback that is called when thisHTTPServerStreamhas finished receiving the request and data, including optional trailers.voidResponds to thisHTTPServerStreamwith a new HTTP response with the given status, data and headers, if no response was already sent.voidrespond(HTTPResponseData response) Responds to thisHTTPServerStreamwith 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, onWritableMethods 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, getRequest, isClosed, onError, onWritable, setReceiveDataMethods 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 theonRequestDatacallback.- Parameters:
data- The object to pass to the callback
-
callOnRequestEnded
Calls theonRequestEndedcallback.- Parameters:
trailers- Optional trailers to pass to the callback
-
getServer
Description copied from interface:HTTPServerStreamReturns theHTTPServerthat created thisHTTPServerStream.- Specified by:
getServerin interfaceHTTPServerStream- Returns:
- The
HTTPServer
-
onRequestData
Description copied from interface:HTTPServerStreamSets a callback that is called when thisHTTPServerStreamreceives data for the request.If
HTTPMessageData.isLastPacket()istruefor aHTTPRequestDataobject passed to the callback, it is followed by aonRequestEndedcallback.- Specified by:
onRequestDatain interfaceHTTPServerStream- Parameters:
onRequestData- The callback
-
onRequestEnded
Description copied from interface:HTTPServerStreamSets a callback that is called when thisHTTPServerStreamhas finished receiving the request and data, including optional trailers.If this callback is called, it ends this
HTTPServerStreamand no further callbacks will be called.- Specified by:
onRequestEndedin interfaceHTTPServerStream- Parameters:
onRequestEnded- The callback
-
respond
Responds to thisHTTPServerStreamwith 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:
respondin interfaceHTTPServerStream- Parameters:
response- The response- See Also:
- Implementation Note:
- Calls
HTTPResponder.respond(HTTPRequest, HTTPResponseData)
-
respond
Responds to thisHTTPServerStreamwith 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:
respondin 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...)
-