Package io.micronaut.http.poja.apache
Class ApacheServletHttpResponse<T>
java.lang.Object
io.micronaut.http.poja.PojaHttpResponse<T,org.apache.hc.core5.http.ClassicHttpResponse>
io.micronaut.http.poja.apache.ApacheServletHttpResponse<T>
- Type Parameters:
T
- The body type
- All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder
,io.micronaut.core.attr.MutableAttributeHolder
,io.micronaut.http.HttpMessage<T>
,io.micronaut.http.HttpResponse<T>
,io.micronaut.http.MutableHttpMessage<T>
,io.micronaut.http.MutableHttpResponse<T>
,ServletHttpResponse<org.apache.hc.core5.http.ClassicHttpResponse,
T>
@Internal
public final class ApacheServletHttpResponse<T>
extends PojaHttpResponse<T,org.apache.hc.core5.http.ClassicHttpResponse>
An implementation of the POJA HTTP response based on Apache.
- Since:
- 4.10.0
- Author:
- Andriy Dmytruk
-
Constructor Summary
ConstructorDescriptionApacheServletHttpResponse
(io.micronaut.core.convert.ConversionService conversionService) Create an Apache-based response. -
Method Summary
Modifier and TypeMethodDescription<B> io.micronaut.http.MutableHttpResponse<B>
body
(B body) int
code()
io.micronaut.http.MutableHttpResponse<T>
cookie
(io.micronaut.http.cookie.Cookie cookie) @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>
getBody()
io.micronaut.http.MutableHttpHeaders
org.apache.hc.core5.http.ClassicHttpResponse
Returns 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.reason()
io.micronaut.http.MutableHttpResponse<T>
status
(int code, CharSequence message) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.attr.AttributeHolder
getAttribute, getAttribute
Methods inherited from interface io.micronaut.http.HttpMessage
getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType, getLocale
Methods inherited from interface io.micronaut.http.HttpResponse
body, getCookie, getCookies, getStatus, header, setAttribute, status
Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder
removeAttribute
Methods inherited from interface io.micronaut.http.MutableHttpMessage
basicAuth, bearerAuth, bodyWriter
Methods inherited from interface io.micronaut.http.MutableHttpResponse
attribute, characterEncoding, characterEncoding, contentEncoding, contentLength, contentType, contentType, cookies, header, headers, headers, locale, status, status, status, toMutableResponse
Methods inherited from interface io.micronaut.servlet.http.ServletHttpResponse
stream
-
Constructor Details
-
ApacheServletHttpResponse
public ApacheServletHttpResponse(io.micronaut.core.convert.ConversionService conversionService) Create an Apache-based response.- Parameters:
conversionService
- The conversion service
-
-
Method Details
-
getNativeResponse
public org.apache.hc.core5.http.ClassicHttpResponse getNativeResponse()- Returns:
- The native response type.
-
getOutputStream
Description copied from interface:ServletHttpResponse
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, theServletHttpResponse.getWriter()
method is more appropriate.- Returns:
- The output stream
- Throws:
IOException
- if a validOutputStream
cannot be returned for some reason.
-
getWriter
Description copied from interface:ServletHttpResponse
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.
-
cookie
-
body
public <B> io.micronaut.http.MutableHttpResponse<B> body(@Nullable B body) -
getBody
-
status
-
code
public int code() -
reason
-
getHeaders
public io.micronaut.http.MutableHttpHeaders getHeaders() -
getAttributes
@NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()
-