Class AbstractHTTPClientStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HTTPClientStream
,HTTPMessageStream
HTTPClientStream
with several basic methods implemented.- Since:
- 1.4.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final HTTPClient
protected Consumer<HTTPResponse>
protected Consumer<HTTPResponseData>
protected Consumer<HTTPMessageTrailers>
protected Consumer<HTTPClientStream>
protected HTTPResponse
Fields inherited from class org.omegazero.http.util.AbstractHTTPMessageStream
closed, onError, onWritable, request
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractHTTPClientStream
(HTTPRequest request, HTTPClient client) Creates a newAbstractHTTPClientStream
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls theonResponseData
callback.void
callOnResponseEnded
(HTTPMessageTrailers trailers) void
callOnServerPush
(HTTPClientStream reqstream) Calls theonServerPush
callback.Returns theHTTPClient
that created thisHTTPClientStream
.Returns the received response of thisHTTPClientStream
, ornull
if no response was received yet.void
onResponse
(Consumer<HTTPResponse> onResponse) Sets a callback that is called when thisHTTPClientStream
receives a response.void
onResponseData
(Consumer<HTTPResponseData> onResponseData) Sets a callback that is called when thisHTTPClientStream
receives data for the response.void
onResponseEnded
(Consumer<HTTPMessageTrailers> onResponseEnded) Sets a callback that is called when thisHTTPClientStream
has finished receiving the response and data, including optional trailers.void
onServerPush
(Consumer<HTTPClientStream> onServerPush) Sets a callback that is called when thisHTTPClientStream
receives a pushed request.void
responseReceived
(HTTPResponse response) Calls theonResponse
callback and stores the response, ifHTTPResponse.isIntermediateMessage()
isfalse
.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.HTTPClientStream
endRequest, sendRequestData, startRequest
Methods inherited from interface org.omegazero.http.util.HTTPMessageStream
close, close, getRequest, isClosed, onError, onWritable, setReceiveData
-
Field Details
-
client
-
response
-
onServerPush
-
onResponse
-
onResponseData
-
onResponseEnded
-
-
Constructor Details
-
AbstractHTTPClientStream
Creates a newAbstractHTTPClientStream
.- Parameters:
request
- The requestclient
- The client
-
-
Method Details
-
callOnServerPush
Calls theonServerPush
callback.- Parameters:
reqstream
- The pushed response stream
-
responseReceived
Calls theonResponse
callback and stores the response, ifHTTPResponse.isIntermediateMessage()
isfalse
.- Parameters:
response
- The response
-
callOnResponseData
Calls theonResponseData
callback.- Parameters:
data
- The object to pass to the callback
-
callOnResponseEnded
- Parameters:
trailers
- Optional trailers to pass to the callback
-
getClient
Description copied from interface:HTTPClientStream
Returns theHTTPClient
that created thisHTTPClientStream
.- Specified by:
getClient
in interfaceHTTPClientStream
- Returns:
- The
HTTPClient
-
getResponse
Description copied from interface:HTTPClientStream
Returns the received response of thisHTTPClientStream
, ornull
if no response was received yet.- Specified by:
getResponse
in interfaceHTTPClientStream
- Returns:
- The response
-
onServerPush
Description copied from interface:HTTPClientStream
Sets a callback that is called when thisHTTPClientStream
receives a pushed request.This callback is always called before the
onResponse
callback. If the underlying protocol does not support server push, this callback is never called.The new
HTTPClientStream
passed to the callback is used to receive the pushed response. The methodsHTTPClientStream.startRequest()
,HTTPClientStream.sendRequestData(byte[], boolean)
, andHTTPClientStream.endRequest(HTTPMessageTrailers)
should not be called on thisHTTPClientStream
. TheonResponse
callback will be called as soon as the pushed response is received.- Specified by:
onServerPush
in interfaceHTTPClientStream
- Parameters:
onServerPush
- The callback
-
onResponse
Description copied from interface:HTTPClientStream
Sets a callback that is called when thisHTTPClientStream
receives a response.No other callbacks in this
HTTPClientStream
are called before the given callback has returned.This callback may be called multiple times when receiving multiple responses (for example, a 102 Processing followed by the actual response, see also:
HTTPResponse.isIntermediateMessage()
).- Specified by:
onResponse
in interfaceHTTPClientStream
- Parameters:
onResponse
- The callback
-
onResponseData
Description copied from interface:HTTPClientStream
Sets a callback that is called when thisHTTPClientStream
receives data for the response.If
HTTPMessageData.isLastPacket()
istrue
for aHTTPResponseData
object passed to the callback, it is followed by aonResponseEnded
callback.- Specified by:
onResponseData
in interfaceHTTPClientStream
- Parameters:
onResponseData
- The callback
-
onResponseEnded
Description copied from interface:HTTPClientStream
Sets a callback that is called when thisHTTPClientStream
has finished receiving the response and data, including optional trailers.If this callback is called, this
HTTPClientStream
is implicitly closed and no further callbacks will be called.- Specified by:
onResponseEnded
in interfaceHTTPClientStream
- Parameters:
onResponseEnded
- The callback
-