Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25789

Windows: HttpClient.onreadystatechange should be called right after ondatastream/onsendstream

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 7.0.0
    • Fix Version/s: Release 8.0.0
    • Component/s: Windows
    • Labels:
    • Story Points:
      5
    • Sprint:
      2018 Sprint 05 SDK, 2018 Sprint 04 SDK, 2018 Sprint 06 SDK, 2018 Sprint 07 SDK, 2018 Sprint 08 SDK, 2018 Sprint 15 SDK, 2016 Sprint 17 SDK, 2018 Sprint 18 SDK, 2018 Sprint 19 SDK, 2018 Sprint 20 SDK, 2018 Sprint 21, 2018 Sprint 22, 2018 Sprint 25

      Description

      HttpClient callbackTestForGETMethod and callbackTestForPOSTMethod unit test 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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kiguchi Kota Iguchi
                Reporter:
                kiguchi Kota Iguchi
                Reviewer:
                Josh Longton
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-6190
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code