[TIMOB-25789] Windows: HttpClient.onreadystatechange should be called right after ondatastream/onsendstream
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-12-10T21:28:26.000+0000 |
Affected Version/s | Release 7.0.0 |
Fix Version/s | Release 8.0.0 |
Components | Windows |
Labels | parity |
Reporter | Kota Iguchi |
Assignee | Kota Iguchi |
Created | 2018-02-20T07:30:45.000+0000 |
Updated | 2018-12-11T12:27:34.000+0000 |
Description
HttpClient
callbackTestForGETMethod
and callbackTestForPOSTMethod
[unit test](https://github.com/appcelerator/titanium-mobile-mocha-suite/blob/master/Resources/ti.network.httpclient.test.js#L377) shows onreadystatechange
should be called right after ondatastream/onsendstream
event to keep parity with iOS/Android.
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
win.addEventListener('open', function () {
var xhr = Ti.Network.createHTTPClient(),
attempts = 3,
sendStreamFinished = false,
buffer;
xhr.setTimeout(3e4);
xhr.onreadystatechange = function () {
Ti.API.info('onreadystatechange sendStreamFinished: ' + sendStreamFinished + ' DONE? ' + (this.readyState === this.DONE));
if (this.readyState === this.DONE && sendStreamFinished) {
Ti.API.info('finish');
}
};
xhr.onsendstream = function (e) {
Ti.API.info('onsendstream');
Ti.API.info(e.progress + ' be.ok');
if (e.progress >= 0.99) {
sendStreamFinished = true;
}
};
xhr.onerror = function (e) {
if (attempts-- > 0) {
Ti.API.warn('failed, attempting to retry request...');
xhr.send();
} else {
Ti.API.warn(JSON.stringify(e, null, 2));
Ti.API.warn(e.error || this.responseText);
}
};
buffer = Ti.createBuffer({
length: 1024 * 10
}).toBlob();
xhr.open('POST', 'http://www.httpbin.org/post');
xhr.send({
data: buffer,
username: 'fgsandford1000',
password: 'sanford1000',
message: 'check me out'
});
});
win.open();
Expected: finish
should be printed.
https://github.com/appcelerator/titanium_mobile_windows/pull/1189
Seems like this makes LiveView unstable.
Attempt to fix issue with liveview: https://github.com/appcelerator/titanium_mobile_windows/pull/1318
*FR Passed*
Closing ticket, fix verified in SDK version 8.0.0.v20181210172243. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile_windows/pull/1318