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 HttpResponseaddCookie(HttpCookiePair cookie) Adds a cookie.default HttpResponseaddCookie(CharSequence name, CharSequence value) default HttpResponseaddHeader(CharSequence name, CharSequence value) Adds a new header with the specifiednameandvalue.default HttpResponseaddHeaders(HttpHeaders headers) Adds all header names and values ofheadersobject.default HttpResponseaddSetCookie(HttpSetCookie cookie) Adds a set-cookie.default HttpResponseaddSetCookie(CharSequence name, CharSequence value) default HttpResponseaddTrailer(CharSequence name, CharSequence value) default HttpResponseaddTrailers(HttpHeaders trailers) context(ContextMap context) Sets a context for thisHttpMetaData.default HttpResponseencoding(ContentCodec encoding) TheContentCodecused to encode the payload of a request or a response.Gets the underlying payload as aBuffer.payloadBody(Buffer payloadBody) Returns anHttpResponsewith its underlying payload set topayloadBody.default <T> TpayloadBody(HttpDeserializer<T> deserializer) Deprecated.<T> TpayloadBody(HttpDeserializer2<T> deserializer) Gets and deserializes the payload body.default <T> HttpResponsepayloadBody(T pojo, HttpSerializer<T> serializer) Deprecated.<T> HttpResponsepayloadBody(T pojo, HttpSerializer2<T> serializer) Returns anHttpResponsewith its underlying payload set to the results of serialization ofpojo.default HttpResponsesetHeader(CharSequence name, CharSequence value) Sets a header with the specifiednameandvalue.default HttpResponsesetHeaders(HttpHeaders headers) Clears the current header entries and copies all header entries of the specifiedheadersobject.default HttpResponsesetTrailer(CharSequence name, CharSequence value) default HttpResponsesetTrailers(HttpHeaders trailers) status(HttpResponseStatus status) Set the status of thisStreamingHttpResponse.Translates thisHttpResponseto aBlockingStreamingHttpResponse.Translates thisHttpResponseto 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, versionMethods inherited from interface io.servicetalk.http.api.HttpResponseMetaData
status
-
Method Details
-
payloadBody
Buffer payloadBody()Gets the underlying payload as aBuffer.- Returns:
- The
Bufferrepresentation 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 anHttpResponsewith its underlying payload set topayloadBody.- Parameters:
payloadBody- the underlying payload.- Returns:
this
-
payloadBody
Deprecated.Returns anHttpResponsewith 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- TheHttpSerializerwhich convertspojointo bytes.- Returns:
this
-
payloadBody
Returns anHttpResponsewith 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- TheHttpSerializerwhich convertspojointo bytes.- Returns:
this
-
toStreamingResponse
StreamingHttpResponse toStreamingResponse()Translates thisHttpResponseto aStreamingHttpResponse.- Returns:
- a
StreamingHttpResponserepresentation of thisHttpResponse.
-
toBlockingStreamingResponse
BlockingStreamingHttpResponse toBlockingStreamingResponse()Translates thisHttpResponseto aBlockingStreamingHttpResponse.- Returns:
- a
BlockingStreamingHttpResponserepresentation of thisHttpResponse.
-
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
Description copied from interface:HttpResponseMetaDataSet the status of thisStreamingHttpResponse.- Specified by:
statusin interfaceHttpResponseMetaData- Parameters:
status- TheHttpResponseStatusto set.- Returns:
this.
-
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 passingIdentity.identity().- Specified by:
encodingin interfaceHttpMetaData- Parameters:
encoding- TheContentCodecused for the encoding of the payload.- Returns:
this.- See Also:
-
addHeader
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
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
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
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
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
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
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
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.
-
addTrailer
-
addTrailers
-
setTrailer
-
setTrailers
-
context
Description copied from interface:HttpMetaDataSets 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:
contextin interfaceContextMapHolder- Specified by:
contextin interfaceHttpMetaData- Specified by:
contextin interfaceHttpResponseMetaData- Parameters:
context- the new context for thisHttpMetaData.- Returns:
this.
-
trailers
HttpHeaders trailers()Gets the trailers.- Returns:
- the trailers.
-
payloadBody(HttpDeserializer2).