appcelerator/APSHTTPClient — pull request #19 by itsbrnrd (2014-12-29 13:05:36+00:00)
Title: Fix malformed Content-Type error with modsecurity

While working on a Titanium iOS application (SDK 3.4.0.GA which uses APSHTTPClient under the hood), I couldn't upload a picture to our backend which uses [modsecurity](https://github.com/SpiderLabs/ModSecurity). The upload request was rejected by modsecurity and the following error appeared in the logs :

`Multipart parsing error (init): Multipart: Invalid boundary in C-T (malformed).`

I looked into APSHTTPClient and saw that the header was created as follow :
```objective-c
[self addHeaderKey:@"Content-Type" andHeaderValue:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, boundry]];
```
Note that `charset` is *before* the `boundary` header.

The reason modsecurity rejected the request is because the Content-Type multipart/data format requires a parameter `boundary` immediately after the subtype. It expects that the boundary header has no characters (except space and ;) before it.[[0]](https://github.com/SpiderLabs/ModSecurity/blob/046b5537368c2a5c3ef9c25b64f0041d3932b373/apache2/msc_multipart.c#L812)

It must be :
`Content-Type: multipart/form-data; boundary=0xTibOuNdArY_1234567890; [...]`

This patch is inspired by : http://hc.apache.org/httpcomponents-client-ga/httpmime/xref/org/apache/http/entity/mime/MultipartEntity.html#94