Repository navigation
Allow injecting a PSR-18 HTTP client and PSR-16 cache - #6
Merged
Merged
Conversation
Client optionally accepts a PSR-18 client, a PSR-17 request factory and a PSR-16 cache. When an HTTP client is given it is used for both the IANA bootstrap files and the RDAP queries; the cache stores the bootstrap files. Without arguments the existing file_get_contents() and temporary file cache behaviour is unchanged. Closes ArrayAccess#5
Author
|
Thanks for merging this so quickly! Would you be able to tag a release so it can be installed through Composer? The latest tag is still I also opened a few small bug fixes found while working on this, in case you want to include them in the same release:
They are independent of each other. If you'd rather not review them now, tagging what's on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the proposal from #5.
What it does
Clientoptionally accepts a PSR-18 HTTP client, a PSR-17 request factory and a PSR-16 cache:RequestFactoryInterface(e.g. Symfony'sPsr18Client). AnInvalidArgumentExceptionis thrown if neither provides one.AbstractRdapService::cacheExpirations()seconds. Content is only cached after it validates, and an invalid cache entry is deleted and fetched again.ignore_errors => truein the stream context), so RDAP error payloads still becomeRdapResponseException. Transport failures, and error statuses with an empty body, becomeRdapRemoteRequestExceptionwith the HTTP status as the code.Backwards compatibility
Without arguments, the existing
file_get_contents()requests and the temporary-file bootstrap cache are unchanged. No existing interface signature changes:RdapHttpClientAwareInterfacethatClientimplements;RdapClientInterfaceis untouched.AbstractRdapServicegets a newfromJson(), whichfromURL()now uses for validation.RdapServiceInterface::fromURL()keeps its signature.The new requirements are the interface-only packages
psr/http-client,psr/http-factoryandpsr/simple-cache(^1.0 || ^2.0 || ^3.0).Testing
composer validate --strict, phpcs and phpstan (level 8, also withphpVersion: 80100) pass.Psr18Client+ PSR-16 cache (IPv6 via RIPE, second client served the bootstrap file from cache), and a 404 from Verisign surfacing asRdapRemoteRequestExceptionwith code 404.Closes #5