B
- The response body@Internal public class NettyMutableHttpResponse<B> extends java.lang.Object implements MutableHttpResponse<B>, NettyHttpResponseBuilder
FullHttpResponse
.Modifier and Type | Field and Description |
---|---|
protected io.netty.handler.codec.http.FullHttpResponse |
nettyResponse |
Constructor and Description |
---|
NettyMutableHttpResponse(ConversionService conversionService) |
NettyMutableHttpResponse(io.netty.handler.codec.http.FullHttpResponse nettyResponse,
ConversionService conversionService) |
Modifier and Type | Method and Description |
---|---|
<T> MutableHttpResponse<T> |
body(T body)
Sets the body.
|
MutableHttpResponse<B> |
cookie(Cookie cookie)
Adds the specified cookie to the response.
|
MutableHttpResponse<B> |
cookies(java.util.Set<Cookie> cookies)
Adds the specified cookies to the response.
|
MutableConvertibleValues<java.lang.Object> |
getAttributes()
A
MutableConvertibleValues of the attributes for this HTTP message. |
java.util.Optional<B> |
getBody() |
<T> java.util.Optional<T> |
getBody(Argument<T> type)
Return the body as the given type.
|
<T1> java.util.Optional<T1> |
getBody(java.lang.Class<T1> type)
Return the body as the given type.
|
java.util.Optional<MediaType> |
getContentType()
The request or response content type.
|
MutableHttpHeaders |
getHeaders() |
io.netty.handler.codec.http.FullHttpResponse |
getNativeResponse() |
io.netty.handler.codec.http.cookie.ServerCookieEncoder |
getServerCookieEncoder() |
HttpStatus |
getStatus() |
boolean |
isStream() |
NettyMutableHttpResponse |
replace(io.netty.buffer.ByteBuf body) |
void |
setServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder serverCookieEncoder) |
MutableHttpResponse<B> |
status(HttpStatus status,
java.lang.CharSequence message)
Sets the response status.
|
io.netty.handler.codec.http.FullHttpResponse |
toFullHttpResponse()
Converts this object to a full http response.
|
io.netty.handler.codec.http.HttpResponse |
toHttpResponse()
Converts this object to the most appropriate http response type.
|
StreamedHttpResponse |
toStreamHttpResponse()
Converts this object to a streamed http response.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
characterEncoding, characterEncoding, contentEncoding, contentLength, contentType, contentType, header, headers, headers, locale, status, status, status
accepted, accepted, badRequest, badRequest, body, code, created, created, created, header, noContent, notAllowed, notAllowed, notAllowedGeneric, notFound, notFound, notModified, ok, ok, permanentRedirect, reason, redirect, seeOther, serverError, serverError, setAttribute, status, status, status, temporaryRedirect, unauthorized, unprocessableEntity, uri
basicAuth, bearerAuth
getCharacterEncoding, getContentLength, getLocale
removeAttribute
getAttribute, getAttribute
toHttpResponse, toStreamResponse
public NettyMutableHttpResponse(io.netty.handler.codec.http.FullHttpResponse nettyResponse, ConversionService conversionService)
nettyResponse
- The FullHttpResponse
conversionService
- The conversion servicepublic NettyMutableHttpResponse(ConversionService conversionService)
conversionService
- The conversion servicepublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.Optional<MediaType> getContentType()
HttpMessage
getContentType
in interface HttpMessage<B>
public MutableHttpHeaders getHeaders()
getHeaders
in interface HttpMessage<B>
getHeaders
in interface MutableHttpMessage<B>
HttpHeaders
objectpublic MutableConvertibleValues<java.lang.Object> getAttributes()
HttpMessage
A MutableConvertibleValues
of the attributes for this HTTP message.
Attributes are designed for internal data sharing and hence are isolated from headers and parameters which are client supplied
getAttributes
in interface AttributeHolder
getAttributes
in interface MutableAttributeHolder
getAttributes
in interface HttpMessage<B>
public HttpStatus getStatus()
getStatus
in interface HttpResponse<B>
public MutableHttpResponse<B> cookie(Cookie cookie)
MutableHttpResponse
cookie
in interface MutableHttpResponse<B>
cookie
- the Cookie to return to the clientpublic MutableHttpResponse<B> cookies(java.util.Set<Cookie> cookies)
MutableHttpResponse
cookies
in interface MutableHttpResponse<B>
cookies
- the Set of Cookies to return to the clientpublic java.util.Optional<B> getBody()
getBody
in interface HttpMessage<B>
public <T1> java.util.Optional<T1> getBody(java.lang.Class<T1> type)
HttpMessage
getBody
in interface HttpMessage<B>
T1
- The generic typetype
- The type of the bodyOptional
of the type or Optional.empty()
if the body cannot be returned as the given typepublic <T> java.util.Optional<T> getBody(Argument<T> type)
HttpMessage
getBody
in interface HttpMessage<B>
T
- The generic typetype
- The type of the bodyOptional
of the type or Optional.empty()
if the body cannot be returned as the given typepublic MutableHttpResponse<B> status(HttpStatus status, java.lang.CharSequence message)
MutableHttpResponse
status
in interface MutableHttpResponse<B>
status
- The statusmessage
- The messagepublic io.netty.handler.codec.http.FullHttpResponse getNativeResponse()
FullHttpResponse
public <T> MutableHttpResponse<T> body(@Nullable T body)
MutableHttpResponse
body
in interface MutableHttpMessage<B>
body
in interface MutableHttpResponse<B>
T
- The new body typebody
- The bodypublic NettyMutableHttpResponse replace(io.netty.buffer.ByteBuf body)
body
- The body to replacepublic io.netty.handler.codec.http.cookie.ServerCookieEncoder getServerCookieEncoder()
public void setServerCookieEncoder(io.netty.handler.codec.http.cookie.ServerCookieEncoder serverCookieEncoder)
serverCookieEncoder
- Server cookie encoder@NonNull public io.netty.handler.codec.http.FullHttpResponse toFullHttpResponse()
NettyHttpResponseBuilder
toFullHttpResponse
in interface NettyHttpResponseBuilder
@NonNull public StreamedHttpResponse toStreamHttpResponse()
NettyHttpResponseBuilder
toStreamHttpResponse
in interface NettyHttpResponseBuilder
@NonNull public io.netty.handler.codec.http.HttpResponse toHttpResponse()
NettyHttpResponseBuilder
toHttpResponse
in interface NettyHttpResponseBuilder
public boolean isStream()
isStream
in interface NettyHttpResponseBuilder