Skip to content

Modified http example for bugreportQHttp2Stream race condition #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 6.9.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion examples/network/http/httpwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,27 @@ HttpWindow::HttpWindow(QWidget *parent)
}
HttpWindow::~HttpWindow() = default;

// BEGIN BUGREPORT CHANGES 1 of 3
void sleepAndScheduleItself() {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
QTimer::singleShot(0, &sleepAndScheduleItself);
}
// END BUGREPORT CHANGES 1 of 3

void HttpWindow::startRequest(const QUrl &requestedUrl)
{
url = requestedUrl;
httpRequestAborted = false;

//! [qnam-download]
reply.reset(qnam.get(QNetworkRequest(url)));
// BEGIN BUGREPORT CHANGES 2 of 3
// The following endpoint accepts POST and returns 401.
url = QUrl("https://lddpro.service.dpt.lego.com/v2/application/blacklist");
QNetworkRequest networkRequest(url);
networkRequest.setRawHeader("Accept-Encoding", "identity");
networkRequest.setRawHeader("Content-Type", "application/json");
reply.reset(qnam.post(networkRequest, QByteArray("{\n \"version\": \"0000000000000000000000000000000000000000\"\n}\n")));
// END BUGREPORT CHANGES 2 of 3
//! [qnam-download]
//! [connecting-reply-to-slots]
connect(reply.get(), &QNetworkReply::finished, this, &HttpWindow::httpFinished);
Expand All @@ -120,6 +134,10 @@ void HttpWindow::startRequest(const QUrl &requestedUrl)
progressDialog->show();

statusLabel->setText(tr("Downloading %1...").arg(url.toString()));

// BEGIN BUGREPORT CHANGES 3 of 3
sleepAndScheduleItself();
// END BUGREPORT CHANGES 3 of 3
}

void HttpWindow::downloadFile()
Expand Down