Guzzle6 has one pretty option: allow_redirects. If setting this option to false value, Guzzle blocking redirect if response code like 302 or Headers has Location param.
But there is one problem. If redirect sends by client – Guzzle doesn't notice this. For example:
We have some URL http://example.com/ that redirected to page http://redirected.com/. Send request with help Guzzle:
$oClient->request('POST', 'http://redirected.com/', [
'form_params' => $aFormData,
'cookies' => (new CookieJar($aPrepareCookie)),
'debug' => true,
'allow_redirects' => false
]);
Suppose that redirect.com has index.php like this:
<?php
header('Location: http://www.example.com/');
?>
In this case, the redirection will be blocked from Guzzle.
Now, let's see this redirect example:
<?php
echo '<script>window.location = "http://www.example.com/";</script>';
?>
Here we have a problem because this is client side redirect and his can't affect the Headers, Therefore Guzzle can't track HTTP Status Code or Location value.
So, how i can solve this problem and find solution?
Thanks for help!