Package io.servicetalk.http.api
Interface HttpResponse
-
- All Superinterfaces:
HttpMetaData
,HttpResponseMetaData
public interface HttpResponse extends HttpResponseMetaData
An HTTP response. The payload is represented as a singleObject
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpResponse
addCookie(HttpCookiePair cookie)
Adds a cookie.default HttpResponse
addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpResponse
addHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpResponse
addTrailer(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpResponse
addTrailers(HttpHeaders trailers)
Buffer
payloadBody()
Gets the underlying payload as aBuffer
.HttpResponse
payloadBody(Buffer payloadBody)
Returns anHttpResponse
with its underlying payload set topayloadBody
.default <T> T
payloadBody(HttpDeserializer<T> deserializer)
Gets and deserializes the payload body.<T> HttpResponse
payloadBody(T pojo, HttpSerializer<T> serializer)
Returns anHttpResponse
with its underlying payload set to the results of serialization ofpojo
.default HttpResponse
setHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpResponse
setTrailers(HttpHeaders trailers)
HttpResponse
status(HttpResponseStatus status)
Set the status of thisStreamingHttpResponse
.BlockingStreamingHttpResponse
toBlockingStreamingResponse()
Translates thisHttpResponse
to aBlockingStreamingHttpResponse
.StreamingHttpResponse
toStreamingResponse()
Translates thisHttpResponse
to aStreamingHttpResponse
.HttpHeaders
trailers()
Gets the trailers.HttpResponse
version(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
Buffer payloadBody()
Gets the underlying payload as aBuffer
.- Returns:
- The
Buffer
representation of the underlying payload.
-
payloadBody
default <T> 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 underlyingObject
.- Returns:
- The results of the deserialization operation.
-
payloadBody
HttpResponse payloadBody(Buffer payloadBody)
Returns anHttpResponse
with its underlying payload set topayloadBody
.- Parameters:
payloadBody
- the underlying payload.- Returns:
this
-
payloadBody
<T> HttpResponse payloadBody(T pojo, HttpSerializer<T> serializer)
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
HttpResponse version(HttpProtocolVersion 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
HttpResponse status(HttpResponseStatus status)
Description copied from interface:HttpResponseMetaData
Set the status of thisStreamingHttpResponse
.- Specified by:
status
in interfaceHttpResponseMetaData
- Parameters:
status
- TheHttpResponseStatus
to set.- Returns:
this
.
-
addHeader
default HttpResponse addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpResponse addHeaders(HttpHeaders headers)
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
default HttpResponse setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpResponse setHeaders(HttpHeaders headers)
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
default HttpResponse addCookie(HttpCookiePair cookie)
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
default HttpResponse addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpResponse addSetCookie(HttpSetCookie cookie)
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
default HttpResponse addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
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
default HttpResponse addTrailer(java.lang.CharSequence name, java.lang.CharSequence value)
-
addTrailers
default HttpResponse addTrailers(HttpHeaders trailers)
-
setTrailer
default HttpResponse setTrailer(java.lang.CharSequence name, java.lang.CharSequence value)
-
setTrailers
default HttpResponse setTrailers(HttpHeaders trailers)
-
trailers
HttpHeaders trailers()
Gets the trailers.- Returns:
- the trailers.
-
-