Http Server: File upload handled by the handler

File upload via multi part message is now handled by the handler.

For that a few changes have been made:
The request holds a reference to the connection, to be able to complete
the upload.

To retain the async nature of the reading a call back interface was
added to the multi-part message parser.

This allows the handler to load the file directly to the file position,
or to upload it to a temporary file inside the target directory and
rename the file after the download is complete.

The new behavior of the connection is to stop parsing after the first
part of the message was parsed. Copy the remaining buffer to the
multipart parser and call the handler to continue processing.

If the handler wishes to continue the upload, it should set the
temporary file name, either immediately or by registering a call back
function and call upload.

If the upload function is called, the connection will not return a
response immediately but will wait for the upload to complete.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: file api - file upload

To upload a file, the file API handler register two function, one that
sets a temporary file inside the target directory and one that move the
temporary file, when the upload is complete, it then call upload to
resume the file upload.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Http Server: Testing the file upload API

This test creates a temporary file, upload it, download it back and
check that the file is identical.

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
run: don't pass extra null argument

Fixes #47
Check size of the string before calling split on it, else
we end up adding a null argument to the command.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>