-
Notifications
You must be signed in to change notification settings - Fork 7
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
Rewrite AsyncHttp\Client for cleaner API and Transfer-Encoding support #113
Merged
Conversation
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
An exploration to support Transfer-Encoding: chunked and Content-encoding: gzip. A larger refactor may need to follow.
adamziel
force-pushed
the
http-client-api-refactir
branch
from
July 14, 2024 14:39
ef41a68
to
2cda531
Compare
adamziel
changed the title
Refactor AsyncHttp\Client API
Rewrite AsyncHttp\Client for cleaner API and Transfer-Encoding support
Jul 15, 2024
adamziel
added a commit
to adamziel/site-transfer-protocol
that referenced
this pull request
Jul 15, 2024
The code got much simpler plus we can easily expand to stream-rewriting remote pages or even zip archives (with the ZIP Processor). See WordPress/blueprints-library#113
This was referenced Oct 24, 2024
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.
Refactors the
AsyncHttp\Client
to simplify the usage and the internal implementation. This will be helpful for rewriting URLs in WordPress posts and downloading the related assets.As a reminder,
AsyncHttp\Client
is a PHP HTTP client that can do asynchronous processing of multiple requests without curl or any other dependencies.Changes
await_next_event()
as a single, filterable interface for consuming all the HTTP activity. Remove theonProgress
callback and various other ways of waiting for information on specific requests.event_loop_tick()
function that runs all the available non-blocking operations.Client
class. It is now less generic, but I'd argue it already wasn't that generic and at least now we can avoid going back and froth between functions and that class.Transfer-Encoding: chunked
,Transfer-Encoding: gzip
, andContent-Encoding: gzip
via stream wrappers.Client
object so we no longer have to go out of our way to store data in stream context, struggle with stream filters, passthrough data between stream wrappers layers etc.This PR also ships an implementation of a HTTP proxy built with this client library – it could come handy for running an in-browser Git client:
https://github.com/WordPress/blueprints-library/blob/http-client-api-refactir/http_proxy.php
Usage example
HTTP Proxy example
Future work
cc @dmsnell @MayPaw @reimic