minkphp / MinkGoutteDriver

Goutte driver for Mink framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setRequestHeader doesn't set header on the Goutte client instance

asprega opened this issue · comments

I was expecting that, in a Mink context, calling

$this->getSession()->getDriver()->getClient()->setRequestHeader('Accept-Language', 'en');

had the same outcome as

$this->getSession()->setRequestHeader('Accept-Language', 'en');

But actually it doesn't, and the call gets "ignored". This is because the Goutte driver uses the same implementation of BrowserKit, which of course has no knowledge of the Guzzle HTTP client, so it doesn't provide it with the header. I'd like to know if this a real issue or I misundertood something. In the former case, I'll do a pull request.

commented

Does $this->getSession()->setRequestHeader('Accept-Language', 'en'); work for you?

If so, then why you attempt to call $this->getSession()->getDriver()->getClient()->setRequestHeader('Accept-Language', 'en');?

This is not the same, because we need to be able to reset headers when resetting the driver, which is why we don't store this state in the BrowserKit client directly.
But we are sending the headers when performing requests with the client (as seen in driver tests)

Both you guys are right, my issue was somewhere else and for a weird coincidence it led me to believe that it was caused by the absence of the header, which is sent instead. My apologies, closing the issue.