Interface StreamingHttpResponse
-
- All Superinterfaces:
HttpMetaData,HttpResponseMetaData
public interface StreamingHttpResponse extends HttpResponseMetaData
The equivalent ofHttpResponsebut provides the payload as aPublisher.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default StreamingHttpResponseaddCookie(HttpCookiePair cookie)Adds a cookie.default StreamingHttpResponseaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default StreamingHttpResponseaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.default StreamingHttpResponseaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.default StreamingHttpResponseaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.default StreamingHttpResponseaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)StreamingHttpResponseencoding(ContentCodec encoding)TheContentCodecused to encode the payload of a request or a response.Publisher<java.lang.Object>messageBody()Get the message-body which contains the payload body concatenated with the trailer (if present).Publisher<Buffer>payloadBody()StreamingHttpResponsepayloadBody(Publisher<Buffer> payloadBody)Returns aStreamingHttpResponsewith its underlying payload set topayloadBody.<T> StreamingHttpResponsepayloadBody(Publisher<T> payloadBody, HttpSerializer<T> serializer)Returns aStreamingHttpResponsewith its underlying payload set to the result of serialization.default <T> Publisher<T>payloadBody(HttpDeserializer<T> deserializer)Gets and deserializes the payload body.Publisher<java.lang.Object>payloadBodyAndTrailers()Deprecated.UsemessageBody().default StreamingHttpResponsesetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.default StreamingHttpResponsesetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.BlockingStreamingHttpResponsetoBlockingStreamingResponse()Translates thisStreamingHttpResponseto aBlockingStreamingHttpResponse.Single<HttpResponse>toResponse()Translates thisStreamingHttpResponseto aHttpResponse.<T> StreamingHttpResponsetransform(TrailersTransformer<T,Buffer> trailersTransformer)Returns aStreamingHttpResponsewith its underlying payload transformed toBuffers, with access to the trailers.StreamingHttpResponsetransformMessageBody(java.util.function.UnaryOperator<Publisher<?>> transformer)Transform the message-body which contains the payload body concatenated with the trailer (if present).<T> StreamingHttpResponsetransformPayloadBody(java.util.function.Function<Publisher<Buffer>,Publisher<T>> transformer, HttpSerializer<T> serializer)Returns aStreamingHttpResponsewith its underlying payload transformed to the result of serialization.default <T,R>
StreamingHttpResponsetransformPayloadBody(java.util.function.Function<Publisher<T>,Publisher<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)Returns aStreamingHttpResponsewith its underlying payload transformed to the result of serialization.StreamingHttpResponsetransformPayloadBody(java.util.function.UnaryOperator<Publisher<Buffer>> transformer)Returns aStreamingHttpResponsewith its underlying payload transformed toBuffers.<T> StreamingHttpResponsetransformRaw(TrailersTransformer<T,java.lang.Object> trailersTransformer)Deprecated.StreamingHttpResponsetransformRawPayloadBody(java.util.function.UnaryOperator<Publisher<?>> transformer)Deprecated.StreamingHttpResponseversion(HttpProtocolVersion version)Set the protocol version of thisHttpMetaData.-
Methods inherited from interface io.servicetalk.http.api.HttpMetaData
encoding, headers, toString, toString, version
-
Methods inherited from interface io.servicetalk.http.api.HttpResponseMetaData
status, status
-
-
-
-
Method Detail
-
payloadBody
default <T> Publisher<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 underlyingPublisher.- Returns:
- The results of the deserialization operation.
-
payloadBodyAndTrailers
@Deprecated Publisher<java.lang.Object> payloadBodyAndTrailers()
Deprecated.UsemessageBody().
-
messageBody
Publisher<java.lang.Object> messageBody()
Get the message-body which contains the payload body concatenated with the trailer (if present).- Returns:
- a
Publisherthat represents the message-body which contains the payload body concatenated with the trailer (if present).
-
payloadBody
StreamingHttpResponse payloadBody(Publisher<Buffer> payloadBody)
Returns aStreamingHttpResponsewith its underlying payload set topayloadBody.A best effort will be made to apply back pressure to the existing
Publisherpayload body. If this default policy is not sufficient you can usetransformPayloadBody(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 existingPublisherpayload body.- Parameters:
payloadBody- The new payload body.- Returns:
this
-
payloadBody
<T> StreamingHttpResponse payloadBody(Publisher<T> payloadBody, HttpSerializer<T> serializer)
Returns aStreamingHttpResponsewith its underlying payload set to the result of serialization.A best effort will be made to apply back pressure to the existing
Publisherpayload body. If this default policy is not sufficient you can usetransformPayloadBody(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 existingPublisherpayload body.- 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> StreamingHttpResponse transformPayloadBody(java.util.function.Function<Publisher<Buffer>,Publisher<T>> transformer, HttpSerializer<T> serializer)
Returns aStreamingHttpResponsewith 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 bodyPublisherand returns the new payload bodyPublisherprior to serialization. It is assumed the existing payload bodyPublisherwill be transformed/consumed or else no more responses may be processed.serializer- Used to serialize the payload body.- Returns:
this
-
transformPayloadBody
default <T,R> StreamingHttpResponse transformPayloadBody(java.util.function.Function<Publisher<T>,Publisher<R>> transformer, HttpDeserializer<T> deserializer, HttpSerializer<R> serializer)
Returns aStreamingHttpResponsewith 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 bodyPublisherand returns the new payload bodyPublisherprior to serialization. It is assumed the existing payload bodyPublisherwill 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
StreamingHttpResponse transformPayloadBody(java.util.function.UnaryOperator<Publisher<Buffer>> transformer)
Returns aStreamingHttpResponsewith its underlying payload transformed toBuffers.
-
transformRawPayloadBody
@Deprecated StreamingHttpResponse transformRawPayloadBody(java.util.function.UnaryOperator<Publisher<?>> transformer)
Deprecated.Returns aStreamingHttpResponsewith its underlying payload transformed. Note that the raw objects of the underlyingPublishermay be exposed. The object types are not guaranteed to be homogeneous.- Parameters:
transformer- Responsible for transforming the payload body.- Returns:
this
-
transformMessageBody
StreamingHttpResponse transformMessageBody(java.util.function.UnaryOperator<Publisher<?>> transformer)
Transform the message-body which contains the payload body concatenated with the trailer (if present).The transformation is not expected to change the presence of trailers in the message body. For example behavior is undefined if a
HttpHeadersobject is inserted to or removed from to the returnedPublisher. To add trailers usetransform(TrailersTransformer).- Parameters:
transformer- Responsible for transforming the message-body.- Returns:
this.
-
transform
<T> StreamingHttpResponse transform(TrailersTransformer<T,Buffer> trailersTransformer)
Returns aStreamingHttpResponsewith 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
-
transformRaw
@Deprecated <T> StreamingHttpResponse transformRaw(TrailersTransformer<T,java.lang.Object> trailersTransformer)
Deprecated.Returns aStreamingHttpResponsewith its underlying payload transformed toObjects, 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 thisStreamingHttpResponseto aHttpResponse.- Returns:
- a
Singlethat completes with aHttpResponserepresentation of thisStreamingHttpResponse.
-
toBlockingStreamingResponse
BlockingStreamingHttpResponse toBlockingStreamingResponse()
Translates thisStreamingHttpResponseto aBlockingStreamingHttpResponse.- Returns:
- a
BlockingStreamingHttpResponserepresentation of thisStreamingHttpResponse.
-
version
StreamingHttpResponse 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.
-
encoding
StreamingHttpResponse encoding(ContentCodec encoding)
Description copied from interface:HttpMetaDataTheContentCodecused to encode the payload of a request or a response. If the endpoint is setup withContentCodingHttpServiceFilter, the server will auto-establish the accepted encoding for the response, unless the caller provides a specific encoding by calling this method. Any encoding passed here, takes precedence. In other words, a compressed response, can be disabled by passingContentCodings.identity().- Specified by:
encodingin interfaceHttpMetaData- Parameters:
encoding- TheContentCodecused for the encoding of the payload.- Returns:
this.- See Also:
- Content-Encoding
-
addHeader
default StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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 StreamingHttpResponse 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.
-
-