Package io.servicetalk.http.api
Class BlockingStreamingHttpServerResponse
- java.lang.Object
-
- io.servicetalk.http.api.BlockingStreamingHttpServerResponse
-
- All Implemented Interfaces:
HttpMetaData
,HttpResponseMetaData
public abstract class BlockingStreamingHttpServerResponse extends java.lang.Object
The equivalent ofHttpResponse
but provides an ability to write the payload to anHttpPayloadWriter
.- See Also:
BlockingStreamingHttpService
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description BlockingStreamingHttpServerResponse
addCookie(HttpCookiePair cookie)
Adds a cookie.BlockingStreamingHttpServerResponse
addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
BlockingStreamingHttpServerResponse
addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Adds a new header with the specifiedname
andvalue
.BlockingStreamingHttpServerResponse
addHeaders(HttpHeaders headers)
Adds all header names and values ofheaders
object.BlockingStreamingHttpServerResponse
addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.BlockingStreamingHttpServerResponse
addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
ContentCodec
encoding()
Returns theContentCodec
used to encode the payload of a request or a response.HttpMetaData
encoding(ContentCodec encoding)
TheContentCodec
used to encode the payload of a request or a response.boolean
equals(java.lang.Object o)
int
hashCode()
HttpHeaders
headers()
Returns the headers of this message.abstract HttpPayloadWriter<Buffer>
sendMetaData()
Sends theHttpResponseMetaData
and returns anHttpPayloadWriter
to continue writing the payload body.<T> HttpPayloadWriter<T>
sendMetaData(HttpSerializer<T> serializer)
Sends theHttpResponseMetaData
to the client and returns anHttpPayloadWriter
of typeBlockingStreamingHttpServerResponse
to continue writing a payload body.HttpOutputStream
sendMetaDataOutputStream()
Sends theHttpResponseMetaData
to the client and returns anOutputStream
to continue writing a payload body.BlockingStreamingHttpServerResponse
setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Sets a header with the specifiedname
andvalue
.BlockingStreamingHttpServerResponse
setHeaders(HttpHeaders headers)
Clears the current header entries and copies all header entries of the specifiedheaders
object.HttpResponseStatus
status()
Returns the status of thisStreamingHttpResponse
.BlockingStreamingHttpServerResponse
status(HttpResponseStatus status)
Set the status of thisStreamingHttpResponse
.java.lang.String
toString()
Returns a string representation of the message.HttpProtocolVersion
version()
Returns the protocol version of thisHttpMetaData
.BlockingStreamingHttpServerResponse
version(HttpProtocolVersion version)
Set the protocol version of thisHttpMetaData
.
-
-
-
Method Detail
-
sendMetaData
public abstract HttpPayloadWriter<Buffer> sendMetaData()
Sends theHttpResponseMetaData
and returns anHttpPayloadWriter
to continue writing the payload body.Note: calling any other method on this class after calling this method is not allowed.
- Returns:
HttpPayloadWriter
to write a payload body- Throws:
java.lang.IllegalStateException
- if one of thesendMetaData*
methods has been called on this response
-
sendMetaData
public final <T> HttpPayloadWriter<T> sendMetaData(HttpSerializer<T> serializer)
Sends theHttpResponseMetaData
to the client and returns anHttpPayloadWriter
of typeBlockingStreamingHttpServerResponse
to continue writing a payload body. Each element will be serialized using providedserializer
.Note: calling any other method on this class after calling this method is not allowed.
- Type Parameters:
T
- the type of objects to write- Parameters:
serializer
- used to serialize the payload elements- Returns:
HttpPayloadWriter
to write a payload body- Throws:
java.lang.IllegalStateException
- if one of thesendMetaData*
methods has been called on this response
-
sendMetaDataOutputStream
public final HttpOutputStream sendMetaDataOutputStream()
Sends theHttpResponseMetaData
to the client and returns anOutputStream
to continue writing a payload body.Note: calling any other method on this class after calling this method is not allowed.
- Returns:
HttpOutputStream
to write a payload body- Throws:
java.lang.IllegalStateException
- if one of thesendMetaData*
methods has been called on this response
-
version
public BlockingStreamingHttpServerResponse 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
public BlockingStreamingHttpServerResponse 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
public BlockingStreamingHttpServerResponse addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Adds a new header with the specifiedname
andvalue
.- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
public BlockingStreamingHttpServerResponse addHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Adds all header names and values ofheaders
object.- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
public BlockingStreamingHttpServerResponse 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.- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
setHeaders
public BlockingStreamingHttpServerResponse setHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Clears the current header entries and copies all header entries of the specifiedheaders
object.- Parameters:
headers
- the headers object which contains new values.- Returns:
this
.
-
addCookie
public BlockingStreamingHttpServerResponse addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaData
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
public BlockingStreamingHttpServerResponse 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.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addSetCookie
public BlockingStreamingHttpServerResponse addSetCookie(HttpSetCookie cookie)
Description copied from interface:HttpMetaData
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
public BlockingStreamingHttpServerResponse 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.- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
status
public final HttpResponseStatus status()
Description copied from interface:HttpResponseMetaData
Returns the status of thisStreamingHttpResponse
.- Specified by:
status
in interfaceHttpResponseMetaData
- Returns:
- The
HttpResponseStatus
of thisStreamingHttpResponse
-
toString
public final java.lang.String toString()
Description copied from interface:HttpMetaData
Returns a string representation of the message. To avoid accidentally logging sensitive information, implementations should not return any header or content.- Specified by:
toString
in interfaceHttpMetaData
- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of the message
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
version
public final HttpProtocolVersion version()
Description copied from interface:HttpMetaData
Returns the protocol version of thisHttpMetaData
.- Specified by:
version
in interfaceHttpMetaData
- Returns:
- the version.
-
encoding
public HttpMetaData encoding(ContentCodec 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 passingContentCodings.identity()
.- Specified by:
encoding
in interfaceHttpMetaData
- Parameters:
encoding
- TheContentCodec
used for the encoding of the payload.- Returns:
this
.- See Also:
- Content-Encoding
-
encoding
public ContentCodec encoding()
Description copied from interface:HttpMetaData
Returns theContentCodec
used to encode the payload of a request or a response.- Specified by:
encoding
in interfaceHttpMetaData
- Returns:
- The
ContentCodec
used for the encoding of the payload. - See Also:
- Content-Encoding
-
headers
public final HttpHeaders headers()
Description copied from interface:HttpMetaData
Returns the headers of this message.- Specified by:
headers
in interfaceHttpMetaData
- Returns:
- the headers.
-
-