Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. XHR empty responseText

XHR empty responseText

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 3 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by
    #1

    hi,

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Button{
            onClicked: {
                var doc = new XMLHttpRequest();
    
                   doc.onreadystatechange = function() {
                       if (doc.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
                           showRequestInfo("Headers -->");
                           showRequestInfo(doc.getAllResponseHeaders ());
                           showRequestInfo("Last modified -->");
                           showRequestInfo(doc.getResponseHeader ("Last-Modified"));
    
                       } else if (doc.readyState === XMLHttpRequest.DONE) {
                            console.log("OK : " + doc.responseText)
                       }
                   }
    
                   doc.open("GET", "www.google.fr");
                   doc.send();
    
    
            }
        }
    }
    
    

    why responseText is empty please ?
    qt5.11 mingw32

    raven-worxR 1 Reply Last reply
    0
    • ODБOïO ODБOï

      hi,

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Button{
              onClicked: {
                  var doc = new XMLHttpRequest();
      
                     doc.onreadystatechange = function() {
                         if (doc.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
                             showRequestInfo("Headers -->");
                             showRequestInfo(doc.getAllResponseHeaders ());
                             showRequestInfo("Last modified -->");
                             showRequestInfo(doc.getResponseHeader ("Last-Modified"));
      
                         } else if (doc.readyState === XMLHttpRequest.DONE) {
                              console.log("OK : " + doc.responseText)
                         }
                     }
      
                     doc.open("GET", "www.google.fr");
                     doc.send();
      
      
              }
          }
      }
      
      

      why responseText is empty please ?
      qt5.11 mingw32

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @LeLev
      what is the value of the status property?
      Is OpenSSL available?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      ODБOïO 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @LeLev
        what is the value of the status property?
        Is OpenSSL available?

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        @raven-worx thx,
        status is 0 with : doc.open("GET", "www.google.fr");
        but i tryed : doc.open("GET", "https://www.google.fr")
        now status 200 and i have headers received, but doc.readyState === XMLHttpRequest.DONE is never true.
        and i have this errors

        qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
        qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
        qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
        qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
        qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
        qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
        qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
        qt.network.ssl: QSslSocket: cannot resolve SSL_set_alpn_protos
        qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb
        qt.network.ssl: QSslSocket: cannot resolve SSL_get0_alpn_selected
        qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiated
        

        i installed openssl and pasted the dlls near the executable.

        This code was working without openSll (with the same errors..)..

        raven-worxR 1 Reply Last reply
        0
        • ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          Now im running this exemple project : http://doc.qt.io/qt-5/qtqml-xmlhttprequest-example.html

          error a this line :

          var a = doc.responseXML.documentElement;
          

          qrc:///qml/xmlhttprequest/methods.js:68: TypeError: Cannot read property 'documentElement' of null

          2 day im trying to get 1 html page content ...

          I also had a working project using : QNetworkAccessManager/QNetworkReply that is not working anymore...

          1 Reply Last reply
          0
          • ODБOïO ODБOï

            @raven-worx thx,
            status is 0 with : doc.open("GET", "www.google.fr");
            but i tryed : doc.open("GET", "https://www.google.fr")
            now status 200 and i have headers received, but doc.readyState === XMLHttpRequest.DONE is never true.
            and i have this errors

            qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
            qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
            qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
            qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
            qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
            qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
            qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
            qt.network.ssl: QSslSocket: cannot resolve SSL_set_alpn_protos
            qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb
            qt.network.ssl: QSslSocket: cannot resolve SSL_get0_alpn_selected
            qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiated
            

            i installed openssl and pasted the dlls near the executable.

            This code was working without openSll (with the same errors..)..

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @LeLev said in XHR empty responseText:

            This code was working without openSll (with the same errors..)..

            when was it working? long time ago right?
            Google automatically changed to redirecting to https at some time ago.

            status is 0 with : doc.open("GET", "www.google.fr");
            but i tryed : doc.open("GET", "https://www.google.fr")

            Thats what i was after. Status 0 indicates that it actually tried to access file://www.google.fr

            So your issue is that it can't decrypt SSL connection.

            What Qt version are you using?
            What OpenSSL version?
            Where did you place the OpenSSL libs?
            Easiest would be to add the directory path of the dll files to the PATH variable. For deployment right next to the executable then.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            2
            • ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #6

              @raven-worx said in XHR empty responseText:

              when was it working? long time ago right?

              about one year ago ..

              i tryed with qt5.6 and 5.8 / 5.11 mingw32

              i installed openSSL 32 (and 64) 1.1.0. (putted libeay32.dll and ssleay32.dll near the executable of my app)

              @raven-worx said in XHR empty responseText:

              Easiest would be to add the directory path of the dll files to the PATH variable. For deployment right next to the executable then.

              could you please tell me where you download openSSl . And what 'Path', windows environment variables ? or in Qt ? could you please show an exemple ?

              Thx!

              SGaistS 1 Reply Last reply
              0
              • ODБOïO ODБOï

                @raven-worx said in XHR empty responseText:

                when was it working? long time ago right?

                about one year ago ..

                i tryed with qt5.6 and 5.8 / 5.11 mingw32

                i installed openSSL 32 (and 64) 1.1.0. (putted libeay32.dll and ssleay32.dll near the executable of my app)

                @raven-worx said in XHR empty responseText:

                Easiest would be to add the directory path of the dll files to the PATH variable. For deployment right next to the executable then.

                could you please tell me where you download openSSl . And what 'Path', windows environment variables ? or in Qt ? could you please show an exemple ?

                Thx!

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi,

                @LeLev said in XHR empty responseText:

                i installed openSSL 32 (and 64) 1.1.0.

                That's the problem, currently you need to install the latest of the 1.0.X release. The OpenSSL project broke API and ABI compatibility with the 1.1 release. Since Qt 5.10, there's also a backend for OpenSSL 1.1 but you'll have to build Qt yourself to use it.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #8

                  @raven-worx and @SGaist pleae correct me if im wrong but openSSL is not required for xmlhttprequest right ?

                  @raven-worx said in XHR empty responseText:

                  Google automatically changed to redirecting to https at some time ago.

                  I don't have this probleme only with Google but avery website i test .

                  raven-worxR ODБOïO 2 Replies Last reply
                  0
                  • ODБOïO ODБOï

                    @raven-worx and @SGaist pleae correct me if im wrong but openSSL is not required for xmlhttprequest right ?

                    @raven-worx said in XHR empty responseText:

                    Google automatically changed to redirecting to https at some time ago.

                    I don't have this probleme only with Google but avery website i test .

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by raven-worx
                    #9

                    @LeLev said in XHR empty responseText:

                    I don't have this probleme only with Google but avery website i test .

                    yes, when you omit the http:// - i already explained why.
                    You get the OpenSSL errors only when the website redirects to https. Which doesn't happen on all sites, but on most already.

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    1
                    • ODБOïO ODБOï

                      @raven-worx and @SGaist pleae correct me if im wrong but openSSL is not required for xmlhttprequest right ?

                      @raven-worx said in XHR empty responseText:

                      Google automatically changed to redirecting to https at some time ago.

                      I don't have this probleme only with Google but avery website i test .

                      ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #10

                      @LeLev finnaly i installed Win32OpenSSL-1_0_2, i still have qt.network.ssl: QSslSocket: warnings but its working thank you.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved