The 4096-character truncation in scrapy.utils.response.get_base_url
and get_meta_refresh caused the <base href> tag to be silently missed
whenever it appeared after that offset (e.g. when a large inline
script, comment block, or whitespace precedes the <head> section).
In those cases Scrapy fell back to the response URL, producing wrong
absolute links and mis-resolved relative URLs.
Remove the truncation so the full response text is searched, which
is the correct behaviour. The results are still cached per-response
via WeakKeyDictionary, so the performance impact is bounded to a
single regex pass over the document text.
Closes#3017
* Switch to pytest.raises().
* Add matches= to broad pytest.raises().
* Adjust the test_nonserializable_object() regex for Python <= 3.11.
* Adjust the test_nonserializable_object() regex for PyPy.
* Adjust other test exception regexes for PyPy.
* Cleanup.
utility is used in retry middleware and it was failing to handle non-standard HTTP codes.
Instead of raising exceptions when passing through to_native_str it should return
"Unknown status" message.