Interface BlockingStreamingHttpResponse
-
- All Superinterfaces:
HttpMetaData,HttpResponseMetaData
public interface BlockingStreamingHttpResponse extends HttpResponseMetaData
The equivalent ofHttpResponsebut provides the payload as aBlockingIterable.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default BlockingStreamingHttpResponseaddCookie(HttpCookiePair cookie)Adds a cookie.default BlockingStreamingHttpResponseaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default BlockingStreamingHttpResponseaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.default BlockingStreamingHttpResponseaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.default BlockingStreamingHttpResponseaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.default BlockingStreamingHttpResponseaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)BlockingIterable<Buffer>payloadBody()BlockingStreamingHttpResponsepayloadBody(CloseableIterable<Buffer> payloadBody)Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.<T> BlockingStreamingHttpResponsepayloadBody(CloseableIterable<T> payloadBody, HttpSerializer<T> serializer)Returns aBlockingStreamingHttpResponsewith its underlying payload set to the result of serialization.default <T> BlockingIterable<T>payloadBody(HttpDeserializer<T> deserializer)Gets and deserializes the payload body.BlockingStreamingHttpResponsepayloadBody(java.io.InputStream payloadBody)Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.BlockingStreamingHttpResponsepayloadBody(java.lang.Iterable<Buffer> payloadBody)Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.<T> BlockingStreamingHttpResponsepayloadBody(java.lang.Iterable<T> payloadBody, HttpSerializer<T> serializer)Returns aBlockingStreamingHttpResponsewith its underlying payload set to the result of serialization.default java.io.InputStreampayloadBodyInputStream()Gets the underlying payload as aInputStream.default BlockingStreamingHttpResponsesetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.default BlockingStreamingHttpResponsesetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.BlockingStreamingHttpResponsestatus(HttpResponseStatus status)Set the status of thisStreamingHttpResponse.Single<HttpResponse>toResponse()Translates thisBlockingStreamingHttpResponseto aHttpResponse.StreamingHttpResponsetoStreamingResponse()Translates thisBlockingStreamingHttpResponseto aStreamingHttpResponse.<T> BlockingStreamingHttpResponsetransform(TrailersTransformer<T,Buffer> trailersTransformer)Returns aBlockingStreamingHttpResponsewith its underlying payload transformed toBuffers, with access to the trailers.<T> BlockingStreamingHttpResponsetransformPayloadBody(java.util.function.Function<BlockingIterable<Buffer>,BlockingIterable<T>> transformer, HttpSerializer<T> serializer)Returns aBlockingStreamingHttpResponsewith its underlying payload transformed to the result of serialization.default <T,R>
BlockingStreamingHttpResponsetransformPayloadBody(java.util.function.Function<BlockingIterable<T>,BlockingIterable<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)Returns aBlockingStreamingHttpResponsewith its underlying payload transformed to the result of serialization.BlockingStreamingHttpResponsetransformPayloadBody(java.util.function.UnaryOperator<BlockingIterable<Buffer>> transformer)Returns aBlockingStreamingHttpResponsewith its underlying payload transformed toBuffers.BlockingStreamingHttpResponseversion(HttpProtocolVersion version)Set the protocol version of thisHttpMetaData.-
Methods inherited from interface io.servicetalk.http.api.HttpMetaData
encoding, encoding, headers, toString, toString, version
-
Methods inherited from interface io.servicetalk.http.api.HttpResponseMetaData
status
-
-
-
-
Method Detail
-
payloadBody
BlockingIterable<Buffer> payloadBody()
-
payloadBodyInputStream
default java.io.InputStream payloadBodyInputStream()
Gets the underlying payload as aInputStream.- Returns:
- The
InputStreamrepresentation of the underlying payload body.
-
payloadBody
default <T> BlockingIterable<T> payloadBody(HttpDeserializer<T> deserializer)
Gets and deserializes the payload body.- Type Parameters:
T- The resulting type of the deserialization operation.- Parameters:
deserializer- The function that deserializes the underlyingBlockingIterable.- Returns:
- The results of the deserialization operation.
-
payloadBody
BlockingStreamingHttpResponse payloadBody(java.lang.Iterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(UnaryOperator)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existing payload body that is being replaced.- Parameters:
payloadBody- The new payload body.- Returns:
this
-
payloadBody
BlockingStreamingHttpResponse payloadBody(CloseableIterable<Buffer> payloadBody)
Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(UnaryOperator)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existing payload body that is being replaced.- Parameters:
payloadBody- The new payload body.- Returns:
this
-
payloadBody
BlockingStreamingHttpResponse payloadBody(java.io.InputStream payloadBody)
Returns aBlockingStreamingHttpResponsewith its underlying payload set topayloadBody.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(UnaryOperator)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existing payload body that is being replaced.- Parameters:
payloadBody- The new payload body.- Returns:
this
-
payloadBody
<T> BlockingStreamingHttpResponse payloadBody(java.lang.Iterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpResponsewith its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(Function, HttpSerializer)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existing payload body that is being replaced.- Type Parameters:
T- The type of objects to serialize.- Parameters:
payloadBody- The new payload body, prior to serialization.serializer- Used to serialize the payload body.- Returns:
this
-
payloadBody
<T> BlockingStreamingHttpResponse payloadBody(CloseableIterable<T> payloadBody, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpResponsewith its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing payload body which is being replaced. If this default policy is not sufficient you can use
transformPayloadBody(Function, HttpSerializer)for more fine grain control.This method reserves the right to delay completion/consumption of
payloadBody. This may occur due to the combination with the existing payload body that is being replaced.- Type Parameters:
T- The type of objects to serialize.- Parameters:
payloadBody- The new payload body, prior to serialization.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
<T> BlockingStreamingHttpResponse transformPayloadBody(java.util.function.Function<BlockingIterable<Buffer>,BlockingIterable<T>> transformer, HttpSerializer<T> serializer)
Returns aBlockingStreamingHttpResponsewith its underlying payload transformed to the result of serialization.- Type Parameters:
T- The type of objects to serialize.- Parameters:
transformer- AFunctionwhich take as a parameter the existing payload bodyBlockingIterableand returns the new payload bodyBlockingIterableprior to serialization. It is assumed the existing payload bodyBlockingIterablewill be transformed/consumed or else no more responses may be processed.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
default <T,R> BlockingStreamingHttpResponse transformPayloadBody(java.util.function.Function<BlockingIterable<T>,BlockingIterable<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)
Returns aBlockingStreamingHttpResponsewith its underlying payload transformed to the result of serialization.- Type Parameters:
T- The type of objects to deserialize.R- The type of objects to serialize.- Parameters:
transformer- AFunctionwhich take as a parameter the existing payload bodyBlockingIterableand returns the new payload bodyBlockingIterableprior to serialization. It is assumed the existing payload bodyBlockingIterablewill be transformed/consumed or else no more requests may be processed.deserializer- Used to deserialize the existing payload body.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
BlockingStreamingHttpResponse transformPayloadBody(java.util.function.UnaryOperator<BlockingIterable<Buffer>> transformer)
Returns aBlockingStreamingHttpResponsewith its underlying payload transformed toBuffers.- Parameters:
transformer- AFunctionwhich take as a parameter the existing payload bodyBlockingIterableand returns the new payload bodyBlockingIterable. It is assumed the existing payload bodyBlockingIterablewill be transformed/consumed or else no more responses may be processed.- Returns:
this
-
transform
<T> BlockingStreamingHttpResponse transform(TrailersTransformer<T,Buffer> trailersTransformer)
Returns aBlockingStreamingHttpResponsewith its underlying payload transformed toBuffers, with access to the trailers.- Type Parameters:
T- The type of state used during the transformation.- Parameters:
trailersTransformer-TrailersTransformerto use for this transform.- Returns:
this
-
toResponse
Single<HttpResponse> toResponse()
Translates thisBlockingStreamingHttpResponseto aHttpResponse.- Returns:
- a
Singlethat completes with aHttpResponserepresentation of thisBlockingStreamingHttpResponse.
-
toStreamingResponse
StreamingHttpResponse toStreamingResponse()
Translates thisBlockingStreamingHttpResponseto aStreamingHttpResponse.- Returns:
- a
StreamingHttpResponserepresentation of thisBlockingStreamingHttpResponse.
-
version
BlockingStreamingHttpResponse version(HttpProtocolVersion version)
Description copied from interface:HttpMetaDataSet the protocol version of thisHttpMetaData.- Specified by:
versionin interfaceHttpMetaData- Specified by:
versionin interfaceHttpResponseMetaData- Parameters:
version- the protocol version to set.- Returns:
this.
-
status
BlockingStreamingHttpResponse status(HttpResponseStatus status)
Description copied from interface:HttpResponseMetaDataSet the status of thisStreamingHttpResponse.- Specified by:
statusin interfaceHttpResponseMetaData- Parameters:
status- TheHttpResponseStatusto set.- Returns:
this.
-
addHeader
default BlockingStreamingHttpResponse addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds a new header with the specifiednameandvalue.- Specified by:
addHeaderin interfaceHttpMetaData- Specified by:
addHeaderin interfaceHttpResponseMetaData- Parameters:
name- the name of the header.value- the value of the header.- Returns:
this.
-
addHeaders
default BlockingStreamingHttpResponse addHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaDataAdds all header names and values ofheadersobject.- Specified by:
addHeadersin interfaceHttpMetaData- Specified by:
addHeadersin interfaceHttpResponseMetaData- Parameters:
headers- the headers to add.- Returns:
this.
-
setHeader
default BlockingStreamingHttpResponse setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataSets a header with the specifiednameandvalue. Any existing headers with the same name are overwritten.- Specified by:
setHeaderin interfaceHttpMetaData- Specified by:
setHeaderin interfaceHttpResponseMetaData- Parameters:
name- the name of the header.value- the value of the header.- Returns:
this.
-
setHeaders
default BlockingStreamingHttpResponse setHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaDataClears the current header entries and copies all header entries of the specifiedheadersobject.- Specified by:
setHeadersin interfaceHttpMetaData- Specified by:
setHeadersin interfaceHttpResponseMetaData- Parameters:
headers- the headers object which contains new values.- Returns:
this.
-
addCookie
default BlockingStreamingHttpResponse addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaDataAdds a cookie.This may result in multiple
HttpCookiePairs with same name.- Specified by:
addCookiein interfaceHttpMetaData- Specified by:
addCookiein interfaceHttpResponseMetaData- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addCookie
default BlockingStreamingHttpResponse addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds a cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Specified by:
addCookiein interfaceHttpMetaData- Specified by:
addCookiein interfaceHttpResponseMetaData- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
addSetCookie
default BlockingStreamingHttpResponse addSetCookie(HttpSetCookie cookie)
Description copied from interface:HttpMetaDataAdds a set-cookie.This may result in multiple
HttpSetCookies with same name.- Specified by:
addSetCookiein interfaceHttpMetaData- Specified by:
addSetCookiein interfaceHttpResponseMetaData- Parameters:
cookie- the cookie to add.- Returns:
this.
-
addSetCookie
default BlockingStreamingHttpResponse addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds a set-cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Specified by:
addSetCookiein interfaceHttpMetaData- Specified by:
addSetCookiein interfaceHttpResponseMetaData- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
-