Top Inners Fields Constructors Methods
io.undertow.server.handlers.form

public Class MultiPartParserDefinition

extends Object
implements FormParserFactory.ParserDefinition<MultiPartParserDefinition>
Class Inheritance
All Implemented Interfaces
io.undertow.server.handlers.form.FormParserFactory.ParserDefinition
Imports
io.undertow.UndertowLogger, .UndertowMessages, .UndertowOptions, io.undertow.server.ExchangeCompletionListener, .HttpHandler, .HttpServerExchange, io.undertow.util.HeaderMap, .Headers, .MalformedMessageException, .MultipartParser, .SameThreadExecutor, .StatusCodes, org.xnio.ChannelListener, .IoUtils, io.undertow.connector.PooledByteBuffer, org.xnio.channels.StreamSourceChannel, java.io.ByteArrayOutputStream, .FileOutputStream, .IOException, .InputStream, .UnsupportedEncodingException, java.nio.ByteBuffer, java.nio.channels.FileChannel, java.nio.charset.StandardCharsets, java.nio.file.Files, .LinkOption, .NoSuchFileException, .Path, .Paths, java.nio.file.attribute.FileAttribute, java.util.ArrayList, .Arrays, .LinkedList, .List, java.util.concurrent.Executor

Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private class

Field Summary

Modifier and TypeField and Description
private String
private Executor
private long
fieldSizeThreshold

The threshold of form field size to persist to disk.

private long
private long
private static final long
MINSIZE

Proposed default MINSIZE as 16 KB for content in memory before persisting to disk if file content exceeds fileSizeThreshold and the filename is not specified in the form.

public static final String
private Path

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public FormDataParser
public String
public Executor
public long
public Path
public MultiPartParserDefinition
public MultiPartParserDefinition
setExecutor(final Executor executor)

public MultiPartParserDefinition
setFieldSizeThreshold(long fieldSizeThreshold)

public void
setFileSizeThreshold(long fileSizeThreshold)

public void
setMaxIndividualFileSize(final long maxIndividualFileSize)

public MultiPartParserDefinition
setTempFileLocation(Path tempFileLocation)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultEncodingback to summary
private String defaultEncoding
executorback to summary
private Executor executor
fieldSizeThresholdback to summary
private long fieldSizeThreshold

The threshold of form field size to persist to disk. It takes effect only for the form fields which do not have filename specified.

fileSizeThresholdback to summary
private long fileSizeThreshold
maxIndividualFileSizeback to summary
private long maxIndividualFileSize
MINSIZEback to summary
private static final long MINSIZE

Proposed default MINSIZE as 16 KB for content in memory before persisting to disk if file content exceeds fileSizeThreshold and the filename is not specified in the form.

MULTIPART_FORM_DATAback to summary
public static final String MULTIPART_FORM_DATA
tempFileLocationback to summary
private Path tempFileLocation

Constructor Detail

MultiPartParserDefinitionback to summary
public MultiPartParserDefinition()
MultiPartParserDefinitionback to summary
public MultiPartParserDefinition(final Path tempDir)

Method Detail

createback to summary
public FormDataParser create(final HttpServerExchange exchange)

Implements io.undertow.server.handlers.form.FormParserFactory.ParserDefinition.create.

Annotations
@Override
getDefaultEncodingback to summary
public String getDefaultEncoding()
getExecutorback to summary
public Executor getExecutor()
getMaxIndividualFileSizeback to summary
public long getMaxIndividualFileSize()
getTempFileLocationback to summary
public Path getTempFileLocation()
setDefaultEncodingback to summary
public MultiPartParserDefinition setDefaultEncoding(final String defaultEncoding)

Implements io.undertow.server.handlers.form.FormParserFactory.ParserDefinition.setDefaultEncoding.

setExecutorback to summary
public MultiPartParserDefinition setExecutor(final Executor executor)
setFieldSizeThresholdback to summary
public MultiPartParserDefinition setFieldSizeThreshold(long fieldSizeThreshold)
setFileSizeThresholdback to summary
public void setFileSizeThreshold(long fileSizeThreshold)
setMaxIndividualFileSizeback to summary
public void setMaxIndividualFileSize(final long maxIndividualFileSize)
setTempFileLocationback to summary
public MultiPartParserDefinition setTempFileLocation(Path tempFileLocation)
io.undertow.server.handlers.form back to summary

public Class MultiPartParserDefinition.FileTooLargeException

extends IOException
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
public
public
public

Constructor Detail

FileTooLargeExceptionback to summary
public FileTooLargeException()
FileTooLargeExceptionback to summary
public FileTooLargeException(String message)
FileTooLargeExceptionback to summary
public FileTooLargeException(String message, Throwable cause)
FileTooLargeExceptionback to summary
public FileTooLargeException(Throwable cause)
io.undertow.server.handlers.form back to summary

private final Class MultiPartParserDefinition.MultiPartUploadHandler

extends Object
implements FormDataParser, PartHandler
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.form.MultiPartParserDefinition.MultiPartUploadHandler
All Implemented Interfaces
io.undertow.util.MultipartParser.PartHandler, io.undertow.server.handlers.form.FormDataParser, java.io.Closeable, java.lang.AutoCloseable

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final ByteArrayOutputStream
private final List<Path>
private long
private String
private final FormData
private String
private final HttpServerExchange
private final long
private Path
private FileChannel
private String
private final long
private HttpHandler
private HeaderMap
private final long
private final MultipartParser.ParseState

Constructor Summary

AccessConstructor and Description
private
MultiPartUploadHandler(final HttpServerExchange exchange, final String boundary, final long maxIndividualFileSize, final long fileSizeThreshold, final String defaultEncoding, final long fieldSizeThreshold)

Method Summary

Modifier and TypeMethod and Description
public void
public void
close()

Implements io.undertow.server.handlers.form.FormDataParser.close.

Closes the parser, and removes and temporary files that may have been created.

private Path
public void
public void
private String
public List<Path>
public void
parse(final HttpHandler handler)

Implements io.undertow.server.handlers.form.FormDataParser.parse.

Parse the form data asynchronously.

public FormData
parseBlocking()

Implements io.undertow.server.handlers.form.FormDataParser.parseBlocking.

Parse the data, blocking the current thread until parsing is complete.

public void
setCharacterEncoding(final String
The encoding
encoding
)

Implements io.undertow.server.handlers.form.FormDataParser.setCharacterEncoding.

Sets the character encoding that will be used by this parser.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentBytesback to summary
private final ByteArrayOutputStream contentBytes
createdFilesback to summary
private final List<Path> createdFiles
currentFileSizeback to summary
private long currentFileSize
currentNameback to summary
private String currentName
databack to summary
private final FormData data
defaultEncodingback to summary
private String defaultEncoding
exchangeback to summary
private final HttpServerExchange exchange
fieldSizeThresholdback to summary
private final long fieldSizeThreshold
fileback to summary
private Path file
fileChannelback to summary
private FileChannel fileChannel
fileNameback to summary
private String fileName
fileSizeThresholdback to summary
private final long fileSizeThreshold
handlerback to summary
private HttpHandler handler
headersback to summary
private HeaderMap headers
maxIndividualFileSizeback to summary
private final long maxIndividualFileSize
parserback to summary
private final MultipartParser.ParseState parser

Constructor Detail

MultiPartUploadHandlerback to summary
private MultiPartUploadHandler(final HttpServerExchange exchange, final String boundary, final long maxIndividualFileSize, final long fileSizeThreshold, final String defaultEncoding, final long fieldSizeThreshold)

Method Detail

beginPartback to summary
public void beginPart(final HeaderMap headers)

Implements io.undertow.util.MultipartParser.PartHandler.beginPart.

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements io.undertow.server.handlers.form.FormDataParser.close.

Doc from io.undertow.server.handlers.form.FormDataParser.close.

Closes the parser, and removes and temporary files that may have been created.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

createFileback to summary
private Path createFile() throws IOException
databack to summary
public void data(final ByteBuffer buffer) throws IOException

Implements io.undertow.util.MultipartParser.PartHandler.data.

Annotations
@Override
endPartback to summary
public void endPart()

Implements io.undertow.util.MultipartParser.PartHandler.endPart.

Annotations
@Override
getCharsetback to summary
private String getCharset()
getCreatedFilesback to summary
public List<Path> getCreatedFiles()
parseback to summary
public void parse(final HttpHandler handler) throws Exception

Implements io.undertow.server.handlers.form.FormDataParser.parse.

Doc from io.undertow.server.handlers.form.FormDataParser.parse.

Parse the form data asynchronously. If all the data cannot be read immediately then a read listener will be registered, and the data will be parsed by the read thread.

When this method completes the handler will be invoked, and the data will be attached under FORM_DATA.

The method can either invoke the next handler directly, or may delegate to the IO thread to perform the parsing.

Annotations
@Override
parseBlockingback to summary
public FormData parseBlocking() throws IOException

Implements io.undertow.server.handlers.form.FormDataParser.parseBlocking.

Doc from io.undertow.server.handlers.form.FormDataParser.parseBlocking.

Parse the data, blocking the current thread until parsing is complete. For blocking handlers this method is more efficient than parse(io.undertow.server.HttpHandler next), as the calling thread should do that actual parsing, rather than the read thread

Returns:FormData

The parsed form data

Annotations
@Override
Exceptions
IOException:
If the data could not be read
setCharacterEncodingback to summary
public void setCharacterEncoding(final String encoding)

Implements io.undertow.server.handlers.form.FormDataParser.setCharacterEncoding.

Doc from io.undertow.server.handlers.form.FormDataParser.setCharacterEncoding.

Sets the character encoding that will be used by this parser. If the request is already processed this will have no effect

Parameters
encoding:String

The encoding

Annotations
@Override
io.undertow.server.handlers.form back to summary

private final Class MultiPartParserDefinition.MultiPartUploadHandler.NonBlockingParseTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.form.MultiPartParserDefinition.MultiPartUploadHandler.NonBlockingParseTask
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final Executor
private final StreamSourceChannel

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
private final Executor executor
requestChannelback to summary
private final StreamSourceChannel requestChannel

Constructor Detail

NonBlockingParseTaskback to summary
private NonBlockingParseTask(Executor executor, StreamSourceChannel requestChannel)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override