Skip to content

Commit 48524f2

Browse files
committed
Fixes #118 - partial reverts PR #67 - handling legacy webdriver 4xx responses
1 parent 200b8df commit 48524f2

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
@@ -133,18 +133,17 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
133133
);
134134
}
135135

136-
// According to https://w3c.github.io/webdriver/webdriver-spec.html all 4xx responses are to be considered
137-
// an error and return plaintext, while 5xx responses are json encoded
138-
if ($httpCode >= 400 && $httpCode <= 499) {
139-
throw WebDriverException::factory(
140-
WebDriverException::CURL_EXEC,
141-
'Webdriver http error: ' . $httpCode . ', payload :' . substr($rawResult, 0, 1000)
142-
);
143-
}
144-
145136
$result = json_decode($rawResult, true);
146137

147138
if (!empty($rawResult) && $result === null && json_last_error() != JSON_ERROR_NONE) {
139+
// Legacy webdriver 4xx responses are to be considered // an error and return plaintext
140+
if ($httpCode >= 400 && $httpCode <= 499) {
141+
throw WebDriverException::factory(
142+
WebDriverException::CURL_EXEC,
143+
'Webdriver http error: ' . $httpCode . ', payload :' . substr($rawResult, 0, 1000)
144+
);
145+
}
146+
148147
throw WebDriverException::factory(
149148
WebDriverException::CURL_EXEC,
150149
'Payload received from webdriver is not valid json: ' . substr($rawResult, 0, 1000)

0 commit comments

Comments
 (0)