woohoolabs / yang

The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-http plugin AddHostPlugin does not work with JsonApiRequestBuilder

Ilyes512 opened this issue · comments

Hey first off awesome library!!

I was already playing with php-http and so I was using AddHostPlugin.

However, the plugin is currently not useable in combination with yang because when you use the JsonApiRequestBuilder to create a request. It will set a (default) host in the request, which will have precedence over the client configured host.

I will see if I can extend JsonApiRequestBuilder and change the behaviour of getRequest() later.

I am definitely interested in your findings!

@Ilyes512 Is it possible to apply the AddHostPlugin after Yang has finished the processing? That way - using the replace option - the plugin could overwrite the host.

Or another solution could be to only set the host in the Request Builder when it is not empty. So instead of this:

$uri = $request
            ->getUri()
            ->withScheme($this->scheme)
            ->withHost($this->host)
            ->withPort($this->port);

we could conditionally set the values.

I am closing the ticket because of inactivity. If the problem becomes urgent, feel free to reopen it, and we can discuss how to proceed.

Thats ok :) Haven't been working on the project where I had this problem. I will probably be working on it in my next sprint. I will try and remember this.