Releases: gocanto/http-client
Releases · gocanto/http-client
PHP Version + Quality tools
Guzzle + PHP updates
Updates dependencies + code clean up.
Ref: #6
Add request headers on demand
Sometimes, we need to add headers to a given client
instance based on dynamic data.
Such as requirement is not possible on the creation stage because we do not know what information we would be dealing with. Therefore, we need a mechanism to hook into and populate this data when needed.
This PR
adds a new method withHeaders to allow on-demand headers values whenever needed.
For instance, you would be able to do something like so:
$client = new HttpClient;
$client->withHeaders([
'X-GUS-1' => 'testing testing',
'X-GUS-2' => 'testing testing',
'X-GUS-3' => 'testing testing',
'X-GUS-4' => 'testing testing',
])->request('GET', 'https://foo.com');
to populate as many headers as needed.
Note
You can still call other methods on the client because of the immutability nature of the given method.
You will be able to see the PR body here
First release
1.0.0 add examples