From 5c602bf5bb1e564ef677fd2f14b0eeef8fba3073 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Thu, 12 May 2016 13:26:07 +0100 Subject: [PATCH] MDL-54553 behat: check statuscode of http request --- lib/behat/classes/util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index cfcbf8bf154..a24ab5be816 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -151,9 +151,10 @@ class behat_util extends testing_util { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); + $statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); - if (empty($result)) { + if ($statuscode !== 200 || empty($result) || (!$result = json_decode($result, true))) { behat_error (BEHAT_EXITCODE_REQUIREMENT, $CFG->behat_wwwroot . ' is not available, ensure you specified ' . 'correct url and that the server is set up and started.' . PHP_EOL . ' More info in ' . @@ -161,7 +162,6 @@ class behat_util extends testing_util { } // Check if cli version is same as web version. - $result = json_decode($result, true); $clienv = self::get_environment(); if ($result != $clienv) { $output = 'Differences detected between cli and webserver...'.PHP_EOL; -- 2.43.0