Package io.servicetalk.http.api
Interface HttpResponse
- All Superinterfaces:
ContextMapHolder
,HttpMetaData
,HttpResponseMetaData
An HTTP response. The payload is represented as a single
Object
.-
Method Summary
Modifier and TypeMethodDescriptiondefault HttpResponse
addCookie
(HttpCookiePair cookie) Adds a cookie.default HttpResponse
addCookie
(CharSequence name, CharSequence value) default HttpResponse
addHeader
(CharSequence name, CharSequence value) Adds a new header with the specifiedname
andvalue
.default HttpResponse
addHeaders
(HttpHeaders headers) Adds all header names and values ofheaders
object.default HttpResponse
addSetCookie
(HttpSetCookie cookie) Adds a set-cookie.default HttpResponse
addSetCookie
(CharSequence name, CharSequence value) default HttpResponse
addTrailer
(CharSequence name, CharSequence value) default HttpResponse
addTrailers
(HttpHeaders trailers) context
(ContextMap context) Sets a context for thisHttpMetaData
.default HttpResponse
encoding
(ContentCodec encoding) TheContentCodec
used to encode the payload of a request or a response.Gets the underlying payload as aBuffer
.payloadBody
(Buffer payloadBody) Returns anHttpResponse
with its underlying payload set topayloadBody
.default <T> T
payloadBody
(HttpDeserializer<T> deserializer) Deprecated.<T> T
payloadBody
(HttpDeserializer2<T> deserializer) Gets and deserializes the payload body.default <T> HttpResponse
payloadBody
(T pojo, HttpSerializer<T> serializer) Deprecated.<T> HttpResponse
payloadBody
(T pojo, HttpSerializer2<T> serializer) Returns anHttpResponse
with its underlying payload set to the results of serialization ofpojo
.default HttpResponse
setHeader
(CharSequence name, CharSequence value) Sets a header with the specifiedname
andvalue
.default HttpResponse
setHeaders
(HttpHeaders headers) Clears the current header entries and copies all header entries of the specifiedheaders
object.default HttpResponse
setTrailer
(CharSequence name, CharSequence value) default HttpResponse
setTrailers
(HttpHeaders trailers) status
(HttpResponseStatus status) Set the status of thisStreamingHttpResponse
.Translates thisHttpResponse
to aBlockingStreamingHttpResponse
.Translates thisHttpResponse
to aStreamingHttpResponse
.trailers()
Gets the trailers.version
(HttpProtocolVersion version) Set the protocol version of thisHttpMetaData
.Methods inherited from interface io.servicetalk.http.api.HttpMetaData
context, encoding, headers, toString, toString, version
Methods inherited from interface io.servicetalk.http.api.HttpResponseMetaData
status
-
Method Details
-
payloadBody
Buffer payloadBody()Gets the underlying payload as aBuffer
.- Returns:
- The
Buffer
representation of the underlying payload.
-
payloadBody
Deprecated.Gets and deserializes the payload body.- Type Parameters:
T
- The resulting type of the deserialization operation.- Parameters:
deserializer
- The function that deserializes the underlyingObject
.- Returns:
- The results of the deserialization operation.
-
payloadBody
Gets and deserializes the payload body.- Type Parameters:
T
- The resulting type of the deserialization operation.- Parameters:
deserializer
- The function that deserializes the underlyingObject
.- Returns:
- The results of the deserialization operation.
-
payloadBody
Returns anHttpResponse
with its underlying payload set topayloadBody
.- Parameters:
payloadBody
- the underlying payload.- Returns:
this
-
payloadBody
Deprecated.Returns anHttpResponse
with its underlying payload set to the results of serialization ofpojo
.- Type Parameters:
T
- The type of object to serialize.- Parameters:
pojo
- The object to serialize.serializer
- TheHttpSerializer
which convertspojo
into bytes.- Returns:
this
-
payloadBody
Returns anHttpResponse
with its underlying payload set to the results of serialization ofpojo
.- Type Parameters:
T
- The type of object to serialize.- Parameters:
pojo
- The object to serialize.serializer
- TheHttpSerializer
which convertspojo
into bytes.- Returns:
this
-
toStreamingResponse
StreamingHttpResponse toStreamingResponse()Translates thisHttpResponse
to aStreamingHttpResponse
.- Returns:
- a
StreamingHttpResponse
representation of thisHttpResponse
.
-
toBlockingStreamingResponse
BlockingStreamingHttpResponse toBlockingStreamingResponse()Translates thisHttpResponse
to aBlockingStreamingHttpResponse
.- Returns:
- a
BlockingStreamingHttpResponse
representation of thisHttpResponse
.
-
version
Description copied from interface:HttpMetaData
Set the protocol version of thisHttpMetaData
.- Specified by:
version
in interfaceHttpMetaData
- Specified by:
version
in interfaceHttpResponseMetaData
- Parameters:
version
- the protocol version to set.- Returns:
this
.
-
status
Description copied from interface:HttpResponseMetaData
Set the status of thisStreamingHttpResponse
.- Specified by:
status
in interfaceHttpResponseMetaData
- Parameters:
status
- TheHttpResponseStatus
to set.- Returns:
this
.
-
encoding
Description copied from interface:HttpMetaData
TheContentCodec
used 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 passingIdentity.identity()
.- Specified by:
encoding
in interfaceHttpMetaData
- Parameters:
encoding
- TheContentCodec
used for the encoding of the payload.- Returns:
this
.- See Also:
-
addHeader
Description copied from interface:HttpMetaData
Adds a new header with the specifiedname
andvalue
.- Specified by:
addHeader
in interfaceHttpMetaData
- Specified by:
addHeader
in interfaceHttpResponseMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
Description copied from interface:HttpMetaData
Adds all header names and values ofheaders
object.- Specified by:
addHeaders
in interfaceHttpMetaData
- Specified by:
addHeaders
in interfaceHttpResponseMetaData
- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
Description copied from interface:HttpMetaData
Sets a header with the specifiedname
andvalue
. Any existing headers with the same name are overwritten.- Specified by:
setHeader
in interfaceHttpMetaData
- Specified by:
setHeader
in interfaceHttpResponseMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
setHeaders
Description copied from interface:HttpMetaData
Clears the current header entries and copies all header entries of the specifiedheaders
object.- Specified by:
setHeaders
in interfaceHttpMetaData
- Specified by:
setHeaders
in interfaceHttpResponseMetaData
- Parameters:
headers
- the headers object which contains new values.- Returns:
this
.
-
addCookie
Description copied from interface:HttpMetaData
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Specified by:
addCookie
in interfaceHttpMetaData
- Specified by:
addCookie
in interfaceHttpResponseMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
Description copied from interface:HttpMetaData
Adds a cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s 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:
addCookie
in interfaceHttpMetaData
- Specified by:
addCookie
in interfaceHttpResponseMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addSetCookie
Description copied from interface:HttpMetaData
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Specified by:
addSetCookie
in interfaceHttpMetaData
- Specified by:
addSetCookie
in interfaceHttpResponseMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
Description copied from interface:HttpMetaData
Adds a set-cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s 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:
addSetCookie
in interfaceHttpMetaData
- Specified by:
addSetCookie
in interfaceHttpResponseMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addTrailer
-
addTrailers
-
setTrailer
-
setTrailers
-
context
Description copied from interface:HttpMetaData
Sets a context for thisHttpMetaData
.Context can be used to associate a state with a request or response message without serializing its state on the wire.
- Specified by:
context
in interfaceContextMapHolder
- Specified by:
context
in interfaceHttpMetaData
- Specified by:
context
in interfaceHttpResponseMetaData
- Parameters:
context
- the new context for thisHttpMetaData
.- Returns:
this
.
-
trailers
HttpHeaders trailers()Gets the trailers.- Returns:
- the trailers.
-
payloadBody(HttpDeserializer2)
.