Package io.vertx.ext.web.handler
Interface BodyHandler
-
- All Superinterfaces:
Handler<RoutingContext>
public interface BodyHandler extends Handler<RoutingContext>
A handler which gathers the entire request body and sets it on theRoutingContext.It also handles HTTP file uploads and can be used to limit body sizes.
- Author:
- Tim Fox
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_BODY_LIMITDefault max size for a request body in bytes =10485760, i.e. 10 megabytesstatic booleanDEFAULT_DELETE_UPLOADED_FILES_ON_ENDDefault value of whether uploaded files should be removed after handling the requeststatic booleanDEFAULT_MERGE_FORM_ATTRIBUTESDefault value of whether form attributes should be merged into request paramsstatic booleanDEFAULT_PREALLOCATE_BODY_BUFFERDefault value of whether to pre-allocate the body buffer size according to the content-length HTTP request headerstatic StringDEFAULT_UPLOADS_DIRECTORYDefault uploads directory on server for file uploads
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static BodyHandlercreate()Create a body handler with defaults.static BodyHandlercreate(boolean handleFileUploads)Create a body handler setting if it should handle file uploads.static BodyHandlercreate(String uploadDirectory)Create a body handler and use the given upload directory.BodyHandlersetBodyLimit(long bodyLimit)Set the maximum body size in bytes,-1means no limit.BodyHandlersetDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd)Set whether uploaded files should be removed after handling the request.BodyHandlersetHandleFileUploads(boolean handleFileUploads)Set whether file uploads will be handled.BodyHandlersetMergeFormAttributes(boolean mergeFormAttributes)Set whether form attributes will be added to the request parameters.BodyHandlersetPreallocateBodyBuffer(boolean isPreallocateBodyBuffer)Pre-allocate the body buffer according to the value parsed from content-length header.BodyHandlersetUploadsDirectory(String uploadsDirectory)Set the uploads directory to use.
-
-
-
Field Detail
-
DEFAULT_BODY_LIMIT
static final long DEFAULT_BODY_LIMIT
Default max size for a request body in bytes =10485760, i.e. 10 megabytes- See Also:
- Constant Field Values
-
DEFAULT_UPLOADS_DIRECTORY
static final String DEFAULT_UPLOADS_DIRECTORY
Default uploads directory on server for file uploads- See Also:
- Constant Field Values
-
DEFAULT_MERGE_FORM_ATTRIBUTES
static final boolean DEFAULT_MERGE_FORM_ATTRIBUTES
Default value of whether form attributes should be merged into request params- See Also:
- Constant Field Values
-
DEFAULT_DELETE_UPLOADED_FILES_ON_END
static final boolean DEFAULT_DELETE_UPLOADED_FILES_ON_END
Default value of whether uploaded files should be removed after handling the request- See Also:
- Constant Field Values
-
DEFAULT_PREALLOCATE_BODY_BUFFER
static final boolean DEFAULT_PREALLOCATE_BODY_BUFFER
Default value of whether to pre-allocate the body buffer size according to the content-length HTTP request header- See Also:
- Constant Field Values
-
-
Method Detail
-
create
static BodyHandler create()
Create a body handler with defaults.- Returns:
- the body handler
-
create
static BodyHandler create(boolean handleFileUploads)
Create a body handler setting if it should handle file uploads.- Parameters:
handleFileUploads- true if files upload should be handled- Returns:
- the body handler
-
create
static BodyHandler create(String uploadDirectory)
Create a body handler and use the given upload directory.- Parameters:
uploadDirectory- the uploads directory- Returns:
- the body handler
-
setHandleFileUploads
BodyHandler setHandleFileUploads(boolean handleFileUploads)
Set whether file uploads will be handled.- Parameters:
handleFileUploads- true if they should be handled- Returns:
- reference to this for fluency
-
setBodyLimit
BodyHandler setBodyLimit(long bodyLimit)
Set the maximum body size in bytes,-1means no limit.- Parameters:
bodyLimit- the max size in bytes- Returns:
- reference to this for fluency
-
setUploadsDirectory
BodyHandler setUploadsDirectory(String uploadsDirectory)
Set the uploads directory to use.- Parameters:
uploadsDirectory- the uploads directory- Returns:
- reference to this for fluency
-
setMergeFormAttributes
BodyHandler setMergeFormAttributes(boolean mergeFormAttributes)
Set whether form attributes will be added to the request parameters.- Parameters:
mergeFormAttributes- true if they should be merged- Returns:
- reference to this for fluency
-
setDeleteUploadedFilesOnEnd
BodyHandler setDeleteUploadedFilesOnEnd(boolean deleteUploadedFilesOnEnd)
Set whether uploaded files should be removed after handling the request.- Parameters:
deleteUploadedFilesOnEnd- true if uploaded files should be removed after handling the request- Returns:
- reference to this for fluency
-
setPreallocateBodyBuffer
BodyHandler setPreallocateBodyBuffer(boolean isPreallocateBodyBuffer)
Pre-allocate the body buffer according to the value parsed from content-length header. The buffer is capped at 64KB- Parameters:
isPreallocateBodyBuffer-trueif body buffer is pre-allocated according to the size read from content-length Header. {code false} if body buffer is pre-allocated to 1KB, and is resized dynamically- Returns:
- reference to this for fluency
-
-