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

Feature request add support Upgrade protocols to url Requests in QML to Qt 6

    XMLWordPrintable

    Details

    • Platform/s:
      All
    • Technical Risk:
      Normal

      Description

      Hello.
       
      I have a suggestion: add to next Major release Qt support for Protocol Upgrade in QML requests and/or switching protocol to SPDY .
       
      Context: work with Qt with Kubernetes or Openshift.
       
      1. For example console command (oc) for listing directory in to openshift pod:

      oc exec guid_pod-5bcd8cd446-blg95 ls / --loglevel=9
      
      I0711 00:10:43.153956   24178 round_trippers.go:386] curl -k -v -XPOST  -H "X-Stream-Protocol-Version: v4.channel.k8s.io" -H "X-Stream-Protocol-Version: v3.channel.k8s.io" -H "X-Stream-Protocol-Version: v2.channel.k8s.io" -H "X-Stream-Protocol-Version: channel.k8s.io" -H "User-Agent: oc/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0" -H "Authorization: Bearer Lno_YLI1zrbbEWl3258uMsI178B0uE3c-g2H0XQAK4s" 'https://vm-openshift.local:8443/api/v1/namespaces/myprojecy/pods/guid_pod-5bcd8cd446-blg95/exec?command=ls&command=%2F&container=name-cnt&container=name-cnt&stderr=true&stdout=true'
      I0711 00:10:43.787906   24178 round_trippers.go:405] POST https://vm-openshift.local:8443/api/v1/namespaces/myprojecy/pods/guid_pod-5bcd8cd446-blg95/exec?command=ls&command=%2F&container=name-cnt&container=name-cnt&stderr=true&stdout=true 101 Switching Protocols in 633 milliseconds
      I0711 00:10:43.787930   24178 round_trippers.go:411] Response Headers:
      I0711 00:10:43.787941   24178 round_trippers.go:414]     Connection: Upgrade
      I0711 00:10:43.787951   24178 round_trippers.go:414]     Upgrade: SPDY/3.1
      I0711 00:10:43.787958   24178 round_trippers.go:414]     X-Stream-Protocol-Version: v4.channel.k8s.io
      I0711 00:10:43.787965   24178 round_trippers.go:414]     Date: Fri, 10 Jul 2020 21:10:43 GMT
      bin
      dev
      etc
      home
      lib
      media
      mnt
      opt
      proc
      root
      run
      sbin
      srv
      sys
      tmp
      usr
      var
      

      2. Example with this verbose log with curl: (curl not support Uprade((

      curl -k -v -XPOST -H "X-Stream-Protocol-Version: v4.channel.k8s.io" -H "X-Stream-Protocol-Version: v3.channel.k8s.io" -H "X-Stream-Protocol-Version: v2.channel.k8s.io" -H "X-Stream-Protocol-Version: channel.k8s.io" -H "User-Agent: oc/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0" -H "Authorization: Bearer Lno_YLI1zrbbEWl3258uMsI178B0uE3c-g2H0XQAK4s" 'https://vm-openshift.local:8443/api/v1/namespaces/myprojecy/pods/guid_pod-5bcd8cd446-blg95/exec?command=ls&command=%2F&container=name-cnt&container=name-cnt&stderr=true&stdout=true' I0711 00:10:43.787906 24178 round_trippers.go:405] POST https://vm-openshift.local:8443/api/v1/namespaces/myprojecy/pods/guid_pod-5bcd8cd446-blg95/exec?command=ls&command=%2F&container=name-cnt&container=name-cnt&stderr=true&stdout=true
      ////end of cut outout
      < HTTP/2 400 
      < cache-control: no-store
      < content-type: application/json
      < content-length: 139
      < date: Fri, 10 Jul 2020 21:18:37 GMT
      < 
      {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Upgrade request required","reason":"BadRequest","code":400}
      * Connection #0 to host vm-openshift.local left intact
      
      

      3. Work with Python with API openshift (work without errors)

      pip list
      Package           Version  
      ----------------- ---------
      cachetools        4.1.1    
      certifi           2020.6.20
      chardet           3.0.4    
      google-auth       1.18.0   
      idna              2.10     
      kubernetes        11.0.0   
      oauthlib          3.1.0    
      pip               18.1     
      pkg-resources     0.0.0    
      pyasn1            0.4.8    
      pyasn1-modules    0.2.8    
      python-dateutil   2.8.1    
      PyYAML            5.3.1    
      requests          2.24.0   
      requests-oauthlib 1.3.0    
      rsa               4.6      
      setuptools        40.8.0   
      six               1.15.0   
      urllib3           1.25.9   
      websocket-client  0.57.0 
      
      python 1.py 
      python/pyth3/lib/python3.7/site-packages/kubernetes/client/apis/__init__.py:12: DeprecationWarning: The package kubernetes.client.apis is renamed and deprecated, use kubernetes.client.api instead (please note that the trailing s was removed).
        DeprecationWarning
      python/pyth3/lib/python3.7/site-packages/urllib3/connectionpool.py:986: InsecureRequestWarning: Unverified HTTPS request is being made to host 'vm-openshift.local'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
        InsecureRequestWarning,
      Response: This message goes to stdout
      This message goes to stderr
      Running command... 
      echo test1
      STDOUT: test1Running command... 
      echo "This message goes to stderr" >&2
      STDERR: This message goes to stderrServer date command returns: Fri Jul 10 21:36:16 UTC 2020
      Server user is: None
      

      4. QML Js example:

      function apipost() {
          console.log('check update function start')
          console.log(cmdparse.osurl)
          var request = new XMLHttpRequest()
         request.open("POST", "https://vm-openshift.local:8443/api/v1/namespaces/myprojecy/pods/guid_pod-5bcd8cd446-blg95/exec?command=ls&command=%2F&container=name-cnt&container=name-cnt&stderr=true&stdout=true")    //request.setRequestHeader('Content-Type',
          //                         'application/x-www-form-urlencoded')
          console.log(cmdparse.ostoken);
          request.setRequestHeader("Authorization", "Bearer " + cmdparse.ostoken)
          request.setRequestHeader("X-Stream-Protocol-Version", "v4.channel.k8s.io")
          request.setRequestHeader("X-Stream-Protocol-Version", "v3.channel.k8s.io")
          request.setRequestHeader("X-Stream-Protocol-Version", "v2.channel.k8s.io")
          request.setRequestHeader("X-Stream-Protocol-Version", "channel.k8s.io")
          request.setRequestHeader("User-Agent", "oc/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0")    //request.setRequestHeader("Connection", "Upgrade")
          //request.setRequestHeader("Upgrade", "SPDY/3.1")    request.withCredentials = true
          console.log(request.reqdyState +  " - ready state")
          request.onreadystatechange = function () {
              console.log("js request on ready state function. State=" + request.readyState + " and status=" + request.status)
              if (request.readyState === 4 && request.status === 0) {
                  textArea2.text = "No internet access"
              }        if (request.readyState === 4 && request.status === 404) {
                  textArea2.text = "No data on server"
              }        if (request.readyState === 4 && request.status === 200) {
                  print('result download is' + request.responseText)
                  myFunction1(request.responseText)
              }
          }
          request.send()
          console.log("request sended")
      }
      
      

      main.cpp

       

      #include <QSslConfiguration>
      #include <QSslSocket>
      
      
          qDebug() << "Allow untrusted certificated by settins in application";
          QSslConfiguration config = QSslConfiguration::defaultConfiguration();
          config.setPeerVerifyMode(QSslSocket::VerifyNone);
          QSslConfiguration::setDefaultConfiguration(config);
      
      

      Log QML (error code also as curl):

      qml: after start post api openshift
      qml: js request on ready state function. State=2 and status=400
      qml: js request on ready state function. State=3 and status=400
      qml: js request on ready state function. State=3 and status=400
      qml: js request on ready state function. State=4 and status=400

       

       

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            manordheim Mårten Nordheim
            Reporter:
            homdx Homdx Homdx
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes