Class ImmediateByteBody

java.lang.Object
io.micronaut.http.server.netty.body.ImmediateByteBody
All Implemented Interfaces:
ByteBody, HttpBody

@Internal public final class ImmediateByteBody extends Object implements ByteBody
Fully buffered ByteBody, all operations are eager.
Since:
4.0.0
  • Method Details

    • processMulti

      public MultiObjectBody processMulti(FormDataHttpContentProcessor processor) throws Throwable
      Description copied from interface: ByteBody
      Process this body using the given processor.
      Only used for form processing now.
      Specified by:
      processMulti in interface ByteBody
      Parameters:
      processor - The processor to apply
      Returns:
      The new processed body
      Throws:
      Throwable - Any exception thrown by the processor. Not all processing failures may throw immediately, however
    • rawContent

      public ImmediateSingleObjectBody rawContent(io.micronaut.http.server.HttpServerConfiguration configuration) throws io.micronaut.http.exceptions.ContentLengthExceededException
      Description copied from interface: ByteBody
      Transform this body to a MultiObjectBody containing ByteBufs with the raw body. There is a check against HttpServerConfiguration.getMaxRequestSize().
      Specified by:
      rawContent in interface ByteBody
      Parameters:
      configuration - The configuration for request size limits
      Returns:
      The body containing ByteBufs
      Throws:
      io.micronaut.http.exceptions.ContentLengthExceededException - If the content length exceeds the configured request size. May also appear delayed for StreamingMultiObjectBody
    • processSingle

      public ImmediateSingleObjectBody processSingle(FormDataHttpContentProcessor processor, Charset defaultCharset, io.netty.buffer.ByteBufAllocator alloc) throws Throwable
      Process this body and then transform it into a single object using ImmediateMultiObjectBody.single(java.nio.charset.Charset, io.netty.buffer.ByteBufAllocator).
      Only used for form processing now.
      Parameters:
      processor - The processor
      defaultCharset - The default charset (see ImmediateMultiObjectBody.single(java.nio.charset.Charset, io.netty.buffer.ByteBufAllocator))
      alloc - The buffer allocator (see ImmediateMultiObjectBody.single(java.nio.charset.Charset, io.netty.buffer.ByteBufAllocator))
      Returns:
      The processed object
      Throws:
      Throwable - Any failure
    • processSingle

      public <T> ImmediateSingleObjectBody processSingle(io.micronaut.http.server.HttpServerConfiguration configuration, io.micronaut.http.body.MessageBodyReader<T> reader, io.micronaut.core.type.Argument<T> type, io.micronaut.http.MediaType mediaType, io.micronaut.core.type.Headers httpHeaders)
      Process this body using the given MessageBodyReader.
      Type Parameters:
      T - The type to parse to
      Parameters:
      configuration - The server configuration. Used for checking body length restrictions
      reader - The reader
      type - The type to parse to
      mediaType - The request media type
      httpHeaders - The request headers
      Returns:
      The parsed value
    • buffer

      public io.micronaut.core.execution.ExecutionFlow<ImmediateByteBody> buffer(io.netty.buffer.ByteBufAllocator alloc)
      Description copied from interface: ByteBody
      Fully buffer this body.
      Specified by:
      buffer in interface ByteBody
      Parameters:
      alloc - The allocator for storage
      Returns:
      A flow that completes when all data has been read
    • contentUnclaimed

      public io.netty.buffer.ByteBuf contentUnclaimed()
    • claimForReuse

      public io.netty.handler.codec.http.HttpRequest claimForReuse(io.netty.handler.codec.http.HttpRequest request)
      Description copied from interface: ByteBody
      Claim this body and convert it back to a HttpRequest. This is used for proxying, where the request received by the server is reused by the client.
      Specified by:
      claimForReuse in interface ByteBody
      Parameters:
      request - The input request (headers and such)
      Returns:
      The request including the body, either a FullHttpRequest or a StreamedHttpRequest
    • empty

      public boolean empty()
    • release

      public final void release()
      Description copied from interface: HttpBody
      Release this body and any downstream representations.
      Specified by:
      release in interface HttpBody
    • next

      @Nullable public @Nullable HttpBody next()
      Description copied from interface: HttpBody
      Get the next representation this body was transformed into, if any.
      Specified by:
      next in interface HttpBody
      Returns:
      The next representation, or null if this body has not been transformed