Class DefaultServletHttpRequest<B>

java.lang.Object
io.micronaut.core.convert.value.ConvertibleValuesMap<V>
io.micronaut.core.convert.value.MutableConvertibleValuesMap<Object>
io.micronaut.servlet.engine.DefaultServletHttpRequest<B>
Type Parameters:
B - The body type
All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder, io.micronaut.core.attr.MutableAttributeHolder, io.micronaut.core.convert.ConversionServiceAware, io.micronaut.core.convert.ConversionServiceProvider, io.micronaut.core.convert.value.ConvertibleValues<Object>, io.micronaut.core.convert.value.MutableConvertibleValues<Object>, io.micronaut.core.value.ValueResolver<CharSequence>, io.micronaut.http.FullHttpRequest<B>, io.micronaut.http.HttpMessage<B>, io.micronaut.http.HttpRequest<B>, ParsedBodyHolder<B>, ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>, ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>, StreamedServletMessage<B,byte[]>, Iterable<Map.Entry<String,Object>>, org.reactivestreams.Publisher<byte[]>

@Internal public final class DefaultServletHttpRequest<B> extends io.micronaut.core.convert.value.MutableConvertibleValuesMap<Object> implements ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>, io.micronaut.core.convert.value.MutableConvertibleValues<Object>, ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>, StreamedServletMessage<B,byte[]>, io.micronaut.http.FullHttpRequest<B>, ParsedBodyHolder<B>
Implementation of HttpRequest ontop of the Servlet API.
Since:
1.0.0
Author:
graemerocher
  • Constructor Details

    • DefaultServletHttpRequest

      protected DefaultServletHttpRequest(io.micronaut.core.convert.ConversionService conversionService, jakarta.servlet.http.HttpServletRequest delegate, jakarta.servlet.http.HttpServletResponse response, io.micronaut.http.codec.MediaTypeCodecRegistry codecRegistry, BodyBuilder bodyBuilder)
      Default constructor.
      Parameters:
      conversionService - The servlet request
      delegate - The servlet request
      response - The servlet response
      codecRegistry - The codec registry
      bodyBuilder - Body Builder
  • Method Details

    • getConversionService

      public io.micronaut.core.convert.ConversionService getConversionService()
      Specified by:
      getConversionService in interface io.micronaut.core.convert.ConversionServiceProvider
      Specified by:
      getConversionService in interface io.micronaut.core.convert.value.ConvertibleValues<B>
    • getCodecRegistry

      public io.micronaut.http.codec.MediaTypeCodecRegistry getCodecRegistry()
      Returns:
      The codec registry.
    • isAsyncSupported

      public boolean isAsyncSupported()
      Description copied from interface: ServletHttpRequest
      Checks if this request supports asynchronous operation.

      Asynchronous operation is disabled for this request if this request is within the scope of a filter or servlet that has not been annotated or flagged in the deployment descriptor as being able to support asynchronous handling.

      Specified by:
      isAsyncSupported in interface ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>
      Returns:
      true if this request supports asynchronous operation, false otherwise
    • executeAsync

      public void executeAsync(ServletHttpRequest.AsyncExecutionCallback asyncExecutionCallback)
      Description copied from interface: ServletHttpRequest
      Causes the container to dispatch a thread, possibly from a managed thread pool, to run the specified ServletHttpRequest.AsyncExecutionCallback. After the execution is complete ServletHttpRequest.AsyncExecution.complete() should be called.
      Specified by:
      executeAsync in interface ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>
      Parameters:
      asyncExecutionCallback - The response publisher
    • getBody

      @NonNull public <T> @NonNull Optional<T> getBody(@NonNull @NonNull io.micronaut.core.type.Argument<T> arg)
      Specified by:
      getBody in interface io.micronaut.http.HttpMessage<B>
    • getUserPrincipal

      @NonNull public @NonNull Optional<Principal> getUserPrincipal()
      Specified by:
      getUserPrincipal in interface io.micronaut.http.HttpRequest<B>
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface io.micronaut.http.HttpRequest<B>
    • getContentType

      @NonNull public @NonNull Optional<io.micronaut.http.MediaType> getContentType()
      Specified by:
      getContentType in interface io.micronaut.http.HttpMessage<B>
    • getContentLength

      public long getContentLength()
      Specified by:
      getContentLength in interface io.micronaut.http.HttpMessage<B>
    • getRemoteAddress

      @NonNull public @NonNull InetSocketAddress getRemoteAddress()
      Specified by:
      getRemoteAddress in interface io.micronaut.http.HttpRequest<B>
    • getServerAddress

      @NonNull public @NonNull InetSocketAddress getServerAddress()
      Specified by:
      getServerAddress in interface io.micronaut.http.HttpRequest<B>
    • getServerName

      @Nullable public @Nullable String getServerName()
      Specified by:
      getServerName in interface io.micronaut.http.HttpRequest<B>
    • getLocale

      @NonNull public @NonNull Optional<Locale> getLocale()
      Specified by:
      getLocale in interface io.micronaut.http.HttpMessage<B>
      Specified by:
      getLocale in interface io.micronaut.http.HttpRequest<B>
    • getCharacterEncoding

      @NonNull public @NonNull Charset getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface io.micronaut.http.HttpMessage<B>
    • getContextPath

      public String getContextPath()
      Specified by:
      getContextPath in interface ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>
      Returns:
      The context path of the request.
    • getInputStream

      public InputStream getInputStream() throws IOException
      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<jakarta.servlet.http.HttpServletRequest,B>
      Returns:
      The input stream
      Throws:
      IOException - if a valid InputStream cannot be returned for some reason.
    • getReader

      public BufferedReader getReader() throws IOException
      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<jakarta.servlet.http.HttpServletRequest,B>
      Returns:
      The reader
      Throws:
      IOException - if a valid BufferedReader cannot be returned for some reason.
    • getNativeRequest

      public jakarta.servlet.http.HttpServletRequest getNativeRequest()
      Specified by:
      getNativeRequest in interface ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,B>
      Returns:
      The native request type
    • getCookies

      @NonNull public @NonNull io.micronaut.http.cookie.Cookies getCookies()
      Specified by:
      getCookies in interface io.micronaut.http.HttpRequest<B>
    • getParameters

      @NonNull public @NonNull io.micronaut.http.HttpParameters getParameters()
      Specified by:
      getParameters in interface io.micronaut.http.HttpRequest<B>
    • mutate

      public io.micronaut.http.MutableHttpRequest<B> mutate()
      Specified by:
      mutate in interface io.micronaut.http.HttpRequest<B>
    • getMethod

      @NonNull public @NonNull io.micronaut.http.HttpMethod getMethod()
      Specified by:
      getMethod in interface io.micronaut.http.HttpRequest<B>
    • getMethodName

      @NonNull public @NonNull String getMethodName()
      Specified by:
      getMethodName in interface io.micronaut.http.HttpRequest<B>
    • getUri

      @NonNull public @NonNull URI getUri()
      Specified by:
      getUri in interface io.micronaut.http.HttpRequest<B>
    • getHeaders

      @NonNull public @NonNull io.micronaut.http.HttpHeaders getHeaders()
      Specified by:
      getHeaders in interface io.micronaut.http.HttpMessage<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
    • setParsedBody

      public void setParsedBody(B body)
      Description copied from interface: ParsedBodyHolder
      Set the parsed body.
      Specified by:
      setParsedBody in interface ParsedBodyHolder<B>
      Parameters:
      body - the parsed body
    • getBody

      @NonNull public @NonNull Optional<B> getBody()
      Specified by:
      getBody in interface io.micronaut.http.HttpMessage<B>
    • put

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> put(CharSequence key, @Nullable @Nullable Object value)
      Specified by:
      put in interface io.micronaut.core.convert.value.MutableConvertibleValues<B>
      Overrides:
      put in class io.micronaut.core.convert.value.MutableConvertibleValuesMap<Object>
    • getRequest

      public ServletHttpRequest<jakarta.servlet.http.HttpServletRequest,? super Object> getRequest()
      Specified by:
      getRequest in interface ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>
      Returns:
      The request object
    • getResponse

      public ServletHttpResponse<jakarta.servlet.http.HttpServletResponse,?> getResponse()
      Specified by:
      getResponse in interface ServletExchange<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpServletResponse>
      Returns:
      The response object
    • subscribe

      public void subscribe(org.reactivestreams.Subscriber<? super byte[]> s)
      Specified by:
      subscribe in interface org.reactivestreams.Publisher<B>
    • isFull

      public boolean isFull()
      Specified by:
      isFull in interface io.micronaut.http.FullHttpRequest<B>
    • contents

      public io.micronaut.core.io.buffer.ByteBuffer<?> contents()
      Specified by:
      contents in interface io.micronaut.http.FullHttpRequest<B>
    • bufferContents

      public io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>> bufferContents()
      Specified by:
      bufferContents in interface io.micronaut.http.FullHttpRequest<B>