mikeal/request — pull request #1176 by simov (2014-10-16 07:02:20+00:00)
Title: Support formData array fields

:wave:

I don't have a unit test for this one, but here is how I system tested it

```js
request.post('https://api.mailgun.net/v2/[your-domain].mailgun.org/messages', {
auth:{user:'api',pass:'apikey'},
headers:{'content-type':'multipart/form-data'},
formData:{
from:'request@mailinator.com',
to:'request@mailinator.com',
subject:'Multiple Attachments',
html:'

Awesome!

',
text:'True idd!',
attachment:[fs.createReadStream('cat.png'), fs.createReadStream('coffee.png')]
}
},
function (err, res, body) {});
```

The result is an email with two attachments to it

[Mailgun Sending](http://documentation.mailgun.com/api-sending.html#sending)
> `attachment` - File attachment. You can post **multiple** attachment values. Important: You must use multipart/form-data encoding when sending attachments.

Same thing with Sendgrid

[Sendgrid Sending](https://sendgrid.com/docs/API_Reference/Web_API/mail.html)
> `files` - Files to be attached. The file contents must be part of the multipart HTTP POST. Ex: files[file1.jpg]=file1.jpg&[file2.pdf]=file2.pdf

Now when I think about it, why is the `headers:{'content-type':'multipart/form-data'}` not set by default when the `formData` key is present?