Nominate our 2022 Qt Champions!

Content-Length Header missing?

  • Hi,

    I try to download some (binary) from a server. The request page is a php script, that returns the files according some POST variables.

    my php script looks like this

    //read $_POST and do some PDO things returning content as blob, size as int, contenttype as varchar
    $filesize = $res['size']; //size is set in the database
    $type = $res['contenttype'];
    $content = $res['content'];
    header("Content-Length: $filesize");
    header("Content-type: $type");
    echo $content;

    If I request a file via browser (with jquery post), I get all headers, but with QNetworkAccessManager I am missing the Content-Length.

    qDebug() << "header: " << r->header(QNetworkRequest::ContentLengthHeader);

    says QVariant(Invalid)

    qDebug() << r->rawHeaderList();

    reads this:

    ("Date", "Server", "X-Powered-By", "Vary", "Content-Encoding", "Connection", "Transfer-Encoding", "Content-Type")

    Any ideas what went wrong here?