[TIMOB-27293] Android: HTTPClient onsendstream "progress" is always set to 1.0
| GitHub Issue | n/a | 
|---|---|
| Type | Bug | 
| Priority | Medium | 
| Status | Closed | 
| Resolution | Fixed | 
| Resolution Date | 2019-10-30T18:22:42.000+0000 | 
| Affected Version/s | Release 5.1.2, Release 8.0.2 | 
| Fix Version/s | Release 8.3.0 | 
| Components | Android | 
| Labels | android, engSchedule, httpclient | 
| Reporter | Rene Pot | 
| Assignee | Yordan Banev | 
| Created | 2015-12-16T14:08:50.000+0000 | 
| Updated | 2019-10-30T18:22:42.000+0000 | 
Description
	When initiating an XHR request on Android, and providing the onsendstream callback function, the progress within the payload (e.progress) will always be 1.
Expected is the actual progress as a number between 0.0 and 1.0
Hello [~topener], Please provide a complete test case which demonstrate your problem. We will try to regenerate the issue. Also please provide the log and your full configuration. Make sure you follow the [documentation](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient-property-onsendstream) of uploading file. Thanks.
I'm still having this problem in Ti SDK 5.1.2.GA
Reopen this ticket please, it doesn't work now
I am seeing this issue as well. I will see if I can come up with a simple example. I believe I am following the documentation (setting onsendstream before calling open, is there something else?). Please re-open. I am using SDK 6.0.3 ...
I can reproduce with this code and Ti SDK 8.0.2 (an 1+ MB image in assets/images folder is required to test or just use an equivalent size string):
var win = Ti.UI.createWindow(); var progress = Ti.UI.createProgressBar({ width:200, min:0, max:1, value:0, tintColor : "red" }); win.add(progress); var timestamp = Date.now(); var file = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, '/images/img.jpg'); // app/assets/images/img.jpg var base64String = Ti.Utils.base64encode(file).toString(); win.addEventListener('open', function() { var xhr = Ti.Network.createHTTPClient({ onload : function() { var time_passed = Math.floor((Date.now() - timestamp) / 1000); Ti.API.info('Seconds passed:', time_passed, 'SUCCESS'); }, onsendstream : _.throttle(function(e) { var time_passed = Math.floor((Date.now() - timestamp) / 1000); Ti.API.info('Seconds passed:', time_passed + ', progress:', e.progress); progress.setValue(e.progress); }, 250) }); xhr.open('POST', 'https://httpbin.org/post'); xhr.send(base64String); }); win.open();Hello [~jquick], The issue is reproducible with SDK 8.0.2.GA. With the above sample code and a >1MB image file in the assets/android/images/ directory the progress always shows 1. And after sometime it shows success. Thanks.
PR: https://github.com/appcelerator/titanium_mobile/pull/11168
FR passed.
Moving back out of QE test, because unit tests fail with this PR.
merged to master
Verified on: Mac OS 10.14.6 Ti SDK: 8.3.0.v20191030085531 Appc CLI: 7.1.1 Node: 10.5.0 JDK: 1.8.0_162 Studio: 5.1.4.201909061933 Device: Nexus4 (v5.1.1), Pixel3(v10.0) emulator