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.ObjectThe equivalent ofHttpResponsebut 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 BlockingStreamingHttpServerResponseaddCookie(HttpCookiePair cookie)Adds a cookie.BlockingStreamingHttpServerResponseaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)BlockingStreamingHttpServerResponseaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.BlockingStreamingHttpServerResponseaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.BlockingStreamingHttpServerResponseaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.BlockingStreamingHttpServerResponseaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)ContentCodecencoding()Returns theContentCodecused to encode the payload of a request or a response.HttpMetaDataencoding(ContentCodec encoding)TheContentCodecused to encode the payload of a request or a response.booleanequals(java.lang.Object o)inthashCode()HttpHeadersheaders()Returns the headers of this message.abstract HttpPayloadWriter<Buffer>sendMetaData()Sends theHttpResponseMetaDataand returns anHttpPayloadWriterto continue writing the payload body.<T> HttpPayloadWriter<T>sendMetaData(HttpSerializer<T> serializer)Sends theHttpResponseMetaDatato the client and returns anHttpPayloadWriterof typeBlockingStreamingHttpServerResponseto continue writing a payload body.HttpOutputStreamsendMetaDataOutputStream()Sends theHttpResponseMetaDatato the client and returns anOutputStreamto continue writing a payload body.BlockingStreamingHttpServerResponsesetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.BlockingStreamingHttpServerResponsesetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.HttpResponseStatusstatus()Returns the status of thisStreamingHttpResponse.BlockingStreamingHttpServerResponsestatus(HttpResponseStatus status)Set the status of thisStreamingHttpResponse.java.lang.StringtoString()Returns a string representation of the message.HttpProtocolVersionversion()Returns the protocol version of thisHttpMetaData.BlockingStreamingHttpServerResponseversion(HttpProtocolVersion version)Set the protocol version of thisHttpMetaData.
-
-
-
Method Detail
-
sendMetaData
public abstract HttpPayloadWriter<Buffer> sendMetaData()
Sends theHttpResponseMetaDataand returns anHttpPayloadWriterto continue writing the payload body.Note: calling any other method on this class after calling this method is not allowed.
- Returns:
HttpPayloadWriterto 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 theHttpResponseMetaDatato the client and returns anHttpPayloadWriterof typeBlockingStreamingHttpServerResponseto 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:
HttpPayloadWriterto 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 theHttpResponseMetaDatato the client and returns anOutputStreamto continue writing a payload body.Note: calling any other method on this class after calling this method is not allowed.
- Returns:
HttpOutputStreamto 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:HttpMetaDataSet the protocol version of thisHttpMetaData.- Specified by:
versionin interfaceHttpMetaData- Specified by:
versionin interfaceHttpResponseMetaData- Parameters:
version- the protocol version to set.- Returns:
this.
-
status
public BlockingStreamingHttpServerResponse status(HttpResponseStatus status)
Description copied from interface:HttpResponseMetaDataSet the status of thisStreamingHttpResponse.- Specified by:
statusin interfaceHttpResponseMetaData- Parameters:
status- TheHttpResponseStatusto set.- Returns:
this.
-
addHeader
public BlockingStreamingHttpServerResponse addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaDataAdds a new header with the specifiednameandvalue.- 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:HttpMetaDataAdds all header names and values ofheadersobject.- Parameters:
headers- the headers to add.- Returns:
this.
-
setHeader
public BlockingStreamingHttpServerResponse 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.- 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:HttpMetaDataClears the current header entries and copies all header entries of the specifiedheadersobject.- Parameters:
headers- the headers object which contains new values.- Returns:
this.
-
addCookie
public BlockingStreamingHttpServerResponse addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaDataAdds a cookie.This may result in multiple
HttpCookiePairs 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: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.- 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:HttpMetaDataAdds a set-cookie.This may result in multiple
HttpSetCookies 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: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.- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
status
public final HttpResponseStatus status()
Description copied from interface:HttpResponseMetaDataReturns the status of thisStreamingHttpResponse.- Specified by:
statusin interfaceHttpResponseMetaData- Returns:
- The
HttpResponseStatusof thisStreamingHttpResponse
-
toString
public final java.lang.String toString()
Description copied from interface:HttpMetaDataReturns a string representation of the message. To avoid accidentally logging sensitive information, implementations should not return any header or content.- Specified by:
toStringin interfaceHttpMetaData- Overrides:
toStringin 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:HttpMetaDataReturns the protocol version of thisHttpMetaData.- Specified by:
versionin interfaceHttpMetaData- Returns:
- the version.
-
encoding
public HttpMetaData encoding(ContentCodec 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:
- Content-Encoding
-
encoding
public ContentCodec encoding()
Description copied from interface:HttpMetaDataReturns theContentCodecused to encode the payload of a request or a response.- Specified by:
encodingin interfaceHttpMetaData- Returns:
- The
ContentCodecused for the encoding of the payload. - See Also:
- Content-Encoding
-
headers
public final HttpHeaders headers()
Description copied from interface:HttpMetaDataReturns the headers of this message.- Specified by:
headersin interfaceHttpMetaData- Returns:
- the headers.
-
-