Display HTTP error codes instead of "Invalid data from tracker" in tracker status
ClosedPublic

Authored by trufanov on Nov 10 2019, 3:45 PM.

Details

Summary

In case http tracker gets HTTP Error (like 403 Forbidden if someone forgot to pay for domain or 503 Server error) KTorrent displays "Invalid data from tracker" error string. This is misleading and not helping to detect real roots of the problem. I think it'll be better to display HTTP error code instead of this. For ex, "Error: HTTP 403"

"Invalid data from tracker" error message is generated because KTransferrJob's error is 0 while replyData contains some valid HTML like

<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
</body>
</html>

But our case still can be detected with KTransferJob::IsErrorPage() == true and it's metadata contains HTTP error code at "responsecode" key. So we don't need to parse the reply.

Was:

Now:

Test Plan

The attached patch can be tested by manual addition of https://httpstat.us/403 as a new tracker in torrent. Or http://retracker.local/announce is usually broken nowadays while still added to torrent files by many web trackers.

Diff Detail

Repository
R472 KTorrent Library
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
trufanov requested review of this revision.Nov 10 2019, 3:45 PM
trufanov created this revision.
stikonas accepted this revision.Nov 10 2019, 3:48 PM

Yes, I agree, the new error is better.

This revision is now accepted and ready to land.Nov 10 2019, 3:48 PM
This revision was automatically updated to reflect the committed changes.