Torrent example: Use QByteArray toPercentEncoding
The hand-rolled loop produced incorrect output and was subsequently rejected by trackers. The torrent example doesn't support modern features though, so it's still a bit hit-or-miss whether a torrent will work. E.g. downloading an Arch iso does not work since it relies on DHT, PeX and HTTP seeds. Fixes: QTBUG-109798 Task-number: QTBUG-110622 Change-Id: Ica40fb9205f09d135407a160a28a45d06a418176 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 39daa368d47bc676efb19a8e7478ef1c270ae959) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
07f2ca775c
commit
dbe7f136aa
@ -62,12 +62,8 @@ void TrackerClient::fetchPeerList()
|
|||||||
QUrlQuery query(url);
|
QUrlQuery query(url);
|
||||||
|
|
||||||
// Percent encode the hash
|
// Percent encode the hash
|
||||||
QByteArray infoHash = torrentDownloader->infoHash();
|
const QByteArray infoHash = torrentDownloader->infoHash();
|
||||||
QByteArray encodedSum;
|
const QByteArray encodedSum = infoHash.toPercentEncoding();
|
||||||
for (int i = 0; i < infoHash.size(); ++i) {
|
|
||||||
encodedSum += '%';
|
|
||||||
encodedSum += QByteArray::number(infoHash[i], 16).right(2).rightJustified(2, '0');
|
|
||||||
}
|
|
||||||
|
|
||||||
bool seeding = (torrentDownloader->state() == TorrentClient::Seeding);
|
bool seeding = (torrentDownloader->state() == TorrentClient::Seeding);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user