Class PojaHttpRequest<B,REQ,RES>

java.lang.Object
io.micronaut.http.poja.PojaHttpRequest<B,REQ,RES>
Type Parameters:
B - The body type
REQ - The POJA request type
RES - The POJA response type
All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder, io.micronaut.core.attr.MutableAttributeHolder, io.micronaut.core.convert.ConversionServiceAware, io.micronaut.http.HttpMessage<B>, io.micronaut.http.HttpRequest<B>, io.micronaut.http.MutableHttpMessage<B>, io.micronaut.http.MutableHttpRequest<B>, io.micronaut.http.ServerHttpRequest<B>, ServletExchange<REQ,RES>, ServletHttpRequest<REQ,B>
Direct Known Subclasses:
ApacheServletHttpRequest

public abstract class PojaHttpRequest<B,REQ,RES> extends Object implements ServletHttpRequest<REQ,B>, io.micronaut.http.ServerHttpRequest<B>, ServletExchange<REQ,RES>, io.micronaut.http.MutableHttpRequest<B>
A base class for serverless POJA requests that provides a number of common methods to be reused for body and binding.
Since:
4.10.0
Author:
Andriy
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.micronaut.servlet.http.ServletHttpRequest

    ServletHttpRequest.AsyncExecution, ServletHttpRequest.AsyncExecutionCallback
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final io.micronaut.core.convert.value.MutableConvertibleValues<Object>
     
    protected final io.micronaut.http.codec.MediaTypeCodecRegistry
     
    protected final io.micronaut.core.convert.ConversionService
     
    static final io.micronaut.core.type.Argument<io.micronaut.core.convert.value.ConvertibleValues>
     
    protected final PojaHttpResponse<?,RES>
     

    Fields inherited from interface io.micronaut.http.HttpRequest

    SCHEME_HTTP, SCHEME_HTTPS
  • Constructor Summary

    Constructors
    Constructor
    Description
    PojaHttpRequest(io.micronaut.core.convert.ConversionService conversionService, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, PojaHttpResponse<?,RES> response)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract io.micronaut.http.body.ByteBody
     
    <T> T
    A utility method that allows consuming body.
    @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object>
     
    <T> @NonNull Optional<T>
    getBody(@NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
     
    protected io.micronaut.core.convert.value.ConvertibleMultiValues<CharSequence>
    A method used for retrieving form data.
    Returns an InputStream that can be used to read the body of this HTTP request.
    Returns a BufferedReader that can be used to read the text body of this HTTP request.
     
     
    boolean
    Whether the request body is a form.

    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.core.convert.ConversionServiceAware

    setConversionService

    Methods inherited from interface io.micronaut.http.HttpMessage

    getBody, getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType

    Methods inherited from interface io.micronaut.http.HttpRequest

    accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute

    Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder

    removeAttribute

    Methods inherited from interface io.micronaut.http.MutableHttpMessage

    bodyWriter

    Methods inherited from interface io.micronaut.http.MutableHttpRequest

    accept, accept, basicAuth, bearerAuth, body, contentEncoding, contentLength, contentType, contentType, cookie, cookies, getHeaders, getParameters, header, headers, headers, toMutableRequest, uri, uri

    Methods inherited from interface io.micronaut.servlet.http.ServletHttpRequest

    executeAsync, getContextPath, getNativeRequest, isAsyncSupported
  • Field Details

    • CONVERTIBLE_VALUES_ARGUMENT

      public static final io.micronaut.core.type.Argument<io.micronaut.core.convert.value.ConvertibleValues> CONVERTIBLE_VALUES_ARGUMENT
    • conversionService

      protected final io.micronaut.core.convert.ConversionService conversionService
    • codecRegistry

      protected final io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry
    • attributes

      protected final io.micronaut.core.convert.value.MutableConvertibleValues<Object> attributes
    • response

      protected final PojaHttpResponse<?,RES> response
  • Constructor Details

    • PojaHttpRequest

      public PojaHttpRequest(io.micronaut.core.convert.ConversionService conversionService, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, PojaHttpResponse<?,RES> response)
  • Method Details

    • byteBody

      public abstract io.micronaut.http.body.ByteBody byteBody()
      Specified by:
      byteBody in interface io.micronaut.http.ServerHttpRequest<B>
    • getAttributes

      @NonNull public @NonNull io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()
      Specified by:
      getAttributes in interface io.micronaut.core.attr.AttributeHolder
      Specified by:
      getAttributes in interface io.micronaut.http.HttpMessage<B>
      Specified by:
      getAttributes in interface io.micronaut.core.attr.MutableAttributeHolder
    • consumeBody

      public <T> T consumeBody(Function<InputStream,T> consumer)
      A utility method that allows consuming body.
      Type Parameters:
      T - The function return value
      Parameters:
      consumer - The method to consume the body
      Returns:
      The result
    • getBody

      @NonNull public <T> @NonNull Optional<T> getBody(@NonNull @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
      Specified by:
      getBody in interface io.micronaut.http.HttpMessage<B>
    • getFormData

      protected io.micronaut.core.convert.value.ConvertibleMultiValues<CharSequence> getFormData()
      A method used for retrieving form data. Can be overridden by specific implementations.
      Returns:
      The form data as multi-values.
    • getInputStream

      public InputStream getInputStream()
      Description copied from interface: ServletHttpRequest
      Returns an InputStream that can be used to read the body of this HTTP request. This method is typically used to read binary data. If the body is text, the ServletHttpRequest.getReader() method is more appropriate.
      Specified by:
      getInputStream in interface ServletHttpRequest<B,REQ>
      Returns:
      The input stream
    • getReader

      public BufferedReader getReader()
      Description copied from interface: ServletHttpRequest
      Returns a BufferedReader that can be used to read the text body of this HTTP request.
      Specified by:
      getReader in interface ServletHttpRequest<B,REQ>
      Returns:
      The reader
    • isFormSubmission

      public boolean isFormSubmission()
      Whether the request body is a form.
      Returns:
      Whether it is a form submission
    • getRequest

      public ServletHttpRequest<REQ,? super Object> getRequest()
      Specified by:
      getRequest in interface ServletExchange<B,REQ>
      Returns:
      The request object
    • getResponse

      public ServletHttpResponse<RES,?> getResponse()
      Specified by:
      getResponse in interface ServletExchange<B,REQ>
      Returns:
      The response object