[TIMOB-19817] Android: HTTPClient multipart header error
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-10-28T21:28:00.000+0000 |
Affected Version/s | Release 5.0.2 |
Fix Version/s | Release 5.1.0, Release 5.0.3, Release 5.2.0 |
Components | Android |
Labels | android |
Reporter | grebulon |
Assignee | Ashraf Abu |
Created | 2015-10-12T13:19:24.000+0000 |
Updated | 2015-10-29T22:26:23.000+0000 |
Description
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.
Master PR: https://github.com/appcelerator/titanium_mobile/pull/7358 5_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/7360 5_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/7361
Testing steps to ensure all is okay:-
Thanks [~buddyguards] for tracing this.
Verified the fix. No HTTP multipart header error seen. Closing. Environment: Appc Studio : 4.4.0.201510290507 Ti SDK : 5.1.0.v20151028190028 , 5.2.0.v20151029134437, 5.0.3.v20151028143139 Ti CLI : 5.0.5 Alloy : 1.7.18 MAC Yosemite : 10.10.5 Appc NPM : 4.2.1-6 Appc CLI : 5.1.0-38 Node: v0.10.37 samsung Galaxy S4 - Android 4.4.4