Project: titanium
Issue TIMOB-19817: Android: HTTPClient multipart header error
The following code (upload a blob to the server), creates malformed http header: {noformat} var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() {...}; xhr.open('POST',serverUrl'); xhr.send({file:aBlob,name:'something'}); {noformat} This creates the request: {noformat} POST /api/1/upload/ HTTP/1.1 Accept-Encoding: identity X-Titanium-Id: 12345678-2222-4444-8888-111111111111 Content-Type: multipart/form-data; boundary=j7D5qBH3i-pbXOzjDHVJNdQRhPBvF-Q0PUmVjZe ... Content-Length: 56789 --j7D5qBH3i-pbXOzjDHVJNdQRhPBvF-Q0PUmVjZe Content-Disposition: form-data; name="file""; filename="tixhr1851009574.png" Content-Type: image/png Content-Transfer-Encoding: binary ... {noformat} Note the double quotes for the name part: Content-Disposition: form-data; name=*"file""*; filename="tixhr1851009574.png" I've traced the bug to {{TiHTTPClient.java}} at {{addFilePart(String name, ContentBody contentBody)}}. The extra " comes when appending the filename argument.
Story points: 1