Class MultiByteHttpData

java.lang.Object
io.netty.util.AbstractReferenceCounted
io.netty.handler.codec.http.multipart.AbstractHttpData
org.jboss.resteasy.reactive.client.impl.multipart.MultiByteHttpData
All Implemented Interfaces:
io.netty.buffer.ByteBufHolder, io.netty.handler.codec.http.multipart.FileUpload, 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>

public class MultiByteHttpData extends io.netty.handler.codec.http.multipart.AbstractHttpData implements io.netty.handler.codec.http.multipart.FileUpload
A FileUpload implementation that is responsible for sending Multi<Byte> as a file in a multipart message. It is meant to be used by the PausableHttpPostRequestEncoder When created, MultiByteHttpData will subscribe to the underlying Multi and request BUFFER_SIZE of bytes. Before reading the next chunk of data with getChunk(int), the post encoder checks if data isReady(int) and if not, triggers suspend(int). That's because a chunk smaller than requested is treated as the end of input. Then, when the requested amount of bytes is ready, or the underlying Multi is completed, `resumption` is executed.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.handler.codec.http.multipart.InterfaceHttpData

    io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     

    Fields inherited from class io.netty.handler.codec.http.multipart.AbstractHttpData

    definedSize, size
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiByteHttpData(String name, String filename, String contentType, String contentTransferEncoding, Charset charset, io.smallrye.mutiny.Multi<Byte> content, Consumer<Throwable> errorHandler, io.vertx.core.Context context, Runnable resumption)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addContent(io.netty.buffer.ByteBuf buffer, boolean last)
     
    int
    compareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o)
     
    int
     
    io.netty.handler.codec.http.multipart.FileUpload
     
    void
     
    io.netty.handler.codec.http.multipart.FileUpload
     
    boolean
     
    byte[]
    get()
     
    io.netty.buffer.ByteBuf
     
    io.netty.buffer.ByteBuf
    getChunk(int toRead)

    NOTE: should only be invoked when isReady(int) returns true
     
     
     
     
    io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType
     
     
    getString(Charset encoding)
     
    int
     
    boolean
     
    boolean
    isReady(int chunkSize)
    check if it is possible to read the next chunk of data of a given size
    long
     
    boolean
    renameTo(File dest)
     
    io.netty.handler.codec.http.multipart.FileUpload
    replace(io.netty.buffer.ByteBuf content)
     
    io.netty.handler.codec.http.multipart.FileUpload
     
    io.netty.handler.codec.http.multipart.FileUpload
    retain(int increment)
     
    io.netty.handler.codec.http.multipart.FileUpload
     
    void
    setContent(io.netty.buffer.ByteBuf buffer)
     
    void
     
    void
    setContent(InputStream inputStream)
     
    void
    setContentTransferEncoding(String contentTransferEncoding)
     
    void
    setContentType(String contentType)
     
    void
    setFilename(String filename)
     
     
    io.netty.handler.codec.http.multipart.FileUpload
     
    io.netty.handler.codec.http.multipart.FileUpload
    touch(Object hint)
     

    Methods inherited from class io.netty.handler.codec.http.multipart.AbstractHttpData

    checkSize, content, deallocate, definedLength, getCharset, getMaxSize, getName, isCompleted, setCharset, setCompleted, setCompleted, setMaxSize

    Methods inherited from class io.netty.util.AbstractReferenceCounted

    refCnt, release, release, setRefCnt

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.netty.buffer.ByteBufHolder

    content

    Methods inherited from interface io.netty.handler.codec.http.multipart.HttpData

    checkSize, definedLength, getCharset, getMaxSize, isCompleted, setCharset, setMaxSize

    Methods inherited from interface io.netty.handler.codec.http.multipart.InterfaceHttpData

    getName

    Methods inherited from interface io.netty.util.ReferenceCounted

    refCnt, release, release
  • Field Details

  • Constructor Details

    • MultiByteHttpData

      public MultiByteHttpData(String name, String filename, String contentType, String contentTransferEncoding, Charset charset, io.smallrye.mutiny.Multi<Byte> content, Consumer<Throwable> errorHandler, io.vertx.core.Context context, Runnable resumption)
      Parameters:
      name - name of the parameter
      filename - file name
      contentType - content type
      contentTransferEncoding - "binary" for sending binary files
      charset - the charset
      content - the Multi to send
      errorHandler - error handler invoked when the Multi emits an exception
      context - Vertx context on which the data is sent
      resumption - the action to execute when the requested amount of bytes is ready, or the Multi is completed
  • Method Details

    • 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
    • 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
    • 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
    • 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
    • isReady

      public boolean isReady(int chunkSize)
      check if it is possible to read the next chunk of data of a given size
      Parameters:
      chunkSize - amount of bytes
      Returns:
      true if the requested amount of bytes is ready to be read or the Multi is completed, i.e. there will be no more bytes to read
    • getChunk

      public io.netty.buffer.ByteBuf getChunk(int toRead)

      NOTE: should only be invoked when isReady(int) returns true
      Specified by:
      getChunk in interface io.netty.handler.codec.http.multipart.HttpData
      Parameters:
      toRead - amount of bytes to read
      Returns:
      ByteBuf with the requested bytes
    • getString

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

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

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

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

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

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

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

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

      public io.netty.handler.codec.http.multipart.FileUpload 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.FileUpload
      Specified by:
      replace in interface io.netty.handler.codec.http.multipart.HttpData
    • retain

      public io.netty.handler.codec.http.multipart.FileUpload retain(int increment)
      Specified by:
      retain in interface io.netty.buffer.ByteBufHolder
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.FileUpload
      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.handler.codec.http.multipart.AbstractHttpData
    • retain

      public io.netty.handler.codec.http.multipart.FileUpload retain()
      Specified by:
      retain in interface io.netty.buffer.ByteBufHolder
      Specified by:
      retain in interface io.netty.handler.codec.http.multipart.FileUpload
      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.handler.codec.http.multipart.AbstractHttpData
    • touch

      public io.netty.handler.codec.http.multipart.FileUpload touch()
      Specified by:
      touch in interface io.netty.buffer.ByteBufHolder
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.FileUpload
      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
      Specified by:
      touch in class io.netty.handler.codec.http.multipart.AbstractHttpData
    • touch

      public io.netty.handler.codec.http.multipart.FileUpload touch(Object hint)
      Specified by:
      touch in interface io.netty.buffer.ByteBufHolder
      Specified by:
      touch in interface io.netty.handler.codec.http.multipart.FileUpload
      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
      Specified by:
      touch in class io.netty.handler.codec.http.multipart.AbstractHttpData
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(io.netty.handler.codec.http.multipart.InterfaceHttpData o)
      Specified by:
      compareTo in interface Comparable<io.netty.handler.codec.http.multipart.InterfaceHttpData>
    • compareTo

      public int compareTo(MultiByteHttpData o)
    • getHttpDataType

      public io.netty.handler.codec.http.multipart.InterfaceHttpData.HttpDataType getHttpDataType()
      Specified by:
      getHttpDataType in interface io.netty.handler.codec.http.multipart.InterfaceHttpData
    • getFilename

      public String getFilename()
      Specified by:
      getFilename in interface io.netty.handler.codec.http.multipart.FileUpload
    • setFilename

      public void setFilename(String filename)
      Specified by:
      setFilename in interface io.netty.handler.codec.http.multipart.FileUpload
    • setContentType

      public void setContentType(String contentType)
      Specified by:
      setContentType in interface io.netty.handler.codec.http.multipart.FileUpload
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface io.netty.handler.codec.http.multipart.FileUpload
    • getContentTransferEncoding

      public String getContentTransferEncoding()
      Specified by:
      getContentTransferEncoding in interface io.netty.handler.codec.http.multipart.FileUpload
    • setContentTransferEncoding

      public void setContentTransferEncoding(String contentTransferEncoding)
      Specified by:
      setContentTransferEncoding in interface io.netty.handler.codec.http.multipart.FileUpload
    • length

      public long length()
      Specified by:
      length in interface io.netty.handler.codec.http.multipart.HttpData
      Overrides:
      length in class io.netty.handler.codec.http.multipart.AbstractHttpData
    • toString

      public String toString()
      Overrides:
      toString in class Object