B
- The body type@Internal public class DefaultServletHttpResponse<B> extends java.lang.Object implements ServletHttpResponse<javax.servlet.http.HttpServletResponse,B>
ServletHttpResponse
for the Servlet API.Modifier | Constructor and Description |
---|---|
protected |
DefaultServletHttpResponse(DefaultServletHttpRequest request,
javax.servlet.http.HttpServletResponse delegate)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> io.micronaut.http.MutableHttpResponse<T> |
body(T body) |
io.micronaut.http.MutableHttpResponse<B> |
contentLength(long length) |
io.micronaut.http.MutableHttpResponse<B> |
contentType(java.lang.CharSequence contentType) |
io.micronaut.http.MutableHttpResponse<B> |
contentType(io.micronaut.http.MediaType mediaType) |
io.micronaut.http.MutableHttpResponse<B> |
cookie(io.micronaut.http.cookie.Cookie cookie) |
io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> |
getAttributes() |
java.util.Optional<B> |
getBody() |
java.util.Optional<io.micronaut.http.MediaType> |
getContentType() |
io.micronaut.http.MutableHttpHeaders |
getHeaders() |
javax.servlet.http.HttpServletResponse |
getNativeResponse() |
java.io.OutputStream |
getOutputStream()
Returns an
OutputStream that can be used to write the body of the response. |
io.micronaut.http.HttpStatus |
getStatus() |
java.io.BufferedWriter |
getWriter()
Returns a
BufferedWriter that can be used to write the text body of the response. |
io.micronaut.http.MutableHttpResponse<B> |
header(java.lang.CharSequence name,
java.lang.CharSequence value) |
io.micronaut.http.MutableHttpResponse<B> |
locale(java.util.Locale locale) |
io.micronaut.http.MutableHttpResponse<B> |
status(io.micronaut.http.HttpStatus status) |
io.micronaut.http.MutableHttpResponse<B> |
status(io.micronaut.http.HttpStatus status,
java.lang.CharSequence message) |
io.micronaut.http.MutableHttpResponse<B> |
status(int status) |
io.micronaut.http.MutableHttpResponse<B> |
status(int status,
java.lang.CharSequence message) |
org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> |
stream(org.reactivestreams.Publisher<?> dataPublisher)
Streams data using the given data publisher.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
attribute, characterEncoding, characterEncoding, contentEncoding, cookies, headers, headers
accepted, accepted, badRequest, badRequest, body, code, created, created, created, getCookie, getCookies, header, noContent, notAllowed, notAllowed, notAllowedGeneric, notFound, notFound, notModified, ok, ok, permanentRedirect, reason, redirect, seeOther, serverError, serverError, setAttribute, status, status, status, temporaryRedirect, unauthorized, unprocessableEntity, uri
protected DefaultServletHttpResponse(DefaultServletHttpRequest request, javax.servlet.http.HttpServletResponse delegate)
request
- The servlet requestdelegate
- The servlet responsepublic org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> stream(org.reactivestreams.Publisher<?> dataPublisher)
ServletHttpResponse
stream
in interface ServletHttpResponse<javax.servlet.http.HttpServletResponse,B>
dataPublisher
- The data publisher@NonNull public java.util.Optional<io.micronaut.http.MediaType> getContentType()
getContentType
in interface io.micronaut.http.HttpMessage<B>
public io.micronaut.http.MutableHttpResponse<B> contentType(java.lang.CharSequence contentType)
public io.micronaut.http.MutableHttpResponse<B> contentType(io.micronaut.http.MediaType mediaType)
public io.micronaut.http.MutableHttpResponse<B> contentLength(long length)
public io.micronaut.http.MutableHttpResponse<B> locale(java.util.Locale locale)
locale
in interface io.micronaut.http.MutableHttpResponse<B>
public io.micronaut.http.MutableHttpResponse<B> header(java.lang.CharSequence name, java.lang.CharSequence value)
public io.micronaut.http.MutableHttpResponse<B> status(int status)
status
in interface io.micronaut.http.MutableHttpResponse<B>
public io.micronaut.http.MutableHttpResponse<B> status(int status, java.lang.CharSequence message)
status
in interface io.micronaut.http.MutableHttpResponse<B>
public io.micronaut.http.MutableHttpResponse<B> status(io.micronaut.http.HttpStatus status)
status
in interface io.micronaut.http.MutableHttpResponse<B>
public javax.servlet.http.HttpServletResponse getNativeResponse()
getNativeResponse
in interface ServletHttpResponse<javax.servlet.http.HttpServletResponse,B>
public java.io.OutputStream getOutputStream() throws java.io.IOException
ServletHttpResponse
OutputStream
that can be used to write the body of the response.
This method is typically used to write binary data. If the body is text, the
ServletHttpResponse.getWriter()
method is more appropriate.getOutputStream
in interface ServletHttpResponse<javax.servlet.http.HttpServletResponse,B>
java.io.IOException
- if a valid OutputStream
cannot be returned for some reason.public java.io.BufferedWriter getWriter() throws java.io.IOException
ServletHttpResponse
BufferedWriter
that can be used to write the text body of the response.
If the written text will not be US-ASCII, you should specify a character encoding by calling
MutableHttpResponse.contentEncoding(CharSequence)
before calling this method.getWriter
in interface ServletHttpResponse<javax.servlet.http.HttpServletResponse,B>
java.io.IOException
- if a valid BufferedWriter
cannot be returned for some reason.public io.micronaut.http.MutableHttpResponse<B> cookie(io.micronaut.http.cookie.Cookie cookie)
cookie
in interface io.micronaut.http.MutableHttpResponse<B>
@NonNull public io.micronaut.http.MutableHttpHeaders getHeaders()
@NonNull public io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> getAttributes()
getAttributes
in interface io.micronaut.core.attr.AttributeHolder
getAttributes
in interface io.micronaut.core.attr.MutableAttributeHolder
getAttributes
in interface io.micronaut.http.HttpMessage<B>
@NonNull public java.util.Optional<B> getBody()
getBody
in interface io.micronaut.http.HttpMessage<B>
public <T> io.micronaut.http.MutableHttpResponse<T> body(@Nullable T body)
public io.micronaut.http.MutableHttpResponse<B> status(io.micronaut.http.HttpStatus status, java.lang.CharSequence message)
status
in interface io.micronaut.http.MutableHttpResponse<B>
public io.micronaut.http.HttpStatus getStatus()
getStatus
in interface io.micronaut.http.HttpResponse<B>