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

    Constructors
    Constructor
    Description
    ApacheServletHttpResponse(io.micronaut.core.convert.ConversionService conversionService)
    Create an Apache-based response.
  • Method Summary

    Modifier and Type
    Method
    Description
    <B> io.micronaut.http.MutableHttpResponse<B>
    body(B body)
     
    int
     
    io.micronaut.http.MutableHttpResponse<T>
    cookie(io.micronaut.http.cookie.Cookie cookie)
     
    @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>
     
    @NonNull Optional<T>
     
    io.micronaut.http.MutableHttpHeaders
     
    org.apache.hc.core5.http.ClassicHttpResponse
     
    Returns an OutputStream that can be used to write the body of the response.
    Returns a BufferedWriter that can be used to write the text body of the response.
     
    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

      public OutputStream getOutputStream() throws IOException
      Description copied from interface: ServletHttpResponse
      Returns an 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.
      Returns:
      The output stream
      Throws:
      IOException - if a valid OutputStream cannot be returned for some reason.
    • getWriter

      public BufferedWriter getWriter() throws IOException
      Description copied from interface: ServletHttpResponse
      Returns a 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.
      Returns:
      The writer
      Throws:
      IOException - if a valid BufferedWriter cannot be returned for some reason.
    • cookie

      public io.micronaut.http.MutableHttpResponse<T> cookie(io.micronaut.http.cookie.Cookie cookie)
    • body

      public <B> io.micronaut.http.MutableHttpResponse<B> body(@Nullable B body)
    • getBody

      @NonNull public @NonNull Optional<T> getBody()
    • status

      public io.micronaut.http.MutableHttpResponse<T> status(int code, CharSequence message)
    • code

      public int code()
    • reason

      public String reason()
    • getHeaders

      public io.micronaut.http.MutableHttpHeaders getHeaders()
    • getAttributes

      @NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()