Skip to content

Commit 99957bf

Browse files
committed
Fixes #118 - partial reverts PR #67 - handling legacy webdriver 4xx responses
1 parent 1650c80 commit 99957bf

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,17 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
181181
);
182182
}
183183

184-
// According to https://w3c.github.io/webdriver/webdriver-spec.html all 4xx responses are to be considered
185-
// an error and return plaintext, while 5xx responses are json encoded
186-
if ($httpCode >= 400 && $httpCode <= 499) {
187-
throw WebDriverException::factory(
188-
WebDriverException::CURL_EXEC,
189-
'Webdriver http error: ' . $httpCode . ', payload :' . substr($rawResult, 0, 1000)
190-
);
191-
}
192-
193184
$result = json_decode($rawResult, true);
194185

195186
if (! empty($rawResult) && $result === null && json_last_error() != JSON_ERROR_NONE) {
187+
// Legacy webdriver 4xx responses are to be considered // an error and return plaintext
188+
if ($httpCode >= 400 && $httpCode <= 499) {
189+
throw WebDriverException::factory(
190+
WebDriverException::CURL_EXEC,
191+
'Webdriver http error: ' . $httpCode . ', payload :' . substr($rawResult, 0, 1000)
192+
);
193+
}
194+
196195
throw WebDriverException::factory(
197196
WebDriverException::CURL_EXEC,
198197
'Payload received from webdriver is not valid json: ' . substr($rawResult, 0, 1000)

0 commit comments

Comments
 (0)