Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-45581

QML XMLHttpRequest.status does not return OK value

    XMLWordPrintable

Details

    Description

      The XMLHttpRequest.status does not return 200 ‘OK’ HTTP status code for a successful request that is done. The issue can be reproduced with Qt’s XMLHttpRequest example (http://doc.qt.io/qt-5/qtqml-xmlhttprequest-example.html) with minor modifications. If you add check for the status in get.qml, you will always get ‘0’ even for a successful request. The code below shows the added lines:

      } else if (doc.readyState == XMLHttpRequest.DONE) {               
          if (doc.status == 200) { // check the status, 200 = OK                       
              var a = doc.responseXML.documentElement;                  
              for (var ii = 0; ii < a.childNodes.length; ++ii) {        
                  showRequestInfo(a.childNodes[ii].nodeName);           
              }                                                         
              showRequestInfo("Headers -->");                           
              showRequestInfo(doc.getAllResponseHeaders ());            
              showRequestInfo("Last modified -->");                     
              showRequestInfo(doc.getResponseHeader ("Last-Modified")); 
          } else { // status NOK
              showRequestInfo("ERROR, status: " + doc.status);          
          }                                                             
      }                                                                 
      

      Attached also modified version of the example to show the issue.

      Attachments

        For Gerrit Dashboard: QTBUG-45581
        # Subject Branch Project Status CR V

        Activity

          People

            vkotov Valery Kotov
            tiheikka Titta Heikkala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes