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

Content-Length header always sent in HTTP GET request

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.11.0 FF
    • 6.9.1
    • Network: HTTP
    • None
    • bb40f641f (dev)

      When using QNetworkAccessManager::sendCustomRequest(...) with an http GET request, and a non-nullptr QIODevice, then a "Content-Length: 0" header is sent, even if the data from the device is empty.

      Per RFC9110, "A user agent SHOULD NOT send a Content-Length header field when the request message does not contain content and the method semantics do not anticipate such data." Semantically, HTTP_GET and HTTP_HEAD shouldn't send the header when the data is empty.

      My suggestion is that the Content-Length header not be sent for GET, HEAD, DELETE, and CONNECT requests when the data body is empty EVEN if a non-null data device is passed to the call. Some CDNs and other common servers may respond differently for GET calls with "Content-Length: 0" header.

      Issue encountered when using KIO::get(...) from the KDE Frameworks, in https://bugs.kde.org/show_bug.cgi?id=507523

        1. contentlengthtest.pro
          0.1 kB
          Robby Stephenson
        2. main.cpp
          2 kB
          Robby Stephenson
        For Gerrit Dashboard: QTBUG-138848
        # Subject Branch Project Status CR V

            manordheim MÃ¥rten Nordheim
            astrorobby Robby Stephenson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There is 1 open Gerrit change