-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for PSR-18 HTTP clients #826
Draft
jtojnar
wants to merge
15
commits into
simplepie:master
Choose a base branch
from
jtojnar:add-psr18-http-client-support-rebased
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9400f7d
Revert "Merge pull request #777 from Art4/add-psr18-http-client-support"
jtojnar 802d33a
Create Psr7Response and Psr18Client
Art4 58d812a
Psr18Client follows redirects
Art4 1092570
Add tests with local files for FileClient
Art4 b0427c9
Add tests with local files for Psr18Client
Art4 44cdd6b
SimplePieTest: materialize provider
Art4 7d64ada
Set SimplePie->$file to private
Art4 eddf1a1
Add SimplePie::set_http_client(), add tests
Art4 55bb279
Add integration test for loading a feed from cache
Art4 67528cc
Add integration tests for PSR-16 cache and PSR-18 client
Art4 089fe8f
Add code examples in README.markdown for PSR-18 HTTP client and PSR-1…
Art4 1f2881a
Deprecate method SimplePie\SimplePie::set_file()
Art4 35788eb
SimplePie: Remove redundant phpdoc annotations
Art4 6a188f8
Add Sanitize::set_http_client()
Art4 0427439
Add Locator::set_http_client()
Art4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can do anything about being passed a client that already handles redirects (like selfoss does).
We might not have other choice than adding support for each specific one. For example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a PSR-18 client handles the redirects they will return a PSR-7
Response
with a200
(or other then301||308
) status code. So we have no chance to get the final requested url. But this is not a problem becauseFile
will be deprecated and removed. I would not put any work into this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we need to get the permanent URL for features like fossar/selfoss#1178.
Unless we want to deprecate
SimplePie::$permanent_url
and expose theResponse
inSimplePie
so that apps could extract the permanent URL themselves.Or we could instruct consumers to not pass clients with
RedirectMiddleware
in the docs but that is error-prone.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should deprecate also
SimplePie::$permanent_url
while deprecatingFile
, and we should exposePsr\Http\Message\ResponseInterface
instead. The extraction of the permanent URL would be a detail of the provided PSR-18 client. This has to be discussed in future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at the Guzzle docs, their redirect middleware will apparently not be used when using Guzzle as PSR-18 client:
That means the PSR-18 client will not be aware that the requests are connected when we handle redirects ourselves and there will be no way to extract the permanent URL from it.