Top Description Fields Constructors Methods
io.netty.contrib.handler.codec.http.multipart

public Class DefaultHttpDataFactory

extends Object
implements HttpDataFactory
Class Inheritance
All Implemented Interfaces
io.netty.contrib.handler.codec.http.multipart.HttpDataFactory
Imports
io.netty5.handler.codec.http.DefaultHttpRequest, .HttpConstants, .HttpRequest, java.io.IOException, java.nio.charset.Charset, java.util.ArrayList, .Collections, .IdentityHashMap, .Iterator, .List, .Map, .Map.Entry

Default factory giving Attribute and FileUpload according to constructor.

According to the constructor, Attribute and FileUpload can be:

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 Summary

Modifier and TypeField and Description
private String
private Charset
private final boolean
private boolean
public static final long
MAXSIZE

Proposed default MAXSIZE = -1 as UNLIMITED

private long
public static final long
MINSIZE

Proposed default MINSIZE as 16 KB.

private long
private final Map<HttpRequest, List<HttpData>>
requestFileDeleteMap

Keep all HttpDatas until cleaning methods are called.

private final boolean

Constructor Summary

AccessConstructor and Description
public
DefaultHttpDataFactory()

HttpData will be in memory if less than default size (16KB).

public
public
DefaultHttpDataFactory(boolean useDisk)

HttpData will be always on Disk if useDisk is True, else always in Memory if False

public
DefaultHttpDataFactory(boolean useDisk, Charset charset)

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.

public
DefaultHttpDataFactory(long minSize, Charset charset)

Method Summary

Modifier and TypeMethod and Description
private static void
checkHttpDataSize(HttpData data)

Utility method

public void
cleanAllHttpData()

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanAllHttpData.

Remove all InterfaceHttpData from virtual File storage from clean list for all requests
public void
public void
cleanRequestHttpData(HttpRequest
associated request
request
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanRequestHttpData.

Remove all InterfaceHttpData from virtual File storage from clean list for the request
public void
public Attribute
public Attribute
createAttribute(HttpRequest
associated request
request
,
String
name of the attribute
name
,
long
defined size from request for this attribute
definedSize
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

public Attribute
public FileUpload
createFileUpload(HttpRequest
associated request
request
,
String name, String filename, String contentType, String contentTransferEncoding, Charset charset, long
the size of the Uploaded file
size
)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createFileUpload.

private List<HttpData>

Returns:

the associated list of HttpData for the request
getList
(HttpRequest request)

public void
removeHttpDataFromClean(HttpRequest
associated request
request
,
InterfaceHttpData data)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.removeHttpDataFromClean.

Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file is still a temporary one as setup at construction)
public void
setBaseDir(String
directory path where to store disk attributes and file uploads.
baseDir
)

Override global DiskAttribute#baseDirectory and DiskFileUpload#baseDirectory values.

public void
setDeleteOnExit(boolean
true if temporary files should be deleted with the JVM, false otherwise.
deleteOnExit
)

Override global DiskAttribute#deleteOnExitTemporaryFile and DiskFileUpload#deleteOnExitTemporaryFile values.

public void
setMaxLimit(long maxSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.setMaxLimit.

To set a max size limitation on fields.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseDirback to summary
private String baseDir
charsetback to summary
private Charset charset
checkSizeback to summary
private final boolean checkSize
deleteOnExitback to summary
private boolean deleteOnExit
MAXSIZEback to summary
public static final long MAXSIZE

Proposed default MAXSIZE = -1 as UNLIMITED

maxSizeback to summary
private long maxSize
MINSIZEback to summary
public static final long MINSIZE

Proposed default MINSIZE as 16 KB.

minSizeback to summary
private long minSize
requestFileDeleteMapback to summary
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. Similarly, when removing data items, we need to check their identities because different data items may be equal.

useDiskback to summary
private final boolean useDisk

Constructor Detail

DefaultHttpDataFactoryback to summary
public DefaultHttpDataFactory()

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

DefaultHttpDataFactoryback to summary
public DefaultHttpDataFactory(Charset charset)
DefaultHttpDataFactoryback to summary
public DefaultHttpDataFactory(boolean useDisk)

HttpData will be always on Disk if useDisk is True, else always in Memory if False

DefaultHttpDataFactoryback to summary
public DefaultHttpDataFactory(boolean useDisk, Charset charset)
DefaultHttpDataFactoryback to summary
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.

DefaultHttpDataFactoryback to summary
public DefaultHttpDataFactory(long minSize, Charset charset)

Method Detail

checkHttpDataSizeback to summary
private static void checkHttpDataSize(HttpData data)

Utility method

cleanAllHttpDataback to summary
public void cleanAllHttpData()

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanAllHttpData.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanAllHttpData.

Remove all InterfaceHttpData from virtual File storage from clean list for all requests

Annotations
@Override
cleanAllHttpDatasback to summary
public void cleanAllHttpDatas()

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanAllHttpDatas.

Annotations
@Override
cleanRequestHttpDataback to summary
public void cleanRequestHttpData(HttpRequest request)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanRequestHttpData.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanRequestHttpData.

Remove all InterfaceHttpData from virtual File storage from clean list for the request

Parameters
request:HttpRequest

associated request

Annotations
@Override
cleanRequestHttpDatasback to summary
public void cleanRequestHttpDatas(HttpRequest request)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.cleanRequestHttpDatas.

Annotations
@Override
createAttributeback to summary
public Attribute createAttribute(HttpRequest request, String name)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

Parameters
request:HttpRequest

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

associated request

Returns:Attribute

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

a new Attribute with no value

Annotations
@Override
createAttributeback to summary
public Attribute createAttribute(HttpRequest request, String name, long definedSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

Parameters
request:HttpRequest

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

associated request

name:String

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

name of the attribute

definedSize:long

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

defined size from request for this attribute

Returns:Attribute

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

a new Attribute with no value

Annotations
@Override
createAttributeback to summary
public Attribute createAttribute(HttpRequest request, String name, String value)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

Parameters
request:HttpRequest

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

associated request

Returns:Attribute

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createAttribute.

a new Attribute

Annotations
@Override
createFileUploadback to summary
public FileUpload createFileUpload(HttpRequest request, String name, String filename, String contentType, String contentTransferEncoding, Charset charset, long size)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createFileUpload.

Parameters
request:HttpRequest

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createFileUpload.

associated request

size:long

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createFileUpload.

the size of the Uploaded file

Returns:FileUpload

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.createFileUpload.

a new FileUpload

Annotations
@Override
getListback to summary
private List<HttpData> getList(HttpRequest request)
Returns:List<HttpData>

the associated list of HttpData for the request

removeHttpDataFromCleanback to summary
public void removeHttpDataFromClean(HttpRequest request, InterfaceHttpData data)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.removeHttpDataFromClean.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.removeHttpDataFromClean.

Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file is still a temporary one as setup at construction)

Parameters
request:HttpRequest

associated request

Annotations
@Override
setBaseDirback to summary
public void setBaseDir(String baseDir)

Override global DiskAttribute#baseDirectory and DiskFileUpload#baseDirectory values.

Parameters
baseDir:String

directory path where to store disk attributes and file uploads.

setDeleteOnExitback to summary
public void setDeleteOnExit(boolean deleteOnExit)

Override global DiskAttribute#deleteOnExitTemporaryFile and DiskFileUpload#deleteOnExitTemporaryFile values.

Parameters
deleteOnExit:boolean

true if temporary files should be deleted with the JVM, false otherwise.

setMaxLimitback to summary
public void setMaxLimit(long maxSize)

Implements io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.setMaxLimit.

Doc from io.netty.contrib.handler.codec.http.multipart.HttpDataFactory.setMaxLimit.

To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException. A value of -1 means no limitation (default).

Annotations
@Override