BodyParser class
Handles parsing of HTTP request bodies.
Supports JSON, form data, multipart data, and file uploads. Implements caching and concurrent request handling for optimal performance.
Constructors
- BodyParser(HttpRequest _raw, {int maxBodySize = defaultMaxBodySize})
Properties
-
body
→ Map<
String, dynamic> ? -
Gets parsed body.
no setter
-
files
→ Map<
String, UploadedFile> ? -
Gets uploaded files.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxBodySize → int
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
add(
String key, dynamic value) → void - Adds or updates a value in the parsed body.
-
cleanup(
) → Future< void> - Cleans up temporary files.
-
clearCache(
) → void - Clears cached data.
-
file(
String fieldName) → UploadedFile? - Gets a specific file.
-
filesByName(
String fieldName) → List< UploadedFile> - Gets all files with a field name.
-
firstFile(
String fieldName) → UploadedFile? - Gets first file by field name.
-
has(
String key) → bool - Checks if a key exists.
-
hasFile(
String fieldName) → bool - Checks if a file was uploaded.
-
input(
String key, [dynamic defaultValue]) → dynamic - Gets a specific input value.
-
merge(
Map< String, dynamic> values) → void - Merges a map into the parsed body.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
) → Future< Map< String, dynamic> > - Parses and returns the request body as a Map. Caches results to avoid re-parsing.
-
remove(
String key) → void - Removes a value from the parsed body.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultMaxBodySize → const int