Class DefaultHttpDataFactory

java.lang.Object
io.netty.handler.codec.http.multipart.DefaultHttpDataFactory
All Implemented Interfaces:
HttpDataFactory

public class DefaultHttpDataFactory extends Object implements HttpDataFactory
Default factory giving Attribute and FileUpload according to constructor.

According to the constructor, Attribute and FileUpload can be:

  • MemoryAttribute, DiskAttribute or MixedAttribute
  • MemoryFileUpload, DiskFileUpload or MixedFileUpload
A good example of releasing HttpData once all work is done is as follow:

   for (InterfaceHttpData httpData: decoder.getBodyHttpDatas()) {
     httpData.release();
     factory.removeHttpDataFromClean(request, httpData);
   }
   factory.cleanAllHttpData();
   decoder.destroy();
  
  • Field Details

    • MINSIZE

      public static final long MINSIZE
      Proposed default MINSIZE as 16 KB.
      See Also:
    • MAXSIZE

      public static final long MAXSIZE
      Proposed default MAXSIZE = -1 as UNLIMITED
      See Also:
    • useDisk

      private final boolean useDisk
    • checkSize

      private final boolean checkSize
    • minSize

      private long minSize
    • maxSize

      private long maxSize
    • charset

      private Charset charset
    • baseDir

      private String baseDir
    • deleteOnExit

      private boolean deleteOnExit
    • requestFileDeleteMap

      private final Map<HttpRequest,List<HttpData>> requestFileDeleteMap
      Keep all HttpDatas until cleaning methods are called. We need to use IdentityHashMap because different requests may be equal. See DefaultHttpRequest.hashCode() and DefaultHttpRequest.equals(java.lang.Object). Similarly, when removing data items, we need to check their identities because different data items may be equal.
  • Constructor Details

    • DefaultHttpDataFactory

      public DefaultHttpDataFactory()
      HttpData will be in memory if less than default size (16KB). The type will be Mixed.
    • DefaultHttpDataFactory

      public DefaultHttpDataFactory(Charset charset)
    • DefaultHttpDataFactory

      public DefaultHttpDataFactory(boolean useDisk)
      HttpData will be always on Disk if useDisk is True, else always in Memory if False
    • DefaultHttpDataFactory

      public DefaultHttpDataFactory(boolean useDisk, Charset charset)
    • DefaultHttpDataFactory

      public DefaultHttpDataFactory(long minSize)
      HttpData will be on Disk if the size of the file is greater than minSize, else it will be in memory. The type will be Mixed.
    • DefaultHttpDataFactory

      public DefaultHttpDataFactory(long minSize, Charset charset)
  • Method Details