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 HttpResponseaddCookie(HttpCookiePair cookie)Adds a cookie.default HttpResponseaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default HttpResponseaddHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)default HttpResponseaddTrailer(java.lang.CharSequence name, java.lang.CharSequence value)default HttpResponseaddTrailers(HttpHeaders trailers)BufferpayloadBody()Gets the underlying payload as aBuffer.HttpResponsepayloadBody(Buffer payloadBody)Returns anHttpResponsewith its underlying payload set topayloadBody.default <T> TpayloadBody(HttpDeserializer<T> deserializer)Gets and deserializes the payload body.<T> HttpResponsepayloadBody(T pojo, HttpSerializer<T> serializer)Returns anHttpResponsewith its underlying payload set to the results of serialization ofpojo.default HttpResponsesetHeader(java.lang.CharSequence name, java.lang.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(java.lang.CharSequence name, java.lang.CharSequence value)default HttpResponsesetTrailers(HttpHeaders trailers)HttpResponsestatus(HttpResponseStatus status)Set the status of thisStreamingHttpResponse.BlockingStreamingHttpResponsetoBlockingStreamingResponse()Translates thisHttpResponseto aBlockingStreamingHttpResponse.StreamingHttpResponsetoStreamingResponse()Translates thisHttpResponseto aStreamingHttpResponse.HttpHeaderstrailers()Gets the trailers.HttpResponseversion(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
Bufferrepresentation 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 anHttpResponsewith its underlying payload set topayloadBody.- Parameters:
payloadBody- the underlying payload.- Returns:
this
-
payloadBody
<T> HttpResponse payloadBody(T pojo, HttpSerializer<T> serializer)
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
HttpResponse 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
HttpResponse status(HttpResponseStatus status)
Description copied from interface:HttpResponseMetaDataSet the status of thisStreamingHttpResponse.- Specified by:
statusin interfaceHttpResponseMetaData- Parameters:
status- TheHttpResponseStatusto set.- Returns:
this.
-
addHeader
default HttpResponse 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 HttpResponse 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 HttpResponse 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 HttpResponse 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 HttpResponse 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 HttpResponse 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 HttpResponse 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 HttpResponse 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.
-
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.
-
-