Interface ServletHttpResponse<N,B>

Type Parameters:
N - The native response type
B - 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 Type
    Method
    Description
     
    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.
    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

      OutputStream getOutputStream() throws IOException
      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 getWriter() method is more appropriate.
      Returns:
      The output stream
      Throws:
      IOException - if a valid OutputStream cannot be returned for some reason.
      IllegalStateException - if getWriter() has already been called on this instance.
    • getWriter

      BufferedWriter getWriter() throws IOException
      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.
      IllegalStateException - if getOutputStream() 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