Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

Goutte setup allow_redirects=false for Guzzle, while inherits $followRedirects=true from BrowserKit

Open karser opened this issue 6 years ago • 0 comments

Hello.

Throughout the Goutte client, the allow_redirects is set to false. I tend to agree with this because I use it for tests.

The issue is that in the abstract BrowserKit Client, which the Goutte client extends from, the variable followRedirects is set to true. So that forms submission automatically follows location.

abstract class Client
    protected $followRedirects = true;

As a workaround, this option has to be set manually:

$client->followRedirects(false);
$client->submitForm('Click me', [])

The solution is to override the default value of $followRedirects from the BrowserKit Client:

namespace Goutte;

class Client extends BaseClient {
    protected $followRedirects = false;

This change fixes inconsistency, but also introduces a BC break though.

karser avatar May 03 '19 18:05 karser