Class MicronautHttpData<D extends io.netty.handler.codec.http.multipart.HttpData>

java.lang.Object
io.netty.util.AbstractReferenceCounted
io.micronaut.http.server.netty.MicronautHttpData<D>
Type Parameters:
D - This HttpData type, for return (D) this on various methods
All Implemented Interfaces:
io.netty.buffer.ByteBufHolder, io.netty.handler.codec.http.multipart.HttpData, io.netty.handler.codec.http.multipart.InterfaceHttpData, io.netty.util.ReferenceCounted, Comparable<io.netty.handler.codec.http.multipart.InterfaceHttpData>

@Internal public abstract sealed class MicronautHttpData<D extends io.netty.handler.codec.http.multipart.HttpData> extends io.netty.util.AbstractReferenceCounted implements io.netty.handler.codec.http.multipart.HttpData
Alternate HttpData implementation with some limited concurrency support. Only implements the features we actually need.
In most cases, we only access the HttpData on a single thread, with the standard get() and friends. However, if the user wants a reactive stream of data as it comes in, this class can release chunks of that data for concurrent access by the user (see pollChunk()).
This class moves data to disk dynamically once the configured threshold is reached.
  • Method Details

    • pollChunk

      public MicronautHttpData<D>.Chunk pollChunk()
      Get a chunk of data. The chunk will have a fixed content, it will not be amended with further input.
      Returns:
      The chunk, or null if this data is completed and all chunks have been polled.
    • toStream

      public InputStream toStream()
    • addContent

      public void addContent(io.netty.buffer.ByteBuf buffer, boolean last) throws IOException
      Specified by:
      addContent in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • deallocate

      protected void deallocate()
      Specified by:
      deallocate in class io.netty.util.AbstractReferenceCounted
    • setContent

      public void setContent(io.netty.buffer.ByteBuf buffer) throws IOException
      Specified by:
      setContent in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • getMaxSize

      public long getMaxSize()
      Specified by:
      getMaxSize in interface io.netty.handler.codec.http.multipart.HttpData
    • setMaxSize

      public void setMaxSize(long maxSize)
      Specified by:
      setMaxSize in interface io.netty.handler.codec.http.multipart.HttpData
    • checkSize

      public void checkSize(long newSize) throws IOException
      Specified by:
      checkSize in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • setContent

      public void setContent(File file) throws IOException
      Specified by:
      setContent in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • setContent

      public void setContent(InputStream inputStream) throws IOException
      Specified by:
      setContent in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • isCompleted

      public boolean isCompleted()
      Specified by:
      isCompleted in interface io.netty.handler.codec.http.multipart.HttpData
    • length

      public long length()
      Specified by:
      length in interface io.netty.handler.codec.http.multipart.HttpData
    • definedLength

      public long definedLength()
      Specified by:
      definedLength in interface io.netty.handler.codec.http.multipart.HttpData
    • delete

      public void delete()
      Specified by:
      delete in interface io.netty.handler.codec.http.multipart.HttpData
    • get

      public byte[] get() throws IOException
      Specified by:
      get in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • getByteBuf

      public io.netty.buffer.ByteBuf getByteBuf()
      Specified by:
      getByteBuf in interface io.netty.handler.codec.http.multipart.HttpData
    • getChunk

      public io.netty.buffer.ByteBuf getChunk(int length) throws IOException
      Specified by:
      getChunk in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • getString

      public String getString() throws IOException
      Specified by:
      getString in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • getString

      public String getString(Charset encoding) throws IOException
      Specified by:
      getString in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • setCharset

      public void setCharset(Charset charset)
      Specified by:
      setCharset in interface io.netty.handler.codec.http.multipart.HttpData
    • getCharset

      public Charset getCharset()
      Specified by:
      getCharset in interface io.netty.handler.codec.http.multipart.HttpData
    • renameTo

      public boolean renameTo(File dest) throws IOException
      Specified by:
      renameTo in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • isInMemory

      public boolean isInMemory()
      Specified by:
      isInMemory in interface io.netty.handler.codec.http.multipart.HttpData
    • getFile

      public File getFile() throws IOException
      Specified by:
      getFile in interface io.netty.handler.codec.http.multipart.HttpData
      Throws:
      IOException
    • content

      public io.netty.buffer.ByteBuf content()
      Specified by:
      content in interface io.netty.buffer.ByteBufHolder
    • copy

      public D copy()
      Specified by:
      copy in interface io.netty.buffer.ByteBufHolder
      Specified by:
      copy in interface io.netty.handler.codec.http.multipart.HttpData
    • duplicate

      public D duplicate()
      Specified by:
      duplicate in interface io.netty.buffer.ByteBufHolder
      Specified by:
      duplicate in interface io.netty.handler.codec.http.multipart.HttpData
    • retainedDuplicate

      public D retainedDuplicate()
      Specified by:
      retainedDuplicate in interface io.netty.buffer.ByteBufHolder
      Specified by:
      retainedDuplicate in interface io.netty.handler.codec.http.multipart.HttpData
    • replace

      public D replace(io.netty.buffer.ByteBuf content)
      Specified by:
      replace in interface io.netty.buffer.ByteBufHolder
      Specified by:
      replace in interface io.netty.handler.codec.http.multipart.HttpData
    • getName

      public String getName()
      Specified by:
      getName in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
    • touch

      public D touch(Object hint)
      Specified by:
      touch in interface io.netty.buffer.ByteBufHolder
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.HttpData
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
      Specified by:
      touch in interface io.netty.util.ReferenceCounted
    • compareTo

      public int compareTo(@NonNull @NonNull io.netty.handler.codec.http.multipart.InterfaceHttpData o)
      Specified by:
      compareTo in interface Comparable<D extends io.netty.handler.codec.http.multipart.HttpData>
    • retain

      public D retain()
      Specified by:
      retain in interface io.netty.buffer.ByteBufHolder
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.HttpData
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
      Specified by:
      retain in interface io.netty.util.ReferenceCounted
      Overrides:
      retain in class io.netty.util.AbstractReferenceCounted
    • retain

      public D retain(int increment)
      Specified by:
      retain in interface io.netty.buffer.ByteBufHolder
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.HttpData
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
      Specified by:
      retain in interface io.netty.util.ReferenceCounted
      Overrides:
      retain in class io.netty.util.AbstractReferenceCounted
    • touch

      public D touch()
      Specified by:
      touch in interface io.netty.buffer.ByteBufHolder
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.HttpData
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
      Specified by:
      touch in interface io.netty.util.ReferenceCounted
      Overrides:
      touch in class io.netty.util.AbstractReferenceCounted