minkphp / MinkGoutteDriver

Goutte driver for Mink framework
MIT License
299 stars 52 forks source link

setRequestHeader doesn't set header on the Goutte client instance #66

Closed asprega closed 9 years ago

asprega commented 9 years ago

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.

aik099 commented 9 years ago

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');?

stof commented 9 years ago

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)

asprega commented 9 years ago

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.