handle redirection loop #93

KernelFolla opened this Issue Jan 18, 2013 · 1 comment


None yet

2 participants


browserkit redirection don't handle a loop of redirects, i can only disable or enable the redirection.

So i have this loop and can't catch it:

Symfony\Component\BrowserKit\Client->request( ) ..\Client.php:423
Symfony\Component\BrowserKit\Client->followRedirect( )  ..\Client.php:274

for my problem, i've solved it catching the loop in createResponse

class MyClient extends Client{
    const MAX_REDIRECTS = 5;

    public $redirectCount = 0;

    public function request($x, $y){
        return parent::request($x,$y);

    protected function createResponse(GuzzleResponse $response)
        return parent::createResponse($response);

    protected function checkRedirectionLoop($statusCode){
        $isRedirect = $statusCode == 301 || $statusCode == 302;
            if($this->redirectCount >= self::MAX_REDIRECTS){
                $this->redirectCount = 0;
                throw new Exception('intercepted loop of redirects');
            $this->redirectCount = 0;

I believe this is old and has been fixed. I have a recent version and solve the problem this way:

$client = new Client();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment