[TIMOB-15980] iOS: Replace ASIHttp with NSURLConnection
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-03-18T19:12:14.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.3.0 |
Components | iOS |
Labels | planning-3.3.0 |
Reporter | Ingo Muschenetz |
Assignee | Pedro Enrique |
Created | 2013-12-13T01:06:18.000+0000 |
Updated | 2014-06-27T20:27:03.000+0000 |
Description
We currently use the ASIHttp library to provide network connection support. This library is out of date and deprecated. We aim to replace it with NSUrlConnection to provide better support for mobile app security solutions.
yes, yes, and yes again.
Initial implementation can be found at https://github.com/pec1985/TiHTTPClient
PR: https://github.com/appcelerator/titanium_mobile/pull/5323
The 'Content-Length' header only seems to be available on the 'last' ondatastream event - not on all events as previously occurred. This would be very useful as we display 'downloading XXXKb of XXXXKb' messages for the user. This is using NTLM Authentication over SSL. Sample code and log output for the same file below: Code: fileXhr.ondatastream = function(e) { filelog.debug('xhr.ondatastream fired'); filelog.debug('status=' + fileXhr.status); var totalBytes = fileXhr.getResponseHeader('Content-Length'); filelog.debug('Totalbytes:' + totalBytes); filelog.debug('Progress=' + e.progress); }; Old ASIHttpRequest httpClient [DEBUG] : fileXhr 233ms 130mb ^4mb xhr.ondatastream fired [DEBUG] : fileXhr 234ms 130mb ^4mb status=401 [DEBUG] : fileXhr 234ms 130mb ^4mb Totalbytes:1293 [DEBUG] : fileXhr 234ms 130mb ^4mb Progress=1 [DEBUG] : fileXhr 734ms 133mb ^1mb xhr.ondatastream fired [DEBUG] : fileXhr 735ms 133mb ^1mb status=200 [DEBUG] : fileXhr 735ms 133mb ^1mb Totalbytes:1571627 [DEBUG] : fileXhr 735ms 133mb ^1mb Progress=0.07360270619392395 [DEBUG] : fileXhr 984ms 133mb ^0mb xhr.ondatastream fired [DEBUG] : fileXhr 984ms 133mb ^0mb status=200 [DEBUG] : fileXhr 984ms 133mb ^0mb Totalbytes:1571627 [DEBUG] : fileXhr 984ms 133mb ^0mb Progress=0.3759238123893738 [DEBUG] : fileXhr 1234ms 114mb ^20mb xhr.ondatastream fired [DEBUG] : fileXhr 1235ms 114mb ^20mb status=200 [DEBUG] : fileXhr 1235ms 114mb ^20mb Totalbytes:1571627 [DEBUG] : fileXhr 1235ms 114mb ^20mb Progress=0.6678200364112854 [DEBUG] : fileXhr 1485ms 86mb ^47mb xhr.ondatastream fired [DEBUG] : fileXhr 1485ms 86mb ^47mb status=200 [DEBUG] : fileXhr 1485ms 86mb ^47mb Totalbytes:1571627 [DEBUG] : fileXhr 1486ms 86mb ^47mb Progress=0.9909908771514893 [DEBUG] : fileXhr 1490ms 85mb ^49mb xhr.ondatastream fired [DEBUG] : fileXhr 1490ms 85mb ^49mb status=200 [DEBUG] : fileXhr 1490ms 85mb ^49mb Totalbytes:1571627 [DEBUG] : fileXhr 1490ms 85mb ^49mb Progress=1.00082266330719 [DEBUG] : fileXhr 1493ms 81mb ^53mb starting onload New NSUrlConnection httpClient [DEBUG] : fileXhr 118ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 118ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 118ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 118ms 118mb ^-8mb Progress=0.010242888703942299 [DEBUG] : fileXhr 150ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 150ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 150ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 150ms 118mb ^-8mb Progress=0.05194234848022461 [DEBUG] : fileXhr 182ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 182ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 182ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 182ms 118mb ^-8mb Progress=0.09364181011915207 [DEBUG] : fileXhr 215ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 215ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 215ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 215ms 118mb ^-8mb Progress=0.13534127175807953 ... etc ... [DEBUG] : fileXhr 870ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 870ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 870ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 870ms 118mb ^-8mb Progress=0.896356463432312 [DEBUG] : fileXhr 905ms 118mb ^-8mb xhr.ondatastream fired [DEBUG] : fileXhr 905ms 118mb ^-8mb status=0 [DEBUG] : fileXhr 905ms 118mb ^-8mb Totalbytes:undefined [DEBUG] : fileXhr 905ms 118mb ^-8mb Progress=0.9380559325218201 [DEBUG] : fileXhr 935ms 116mb ^-6mb xhr.ondatastream fired [DEBUG] : fileXhr 935ms 116mb ^-6mb status=0 [DEBUG] : fileXhr 935ms 116mb ^-6mb Totalbytes:undefined [DEBUG] : fileXhr 935ms 116mb ^-6mb Progress=0.9797554016113281 [DEBUG] : fileXhr 951ms 116mb ^-6mb xhr.ondatastream fired [DEBUG] : fileXhr 951ms 116mb ^-6mb status=200 [DEBUG] : fileXhr 951ms 116mb ^-6mb Totalbytes:1571627 [DEBUG] : fileXhr 951ms 116mb ^-6mb Progress=1
Got another one for you. When POSTing files, the filename in Content-Disposition and the Content-Type are not being set properly. See the requests for the old and new below (full requests follow) Old ASIHttpRequest httpClient:
New NSUrlConnection httpClient:
---- Full Headers: Old ASIHttpRequest httpClient:
New NSUrlConnection httpClient:
Tested with several apps and found no problems.
[~fokke] Thanks Fokke. We do appreciate the feedback.
Primary testing complete. Will continue to evaluate any upcoming changes.
Testing has not uncovered any issues with feature implementation.