You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
QFile* f = new QFile(filename); // a file of some MB size
if (f->open(QFile::ReadOnly))
{
res->addHeader("content-length", QString::number(f->size()).toLatin1());
res->addHeader("content-type", "application/octet-stream");
res->addHeader("content-disposition", QStringLiteral("attachment; filename=\"%1\"").arg(info.fileName()).toLatin1());
//res->addHeader("connection", "Keep-Alive");
//res->addHeader("keep-alive", "timeout=600, max=100");
res->setStatusCode(qhttp::ESTATUS_OK);
connect(res, &QHttpResponse::allBytesWritten, this, [this, f, res] {
qDebug() << "Write more... " << f->pos(); // called only a few times
QByteArray data = f->read(50000);
if (data.length() == 0)
{
qDebug() << "END"; // never called
res->end();
f->close();
f->deleteLater();
}
else
{
res->write(data); // called a few times
}
});
QByteArray data = f->read(50000);
if (data.length() > 0)
{
res->write(data);
return;
}
else
{
f->close();
}
}
f->deleteLater();
});`
The text was updated successfully, but these errors were encountered:
The "QHttpResponse::allBytesWritten" signal is emited only a few times when manually writing data to the client. This leads to incomplete downloads.
`req->onEnd(this, req, res {
});`
The text was updated successfully, but these errors were encountered: