You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The HttpMethodsClient constructor allows to get an RequestFactory or RequestFactoryInterface as second parameter.
Both declare the createRequest but don't have the same argument.
RequestFactoryInterface::createRequest only have two parameters method and uri.
The HttpMethodsClient::send method which is used to make the HTTP call have two other parameters. So when using a PSR-17 implementation, the code will not work as the body and/or headers won't be sent.
php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0 should work correctly. You don't need two different psr7 implementations (Guzzle already provides one).
NB You can also use Guzzle 7: guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0.
I think you absolutely are right, and the reason I hadn't seen this bug before is because I happened to be using something that was also a PHP-HTTP request factory, and not just a PSR one. There is definitely a bug here. I will prepare a PR to fix this. :)
Activity
GrahamCampbell commentedon Jul 18, 2020
I cannot replicate this. Which particular client and request factory are you discovering. Maybe they have a bug?EDIT: I couldn't replicate this because my request factory happened to implement both interfaces.
jdecool commentedon Jul 18, 2020
I use
guzzle6-adapteras it doesn't provide a PSR-17 implementation, I use it withnyholm/psr7.But beyond that, if we look at the interfaces definitions:
And how the send method is implemented:
There is a problem.
Do you have an example with a working PSR-17 implementation ?
GrahamCampbell commentedon Jul 18, 2020
php-http/guzzle6-adapter:^2.0.1 http-interop/http-factory-guzzle:^1.0should work correctly. You don't need two different psr7 implementations (Guzzle already provides one).NB You can also use Guzzle 7:
guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0.jdecool commentedon Jul 18, 2020
Not working.
I use those dependencies:
With this code:
A debug in
HttpMethodsClient::send:And in it's implementation:
Headers are not set.
jdecool commentedon Jul 18, 2020
I don't understand how the code could work as the two interfaces allowed in the
HttpMethodsClientdon't have the same contract.GrahamCampbell commentedon Jul 18, 2020
Thanks for those details. Very helpful. :)
You don't need this line, in fact you should not add it.
Let me take a look at this in more detail...
GrahamCampbell commentedon Jul 18, 2020
I think you absolutely are right, and the reason I hadn't seen this bug before is because I happened to be using something that was also a PHP-HTTP request factory, and not just a PSR one. There is definitely a bug here. I will prepare a PR to fix this. :)
GrahamCampbell commentedon Jul 18, 2020
@jdecool Please let me know what you think of #202.
jdecool commentedon Jul 18, 2020
Look good to me