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:
DefaultServletHttpResponse
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 anOutputStreamthat can be used to write the body of the response.Returns aBufferedWriterthat 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, getAttributeMethods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocaleMethods inherited from interface io.micronaut.http.HttpResponse
body, code, getCookie, getCookies, getStatus, header, reason, setAttribute, statusMethods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttributeMethods inherited from interface io.micronaut.http.MutableHttpMessage
basicAuth, bearerAuth, bodyWriter, getHeadersMethods 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 anOutputStreamthat 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 validOutputStreamcannot be returned for some reason.IllegalStateException- ifgetWriter()has already been called on this instance.
-
getWriter
Returns aBufferedWriterthat 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 validBufferedWritercannot 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
-