1. Support streaming in the simple case. Put huge warnings around the
buffering API.
2. Support nested multipart messages.
3. Support various kinds of multipart messages, including all the various
absurdities of multipart email messages.
4. Error out on various invalid types of data that might come through.
5. Gracefully several edge cases that occur when the chunk size is smaller
than the boundary length, or cuts into the \r\n, etc.
6. Provide both positive and negative tests.
Some HTTP clients include a charset parameter in the Content-Type, e.g:
multipart/form-data; charset=utf-8; boundary=0xKhTmLbOuNdArY
This patch makes the multipart parser more forgiving towards unexpected
information included in the Content-Type header.
This is actually undesireable as it takes away control from the user who
may want to pause/resume to throttle the upload stream, or synchronize
it with disk flushing.
I actually ran into memory issues when trying to stream huge files to
disc as the file module was building up a huge action buffer. This can
now easily be avoided like this:
part.addListener('body', function(chunk) {
req.pause();
file.write(chunk).addCallback(function() {
req.resume();
});
}
Multipart parts now have a name and filename property. Those are the
same as:
part.headers['content-disposition'].name
part.headers['content-disposition'].filename
This patch also updates and improves the docs for the multipart module.