For three reasons:
- There are only 31 of them, and we don't really expect any more to
turn up (last happened in 2013, and we have a test for it happening)
- It makes for nicer debug output
- It always felt strange to only have a small subset in the enum
With Qt 6.4, it looks like the full UA disappeared from the ELF string
table - see previosly: db1382f75c
However, the full Chromium version string is still stored separately,
most likely for qWebEngineChromiumVersion() - so let's go hunt for that.
Note that this code won't be used for most situations, as with an up-to-
date PyQt, we finally have an API to access this information properly.
But it's still useful as a fallback in strange situations like running
an older PyQt against a newer Qt.
See #7314
This avoids the temptation of creating a Qt.Key() manually, which needs
to be checked for ValueError with PyQt 6.2 due to its handling of unknown enum
values.
This is exactly what happened in RegisterKeyParser, which caused such a
ValueError:
https://github.com/qutebrowser/qutebrowser/issues/7047#issuecomment-1163288560Closes#7047
With Qt 6, the default changed to Qt handling network redirects instead of us
doing so manually. This seems like a good thing, so instead of setting the
redirect policy back to QNetworkRequest.RedirectPolicy.ManualRedirectPolicy,
let's just let Qt handle everything.
By default, Qt allows 50 redirects before giving up. That seems a tad much, so
we set it back to our former default.
This change comes with a few changes in behavior:
- Redirects to the same URL now fail (too many redirects) rather than being
ignored. I'm not sure how the previous behavior was useful. We added it in the
initial implemetation in 6856c49be9 (later
refactored a bit in 70e390a2e8) and added a test
in d13f88f0ac. But it doesn't make sense...
- We use QNetworkRequest.RedirectPolicy.NoLessSafeRedirectPolicy (no HTTPS ->
HTTP redirects allowed), while the former behavior didn't validate redirects
at all. Interestingly enough, I can't get Chromium to error out in that case
for downloads (though I only tried on localhost with a self-signed
certificate). However, it seems like a reasonable default.
Test will be added in a follow-up commit.
- Partially downloaded files aren't deleted anymore on a "too many redirect"
error. This should be solved in a more generic way, will do so in a follow-up
commit.
TODO: Pick to master?
Fixes#2679.
The existing logic seems to work fine now (with some adjustments) and results in
better output compared to the repr.
Partially reverts 111e0c7f3dcccb4d0ff807854cacb6506a93e1f2.