|
26 | 26 | */ |
27 | 27 | class HttpCommandExecutor implements WebDriverCommandExecutor |
28 | 28 | { |
| 29 | + const DEFAULT_HTTP_HEADERS = [ |
| 30 | + 'Content-Type: application/json;charset=UTF-8', |
| 31 | + 'Accept: application/json', |
| 32 | + ]; |
| 33 | + |
29 | 34 | /** |
30 | 35 | * @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#command-reference |
31 | 36 | */ |
@@ -169,14 +174,7 @@ public function __construct($url, $http_proxy = null, $http_proxy_port = null) |
169 | 174 |
|
170 | 175 | curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); |
171 | 176 | curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, true); |
172 | | - curl_setopt( |
173 | | - $this->curl, |
174 | | - CURLOPT_HTTPHEADER, |
175 | | - [ |
176 | | - 'Content-Type: application/json;charset=UTF-8', |
177 | | - 'Accept: application/json', |
178 | | - ] |
179 | | - ); |
| 177 | + curl_setopt($this->curl, CURLOPT_HTTPHEADER, static::DEFAULT_HTTP_HEADERS); |
180 | 178 | $this->setRequestTimeout(30000); |
181 | 179 | $this->setConnectionTimeout(30000); |
182 | 180 | } |
@@ -266,7 +264,9 @@ public function execute(WebDriverCommand $command) |
266 | 264 | if (in_array($http_method, ['POST', 'PUT'])) { |
267 | 265 | // Disable sending 'Expect: 100-Continue' header, as it is causing issues with eg. squid proxy |
268 | 266 | // https://tools.ietf.org/html/rfc7231#section-5.1.1 |
269 | | - curl_setopt($this->curl, CURLOPT_HTTPHEADER, ['Expect:']); |
| 267 | + curl_setopt($this->curl, CURLOPT_HTTPHEADER, array_merge(static::DEFAULT_HTTP_HEADERS, ['Expect:'])); |
| 268 | + } else { |
| 269 | + curl_setopt($this->curl, CURLOPT_HTTPHEADER, static::DEFAULT_HTTP_HEADERS); |
270 | 270 | } |
271 | 271 |
|
272 | 272 | $encoded_params = null; |
|
0 commit comments