Package io.micronaut.servlet.http
Interface ServletHttpResponse<N,B>
- Type Parameters:
N
- The native response typeB
- The body type
- All Superinterfaces:
io.micronaut.core.attr.AttributeHolder
,io.micronaut.http.HttpMessage<B>
,io.micronaut.http.HttpResponse<B>
,io.micronaut.core.attr.MutableAttributeHolder
,io.micronaut.http.MutableHttpMessage<B>
,io.micronaut.http.MutableHttpResponse<B>
- All Known Implementing Classes:
ApacheServletHttpResponse
,DefaultServletHttpResponse
,PojaHttpResponse
public interface ServletHttpResponse<N,B>
extends io.micronaut.http.MutableHttpResponse<B>
Models a serverless HTTP response, allowing access to the native response.
- Since:
- 2.0.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptionReturns anOutputStream
that can be used to write the body of the response.Returns aBufferedWriter
that can be used to write the text body of the response.default org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>>
stream
(org.reactivestreams.Publisher<?> dataPublisher) Streams data using the given data publisher.Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocale
Methods inherited from interface io.micronaut.http.HttpResponse
body, code, getCookie, getCookies, getStatus, header, reason, setAttribute, status
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
basicAuth, bearerAuth, bodyWriter, getHeaders
Methods inherited from interface io.micronaut.http.MutableHttpResponse
attribute, body, characterEncoding, characterEncoding, contentEncoding, contentLength, contentType, contentType, cookie, cookies, header, headers, headers, locale, status, status, status, status, toMutableResponse
-
Method Details
-
getNativeResponse
N getNativeResponse()- Returns:
- The native response type.
-
getOutputStream
Returns anOutputStream
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, thegetWriter()
method is more appropriate.- Returns:
- The output stream
- Throws:
IOException
- if a validOutputStream
cannot be returned for some reason.IllegalStateException
- ifgetWriter()
has already been called on this instance.
-
getWriter
Returns aBufferedWriter
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 callingMutableHttpResponse.contentEncoding(CharSequence)
before calling this method.- Returns:
- The writer
- Throws:
IOException
- if a validBufferedWriter
cannot be returned for some reason.IllegalStateException
- ifgetOutputStream()
has already been called on this instance.
-
stream
default org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> stream(org.reactivestreams.Publisher<?> dataPublisher) Streams data using the given data publisher.- Parameters:
dataPublisher
- The data publisher- Returns:
- Emits the response once the stream has completed
-