Skip to content

Commit

Permalink
tst_QNetworkReply: Avoid race in ioGetFromHttpWithAuth
Browse files Browse the repository at this point in the history
Our authentication code is race-y by design:
1. When two requests are fired off and queued at the same time in the
same QHttpNetworkConnection then if one of them encounters
"authentication required" then it will copy whatever credentials it got
to all the other channels in the connection. This is likely what the
first part of the test is testing.
2. If a later request is fired off and it includes credentials in the
url then the newly included credentials should be used instead of the
cached ones.

The race here can occurr when one socket either takes too long to
connect or the connected signal is not received early enough. Then the
first socket is used for both requests and then we can hit case qt#2 when
the url contains credentials.

Pick-to: 5.15
Change-Id: I646a5378d8c1256b2de98b51912953df29f68cb2
Reviewed-by: Timur Pocheptsov <[email protected]>
  • Loading branch information
Morten242 committed Sep 11, 2020
1 parent 7dd99cd commit 5a47939
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3499,7 +3499,11 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth()
QNetworkRequest request(url);
{
QNetworkReplyPtr reply1(manager.get(request));
QNetworkReplyPtr reply2(manager.get(request));
QUrl copy = url;
copy.setUserName(QString());
copy.setPassword(QString());
QNetworkRequest request2(copy);
QNetworkReplyPtr reply2(manager.get(request2));
DataReader reader1(reply1);
DataReader reader2(reply2);
QSignalSpy finishedspy(reply1.data(), SIGNAL(finished()));
Expand Down

0 comments on commit 5a47939

Please sign in to comment.