-
-
Notifications
You must be signed in to change notification settings - Fork 73
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 async support #323
base: master
Are you sure you want to change the base?
Add async support #323
Conversation
I guess we could introduce a dependency on a concrete promise library such as https://github.com/reactphp/promise/tree/2.x |
I never worked on async/promise on PHP so I might not be able to properly review it. But will it force people to use async/promise or will they still be able to use the sync way like before? |
We can provide sync api by just calling |
Tests depend on j0k3r/httplug-ssrf-plugin#10 |
ade7370
to
5c6ba77
Compare
Will want to finish #324 first, since that way conflicts are easier to resolve. |
4738de6
to
6b7495b
Compare
It does not support async requests.
It is sync only.
Previous versions broke async clients.
It will still be converted to a dual async/sync one by `PluginClient`.
The diff is ugly but I just: - removed the try block - moved the code after the catch blocks inside the first closure argument of `then` - changed the catch blocks into `if`s with `instanceof` checks - moved them to the second closure argument of `then` - replaced `fetch` with `fetchAsync` Unfortunately, HTTPlug’s `HttpFulfilledPromise` is broken (does not allow to be converted to another promise type and only supports resolving with `ResponseInterface`) so we need the ugly hack in `makePromise` to convert it into a promise object from a full-fledged promise library. I considered ReactPHP’s promise library first but those promises are not natively waitable in version 2.0 and using custom busy-loop waiting or third-party wait (from choval/async) just seemed to block. In the end, I went with Guzzle’s promise library.
Unfortunately, it currently does not work because
HttpFulfilledPromise
is broken (does not allow to be converted to another promise type).