Skip to content

Commit

Permalink
Only reset request headers after scenario if they were set
Browse files Browse the repository at this point in the history
Setting manual request headers on a Chrome instance seems
somewhat unlikely, but it is exposed by the Mink interface
and implemented by the driver so they do need to be cleaned
up as part of ->reset() if present.

However, if the browser or devtools connection has crashed /
hit a problemn then calling Network.setExtraHttpHeaders can
fail in a way that masks and/or makes it harder to trace the
actual failure.

Therefore, avoid sending this call unless it is actually
required (e.g. some custom headers have been set since the
session started or was last reset).
  • Loading branch information
acoulton committed Oct 1, 2024
1 parent 74528a2 commit 7106c4b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ChromeDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,10 @@ public function reset()
}
$this->switchToWindow($this->main_window);
$this->page->reset();
$this->request_headers = [];
$this->sendRequestHeaders();
if ($this->request_headers !== []) {
$this->request_headers = [];
$this->sendRequestHeaders();
}
}

/**
Expand Down

0 comments on commit 7106c4b

Please sign in to comment.