php-http / utils

[DEPRECATED] HTTP Client Utilities
http://httplug.io
MIT License
2 stars 8 forks source link

Is it possible to use plugins with HttpMethodsClient? #31

Closed ollietb closed 7 years ago

ollietb commented 7 years ago

This is my logic

    $client = new HttpMethodsClient($client, $messageFactory);
    $this->http = new PluginClient(
          $client,
          [$headerSetPlugin, $contentLengthPlugin]
    );

    $response = $this->http->post($path, $headers, $body);

I get the error Fatal error: Call to undefined method Http\Client\Common\PluginClient::get()

How can I use the methods of HttpMethodsClient with those plugins?

fbourigault commented 7 years ago

Hello, you have wrap the PluginClient into the HttpMethodsClient:

    $client = new PluginClient(
          $client,
          [$headerSetPlugin, $contentLengthPlugin]
    );
    $this->http = new HttpMethodsClient($client, $messageFactory);

    $response = $this->http->post($path, $headers, $body);
Nyholm commented 7 years ago

Also, this library is deprecated. You should use php-http/common