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

(Shown Again) Proxy authentication fails if http proxy disconnects after issuing 407

    XMLWordPrintable

Details

    • Windows
    • 2a15ec72c0d088a5dca344df163fac73c24caa1f (qt/qtbase/5.12)

    Description

      Its very related to the issue QTBUG-22177, which was resolved years ago.

       

      We setup a proxy server and the default behaviour of that server is to disconnect the connection when required authentication on HTTP/1.1.

      The header that Proxy returned is:

       

       

      Connetion: Close \r\n
      Proxy-Connection: Close \r\n
      

       

       

      Expected:

      QT's QNetworkAccessManager reconnect to Proxy and send the authentication to Proxy.

       

      Actual:

      The signal proxyAuthenticationRequired never emitted and QNetworkAccessManager never reconnect to the Proxy.

       

      What I found from QT 5.13.0 's source code:

              bool willClose;
              QByteArray proxyConnectionHeader = d->reply->headerField("Proxy-Connection");
              // Although most proxies use the unofficial Proxy-Connection header, the Connection header
              // from http spec is also allowed.
              if (proxyConnectionHeader.isEmpty())
                  proxyConnectionHeader = d->reply->headerField("Connection");
              if (proxyConnectionHeader.compare("close", Qt::CaseSensitive) == 0) {
                  willClose = true;
              } else if (proxyConnectionHeader.compare("keep-alive", Qt::CaseInsensitive) == 0) {
                  willClose = false;
              } else {
                  // no Proxy-Connection header, so use the default
                  // HTTP 1.1's default behaviour is to keep persistent connections
                  // HTTP 1.0 or earlier, so we expect the server to close
                  willClose = (d->reply->majorVersion() * 0x100 + d->reply->minorVersion()) <= 0x0100;
              }
      

      It seems already being refactored after this fix: https://codereview.qt-project.org/c/qt/qtbase/+/7484

      The original one use the toLower to ignore the case:

      proxyConnectionHeader = proxyConnectionHeader.toLower();

      But the latest code (from QT 5.13.0) made some mistake (I guess):

      proxyConnectionHeader.compare("close", Qt::CaseSensitive)
      

       

      Attached Debug Info

       

       

       

      I've saw the HTTP RFC spec and it defined:

       

       

      Connection: close
      Connection: Keep-Alive
      

       

       

      But why Qt use Qt::CaseSensitive only for the close header then use Qt::CaseInsensitive for the keep-alive one? I guess both of them should use Qt::CaseInsensitive to enlarge the compatibility of such non-standard proxies, thus the upper case "Close" header from our Proxy server could be handled properly.

       

       

       

      Attachments

        Activity

          People

            manordheim Mårten Nordheim
            billhoo Bill Hoo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: