fix: support X-WWW-Authenticate fallback in DigestAuth
AD
1d ago+65+65+01234567890123456789-2-2-0123456789
Summary
Fixes #846.
Some devices, such as Fronius solar inverters, return the non-standard X-WWW-Authenticate header instead of WWW-Authenticate when requesting Digest authentication.
Currently, DigestAuth ignores this header, preventing authentication from proceeding.
This PR adds support for X-WWW-Authenticate as a fallback while preserving existing behaviour:
- Prefer the standard
WWW-Authenticateheader when both are present. - Use
X-WWW-Authenticateonly when the standard header is absent. - Ignore invalid authentication challenges and non-401 responses.
Testing:
- Added regression tests covering both authentication headers, header precedence and invalid challenges.
- Full test suite passed across Python 3.11 to 3.15.
- Linting, type checking and security analysis passed.
- CodSpeed benchmark tests passed, but uploading results from the fork failed due to a 401 authorisation error.
Checklist
- I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
- I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- I've reviewed the documentation requirements. No documentation changes are needed because this is a bug fix that introduces no new public API.