Single file uploads = complete

This commit is contained in:
thosakwe 2016-04-17 15:51:40 -04:00
parent 1f37cd1b70
commit 5c0ee725d1
8 changed files with 245 additions and 157 deletions

2
.gitignore vendored
View file

@ -7,7 +7,7 @@
*.iml
## Directory-based project format:
.idea/
.idea
/Test Results - Run_All_Tests.html
# if you remove the above rule, at least ignore the following:

View file

@ -5,318 +5,318 @@
<entry key="analyzer">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
</list>
</value>
</entry>
<entry key="args">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
</list>
</value>
</entry>
<entry key="async">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
</list>
</value>
</entry>
<entry key="barback">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
</list>
</value>
</entry>
<entry key="boolean_selector">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
</list>
</value>
</entry>
<entry key="charcode">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
</list>
</value>
</entry>
<entry key="collection">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
</list>
</value>
</entry>
<entry key="convert">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
</list>
</value>
</entry>
<entry key="crypto">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
</list>
</value>
</entry>
<entry key="csslib">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
</list>
</value>
</entry>
<entry key="glob">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
</list>
</value>
</entry>
<entry key="html">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
</list>
</value>
</entry>
<entry key="http">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
</list>
</value>
</entry>
<entry key="http_multi_server">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
</list>
</value>
</entry>
<entry key="http_parser">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
</list>
</value>
</entry>
<entry key="json_god">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
</list>
</value>
</entry>
<entry key="logging">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
</list>
</value>
</entry>
<entry key="matcher">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
</list>
</value>
</entry>
<entry key="mime">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
</list>
</value>
</entry>
<entry key="package_config">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
</list>
</value>
</entry>
<entry key="path">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
</list>
</value>
</entry>
<entry key="plugin">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
</list>
</value>
</entry>
<entry key="pool">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
</list>
</value>
</entry>
<entry key="pub_semver">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
</list>
</value>
</entry>
<entry key="shelf">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
</list>
</value>
</entry>
<entry key="shelf_static">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
</list>
</value>
</entry>
<entry key="shelf_web_socket">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
</list>
</value>
</entry>
<entry key="source_map_stack_trace">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
</list>
</value>
</entry>
<entry key="source_maps">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
</list>
</value>
</entry>
<entry key="source_span">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
</list>
</value>
</entry>
<entry key="stack_trace">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
</list>
</value>
</entry>
<entry key="stream_channel">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
</list>
</value>
</entry>
<entry key="string_scanner">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
</list>
</value>
</entry>
<entry key="test">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
</list>
</value>
</entry>
<entry key="typed_data">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
</list>
</value>
</entry>
<entry key="utf">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
</list>
</value>
</entry>
<entry key="watcher">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
</list>
</value>
</entry>
<entry key="web_socket_channel">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
</list>
</value>
</entry>
<entry key="yaml">
<value>
<list>
<option value="$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
<option value="$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
</list>
</value>
</entry>
</option>
</properties>
<CLASSES>
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
<root url="file://$USER_HOME$/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/analyzer-0.27.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/args-0.13.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/async-1.10.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/barback-0.15.2+7/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/collection-1.5.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/convert-1.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/crypto-1.0.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/csslib-0.12.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/glob-1.1.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/html-0.12.2+1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http-0.11.3+3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/http_parser-2.2.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/json_god-1.0.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/logging-0.11.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.0+2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/mime-0.9.3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/package_config-0.1.3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/path-1.3.9/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/plugin-0.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pool-1.2.3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.2.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf-0.6.5/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_static-0.2.3+3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_map_stack_trace-1.0.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_maps-0.10.1+1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/source_span-1.2.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.6.5/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.3.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/string_scanner-0.1.4+1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/test-0.12.13/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/utf-0.9.0+3/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.0.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dartlang.org/yaml-2.1.8/lib" />
</CLASSES>
<SOURCES />
</library>

View file

@ -3,7 +3,8 @@
**NOT YET PRODUCTION READY**
Parse request bodies and query strings in Dart. No external dependencies required.
Parse request bodies and query strings in Dart, as well multipart/form-data uploads. No external
dependencies required.
### Contents
@ -17,7 +18,7 @@ Parse request bodies and query strings in Dart. No external dependencies require
I needed something like Express.js's `body-parser` module, so I made it here. It fully supports JSON requests.
x-www-form-urlencoded fully supported, as well as query strings. You can also include arrays in your query,
in the same way you would for a PHP application. File upload support will also be present by the production 1.0.0 release.
in the same way you would for a PHP application. Full file upload support will also be present by the production 1.0.0 release.
A benefit of this is that primitive types are automatically deserialized correctly. As in, if you have a `hello=1.5` request, then
`body['hello']` will equal `1.5` and not `'1.5'`. A very semantic difference, yes, but it relieves stress in my head.

View file

@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Results &mdash; Run All Tests</title>
<title>Test Results &mdash; All Tests</title>
<style type="text/css">
html {
height: 100%
@ -572,8 +572,8 @@ jQuery.cookie = function(name, value, options) {
<body>
<div id="container">
<div id="header">
<div class="time">1.05 s</div>
<h1>Run All Tests: <strong><span class="total">6 total, </span><span class="passed">6 passed</span></strong>
<div class="time">1.86 s</div>
<h1>All Tests: <strong><span class="total">8 total, </span><span class="ignored">1 ignored, </span><span class="passed">7 passed</span></strong>
</h1>
<div id="treecontrol">
<ul>
@ -589,38 +589,60 @@ jQuery.cookie = function(name, value, options) {
</div>
<div id="content">
<ul id="tree">
<li xmlns="" class="level top open">
<li xmlns="" class="level top ignored open">
<span><em class="time">
<div class="time">1.05 s</div>
</em>all_tests.dart</span>
<ul>
<li class="level suite open">
<span><em class="time">
<div class="time">1.05 s</div>
<div class="time">1.86 s</div>
</em>Test server support</span>
<ul>
<li class="level suite open">
<span><em class="time">
<div class="time">779 ms</div>
<div class="time">1.03 s</div>
</em>query string</span>
<ul>
<li class="level test">
<span><em class="time">
<div class="time">680 ms</div>
<div class="time">910 ms</div>
</em><em class="status">passed</em>GET Simple</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55407<br/>GET http://localhost:55407/?hello=world<br/>Response: {&quot;body&quot;:{},&quot;query&quot;:{&quot;hello&quot;:&quot;world&quot;}}<br/></span>
<span class="stdout">Test server listening on http://localhost:45244<br/>GET http://localhost:45244/?hello=world<br/>Response: {&quot;body&quot;:{},&quot;query&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;files&quot;:[]}<br/></span>
</li>
</ul>
</li>
<li class="level test">
<span><em class="time">
<div class="time">99 ms</div>
<div class="time">121 ms</div>
</em><em class="status">passed</em>GET Complex</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55409<br/>Body: hello=world&amp;nums%5B%5D=1&amp;nums%5B%5D=2.0&amp;nums%5B%5D=2&amp;map.foo.bar=baz<br/>Response: {&quot;body&quot;:{},&quot;query&quot;:{&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}}}<br/></span>
<span class="stdout">Test server listening on http://localhost:54627<br/>Body: hello=world&amp;nums%5B%5D=1&amp;nums%5B%5D=2.0&amp;nums%5B%5D=2&amp;map.foo.bar=baz<br/>Response: {&quot;body&quot;:{},&quot;query&quot;:{&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}},&quot;files&quot;:[]}<br/></span>
</li>
</ul>
</li>
</ul>
</li>
<li class="level suite open">
<span><em class="time">
<div class="time">454 ms</div>
</em>urlencoded</span>
<ul>
<li class="level test">
<span><em class="time">
<div class="time">334 ms</div>
</em><em class="status">passed</em>POST Simple</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:38381<br/>Body: hello=world<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;query&quot;:{},&quot;files&quot;:[]}<br/></span>
</li>
</ul>
</li>
<li class="level test">
<span><em class="time">
<div class="time">120 ms</div>
</em><em class="status">passed</em>Post Complex</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:52437<br/></span>
</li>
</ul>
</li>
@ -629,57 +651,48 @@ jQuery.cookie = function(name, value, options) {
<li class="level suite open">
<span><em class="time">
<div class="time">195 ms</div>
</em>urlencoded</span>
<ul>
<li class="level test">
<span><em class="time">
<div class="time">162 ms</div>
</em><em class="status">passed</em>POST Simple</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55411<br/>Body: hello=world<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;query&quot;:{}}<br/></span>
</li>
</ul>
</li>
<li class="level test">
<span><em class="time">
<div class="time">33 ms</div>
</em><em class="status">passed</em>Post Complex</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55413<br/></span>
</li>
</ul>
</li>
</ul>
</li>
<li class="level suite open">
<span><em class="time">
<div class="time">74 ms</div>
</em>JSON</span>
<ul>
<li class="level test">
<span><em class="time">
<div class="time">31 ms</div>
<div class="time">83 ms</div>
</em><em class="status">passed</em>Post Simple</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55415<br/>Body: {&quot;hello&quot;:&quot;world&quot;}<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;query&quot;:{}}<br/></span>
<span class="stdout">Test server listening on http://localhost:59756<br/>Body: {&quot;hello&quot;:&quot;world&quot;}<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;query&quot;:{},&quot;files&quot;:[]}<br/></span>
</li>
</ul>
</li>
<li class="level test">
<span><em class="time">
<div class="time">43 ms</div>
<div class="time">112 ms</div>
</em><em class="status">passed</em>Post Complex</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55417<br/>Body: {&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}}<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}},&quot;query&quot;:{}}<br/></span>
<span class="stdout">Test server listening on http://localhost:39215<br/>Body: {&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}}<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;,&quot;nums&quot;:[1,2.0,2],&quot;map&quot;:{&quot;foo&quot;:{&quot;bar&quot;:&quot;baz&quot;}}},&quot;query&quot;:{},&quot;files&quot;:[]}<br/></span>
</li>
</ul>
</li>
</ul>
</li>
<li class="level suite ignored open">
<span><em class="time">
<div class="time">181 ms</div>
</em>File</span>
<ul>
<li class="level test">
<span><em class="time">
<div class="time">181 ms</div>
</em><em class="status">passed</em>Single upload</span>
<ul>
<li class="text">
<span class="stdout">Test server listening on http://localhost:55740<br/>Form Data: <br/> <br/>----myBoundary <br/>Content-Disposition: form-data; name=&quot;hello&quot; <br/>world <br/>----myBoundary <br/>Content-Disposition: file; name=&quot;file&quot;; filename=&quot;app.dart&quot; <br/>Content-Type: text/plain <br/>Hello world <br/>----myBoundary--<br/>Response: {&quot;body&quot;:{&quot;hello&quot;:&quot;world&quot;},&quot;query&quot;:{},&quot;files&quot;:[{&quot;mimeType&quot;:&quot;text/plain&quot;,&quot;name&quot;:&quot;file&quot;,&quot;filename&quot;:&quot;app.dart&quot;,&quot;data&quot;:[72,101,108,108,111,32,119,111,114,108,100]}]}<br/></span>
</li>
</ul>
</li>
<li class="level test ignored open">
<span><em class="time"></em><em class="status">ignored</em>Multiple upload</span>
</li>
</ul>
</li>
</ul>
@ -688,7 +701,7 @@ jQuery.cookie = function(name, value, options) {
</div>
</div>
<div id="footer">
<p>Generated by WebStorm on 4/16/16 11:06 PM</p>
<p>Generated by WebStorm on 4/17/16 3:43 PM</p>
</div>
</body>
</html>

View file

@ -5,6 +5,8 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
part 'file_upload_info.dart';
/// A representation of data from an incoming request.
class BodyParseResult {
/// The parsed body.
@ -14,13 +16,17 @@ class BodyParseResult {
Map query = {};
/// All files uploaded within this request.
List<Map> files = [];
List<FileUploadInfo> files = [];
}
/// Grabs data from an incoming request.
///
/// Supports urlencoded and JSON.
Future<BodyParseResult> parseBody(HttpRequest request) async {
/// Supports urlencoded and JSON, as well as multipart/form-data uploads.
/// On a file upload request, only fields with the name **'file'** are processed
/// as files. Anything else is put in the body. You can change the upload file name
/// via the *fileUploadName* parameter. :)
Future<BodyParseResult> parseBody(HttpRequest request,
{String fileUploadName: 'file'}) async {
BodyParseResult result = new BodyParseResult();
ContentType contentType = request.headers.contentType;
@ -45,14 +51,16 @@ Future<BodyParseResult> parseBody(HttpRequest request) async {
// Accept file
if (contentType != null && request.method == 'POST') {
RegExp parseBoundaryRgx = new RegExp(
r'^multipart\/form-data;\s*boundary=(.+)$');
r'multipart\/form-data;\s*boundary=([^\s;]+)');
if (parseBoundaryRgx.hasMatch(contentType.toString())) {
Match boundaryMatch = parseBoundaryRgx.firstMatch(contentType.toString());
String boundary = boundaryMatch.group(1);
String body = await request.transform(UTF8.decoder).join();
for (String chunk in body.split(boundaryMatch.group(1))) {
var fileData = getFileDataFromChunk(chunk);
for (String chunk in body.split(boundary)) {
var fileData = getFileDataFromChunk(
chunk, boundary, fileUploadName, result.body);
if (fileData != null)
result.files.add(fileData);
fileData.forEach((x) => result.files.add(x));
}
}
}
@ -61,18 +69,41 @@ Future<BodyParseResult> parseBody(HttpRequest request) async {
}
/// Parses file data from a multipart/form-data chunk.
Map getFileDataFromChunk(String chunk) {
Map result = {};
List<FileUploadInfo> getFileDataFromChunk(String chunk, String boundary, String fileUploadName,
Map body) {
FileUploadInfo result = new FileUploadInfo();
RegExp isFormDataRgx = new RegExp(
r'Content-Dispositition:\s*form-data;\s*name="([^"]+)"');
r'Content-Disposition:\s*([^;]+);\s*name="([^"]+)"');
if (isFormDataRgx.hasMatch(chunk)) {
result['name'] = isFormDataRgx.firstMatch(chunk).group(1);
Match formDataMatch = isFormDataRgx.firstMatch(chunk);
String disposition = formDataMatch.group(1);
String name = formDataMatch.group(2);
String restOfChunk = chunk.substring(formDataMatch.end);
RegExp contentTypeRgx = new RegExp(r'Content-Type:\s*([^\n]+)');
if (contentTypeRgx.hasMatch(chunk)) {
result['type'] = contentTypeRgx.firstMatch(chunk).group(1);
return result;
RegExp parseFilenameRgx = new RegExp(r'filename="([^"]+)"');
if (parseFilenameRgx.hasMatch(chunk)) {
result.filename = parseFilenameRgx.firstMatch(chunk).group(1);
}
RegExp contentTypeRgx = new RegExp(r'Content-Type:\s*([^\r\n]+)\r\n');
if (contentTypeRgx.hasMatch(restOfChunk)) {
Match contentTypeMatch = contentTypeRgx.firstMatch(restOfChunk);
restOfChunk = restOfChunk.substring(contentTypeMatch.end);
result.mimeType = contentTypeMatch.group(1);
} else restOfChunk = restOfChunk.replaceAll(new RegExp(r'^(\r\n)+'), "");
restOfChunk = restOfChunk
.replaceAll(boundary, "")
.replaceFirst(new RegExp(r'\r\n$'), "");
if (disposition == 'file' && name == fileUploadName) {
result.name = name;
result.data = UTF8.encode(restOfChunk);
return [result];
} else {
buildMapFromUri(body, "$name=$restOfChunk");
return null;
}
}

15
lib/file_upload_info.dart Normal file
View file

@ -0,0 +1,15 @@
part of body_parser;
/// Represents a file uploaded to the server.
class FileUploadInfo {
/// The MIME type of the uploaded file.
String mimeType;
/// The name of the file field from the request.
String name;
/// The filename of the file.
String filename;
/// The bytes that make up this file.
List<int> data;
FileUploadInfo({this.mimeType, this.name, this.filename, this.data: const []}) {}
}

View file

@ -1,7 +1,8 @@
name: body_parser
author: Tobe O <thosakwe@gmail.com>
version: 1.0.0-beta
version: 1.0.0-dev
description: Parse request bodies and query strings in Dart.
homepage: https://github.com/thosakwe/body_parser
dev_dependencies:
http: any
json_god: any

View file

@ -38,7 +38,8 @@ main() {
print('GET $url/?hello=world');
var response = await client.get('$url/?hello=world');
print('Response: ${response.body}');
expect(response.body, equals('{"body":{},"query":{"hello":"world"},"files":[]}'));
expect(response.body,
equals('{"body":{},"query":{"hello":"world"},"files":[]}'));
});
test('GET Complex', () async {
@ -64,7 +65,8 @@ main() {
var response = await client.post(
url, headers: headers, body: 'hello=world');
print('Response: ${response.body}');
expect(response.body, equals('{"body":{"hello":"world"},"query":{},"files":[]}'));
expect(response.body,
equals('{"body":{"hello":"world"},"query":{},"files":[]}'));
});
test('Post Complex', () async {
@ -91,7 +93,8 @@ main() {
var response = await client.post(
url, headers: headers, body: postData);
print('Response: ${response.body}');
expect(response.body, equals('{"body":{"hello":"world"},"query":{},"files":[]}'));
expect(response.body,
equals('{"body":{"hello":"world"},"query":{},"files":[]}'));
});
test('Post Complex', () async {
@ -121,21 +124,45 @@ main() {
Map headers = {
HttpHeaders.CONTENT_TYPE: 'multipart/form-data; boundary=$boundary'
};
String postData = '''
$boundary
Content-Dispositition: form-data; name="file"
Content-Type: text/plain
Hello world
$boundary--
''';
String postData = '\r\n$boundary\r\n' +
'Content-Disposition: form-data; name="hello"\r\nworld\r\n$boundary\r\n' +
'Content-Disposition: file; name="file"; filename="app.dart"\r\n' +
'Content-Type: text/plain\r\nHello world\r\n$boundary--';
print('Form Data: \n$postData');
var response = await client.post(url, headers: headers, body: postData);
print('Response: ${response.body}');
var body = god.deserialize(response.body)['body'];
Map json = god.deserialize(response.body);
List<Map> files = json['files'];
expect(files.length, equals(1));
expect(files[0]['name'], equals('file'));
expect(files[0]['mimeType'], equals('text/plain'));
expect(files[0]['data'].length, equals(11));
expect(files[0]['filename'], equals('app.dart'));
expect(json['body']['hello'], equals('world'));
});
test('Multiple upload', () async {
String boundary = '----myBoundary';
Map headers = {
HttpHeaders.CONTENT_TYPE: 'multipart/form-data; boundary=$boundary'
};
String postData = '\r\n$boundary\r\n' +
'Content-Disposition: form-data; name="json"\r\ngod\r\n$boundary\r\n' +
'Content-Disposition: file; name="file"; filename="app.dart"\r\n' +
'Content-Type: text/plain\r\nHello world\r\n$boundary--';
print('Form Data: \n$postData');
var response = await client.post(url, headers: headers, body: postData);
print('Response: ${response.body}');
Map json = god.deserialize(response.body);
List<Map> files = json['files'];
expect(files.length, equals(1));
expect(files[0]['name'], equals('file'));
expect(files[0]['mimeType'], equals('text/plain'));
expect(files[0]['data'].length, equals(11));
expect(json['body']['json'], equals('god'));
}, skip: 'Multiple file uploads are yet to come.');
});
});
}