contexts icon indicating copy to clipboard operation
contexts copied to clipboard

The method resetHttpHeaders removes SCRIPT_FILENAME from the headers

Open NicolasDievart opened this issue 8 years ago • 1 comments

Hi,

I wanted to update from 2.7.1 to 3.0.1 today, and by doing so, I am facing fail in my test suite. I have a suite of scenario that are doing GET/POST request and I check the responses status and responses body. In 2.8.0, you introduce the resetHttpHeaders between requests which seems to be quite natural. However, this methods cleans all the headers (except the HTTP_USER_AGENT which is hard setted by BrowserKit/Client), even the SCRIPT_FILENAME header added from the base_url option in the BrowserKitDriver of Mink.

My first request hit without problem and this scenario passes, but my next one fails as it does not have the header "SCRIPT_FILENAME" => "/app_test.php".

I tried to re-add the header before the request via the context: I add :name header equal to :value, but it forces the HTTP_ prefix, so I can not add the SCRIPT_FILENAME header anymore.

I may be missing something there, as I can not found a workaround on this except maybe split my scenarios into multiple features which I would like to avoid.

NicolasDievart avatar Dec 14 '17 16:12 NicolasDievart

I have the same behaviour when upgrading from 2.7.1 to 2.8.0 or 2.8.1 and I diagnose the same thing (a call to resetHttpHeaders introduced by https://github.com/Behatch/contexts/commit/4cc6cfcab8914a76403dc044b450cb3a91e0651a ).

The impacted header for me is Authorization, which is quite annoying to reset on every http call as you can imagine :p .

As I understand the purpose of the fix, maybe we can find an issue to allow user to set temporary or "permanent headers ?

Maybe two different command:

Given I add the foo header equal to bar # if you think headers should be temporary
Given I add the foo permanent header equal to bar

or

Given I add the foo header equal to bar # if you think headers should be permanent
Given I add the foo temporary header equal to bar

Thank you

jdeniau avatar Feb 13 '18 08:02 jdeniau