It works. This lib is able to parse dummy response from the dummy webserver and the actual call for resources can be accomplished.
Failure case
When you start a webserver to sleep for more than 10 seconds between sending headers and body (that's the timeout for the whole request), there is a problem.
Note no retries are passed, so RetryModifyRequestMiddleware sets retries to 0.
What happens is Symfony\Component\Debug\Exception\ContextErrorException is thrown with:
Catchable Fatal Error: Argument 2 passed to Frankkessler\Guzzle\Oauth2\Oauth2Client::Frankkessler\Guzzle\Oauth2\{closure}() must implement interface Psr\Http\Message\RequestInterface, none given in vendor/frankkessler/guzzle-oauth2-middleware/src/Oauth2Client.php on line 69
(...)
What's wrong
Not sure yet. Something breaks in promise resolution. Any help with debugging will be greatly appreciated.
EDIT: The same actually happens for the main request too. I set up a proof of concept using bare Guzzle 6.2.1 and it works as expected. This is clearly an issue with the way middlewares are hooked up.
EDIT 2: If you find a dummy webserver using nc misbehaving, here's the same using socat:
Hi, so I wanted to test my client that uses this library for Oauth2 flow and I noticed couple of problems.
Background
For reproduction sake, let's start a dummy webserver using
netcat
:Every request to
localhost:9005
will first establish connection immediately, wait for 1s and print the answer. Actual body response doesn't matter.Don't mind my example above. The way to simulate delays in webserver is irrelevant; use what you want.
Success case
Let's configure
Oauth2Client
with the following config:It works. This lib is able to parse dummy response from the dummy webserver and the actual call for resources can be accomplished.
Failure case
When you start a webserver to sleep for more than 10 seconds between sending headers and body (that's the timeout for the whole request), there is a problem.
Note no
retries
are passed, soRetryModifyRequestMiddleware
sets retries to 0. What happens isSymfony\Component\Debug\Exception\ContextErrorException
is thrown with:What's wrong
Not sure yet. Something breaks in promise resolution. Any help with debugging will be greatly appreciated.
EDIT: The same actually happens for the main request too. I set up a proof of concept using bare Guzzle 6.2.1 and it works as expected. This is clearly an issue with the way middlewares are hooked up.
EDIT 2: If you find a dummy webserver using nc misbehaving, here's the same using
socat
: