keepassxc
keepassxc copied to clipboard
Add NetworkRequest.
Adds a NetworkRequest class.
I have noticed that HTTP requests are implemented several times across the KeepassXC codebase (HibpDownloader, IconDownloader, and UpdateChecker). The implementations share a lot of boilerplate code but are inconsistent in how they handle certain implementation details:
- Some do not use timeouts
- Some allow redirects (s.t. a maximum number of hops)
- Some set a User-Agent header
Imho, these aspects should default to common behavior unless overwritten.
I've implemented a simple NetworkRequest class that implements all of this functionality in a central class and would like to receive some feedback on whether to go forward with this, that is, to add sensible defaults, write tests, etc., or if we prefer to keep implementations separate.
Next steps
- [x] Make request single shot
- [x] Add parameter to disallow insecure protocols (http)
- [x] Write tests for the NetworkRequest class
- [x] Implement builder pattern
- [ ] Change the implementation of HibpDownloader, IconDownloader, and UpdateChecker) to use the NetworkRequest class
Type of change
- ✅ Refactor (significant modification to existing code)