Commit 5106e36c authored by catch's avatar catch
Browse files

Issue #1887046 by Sutharsan: Convert drupal_http_request() usage in install.core.inc to Guzzle.

parent 4eaf4157
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Guzzle\Http\Exception\RequestException;
/** /**
* @file * @file
* API functions for installing Drupal. * API functions for installing Drupal.
...@@ -1450,7 +1452,7 @@ function install_download_translation(&$install_state) { ...@@ -1450,7 +1452,7 @@ function install_download_translation(&$install_state) {
} }
/** /**
* Attempts to get a file using drupal_http_request and to store it locally. * Attempts to get a file using a HTTP request and to store it locally.
* *
* @param string $uri * @param string $uri
* The URI of the file to grab. * The URI of the file to grab.
...@@ -1472,14 +1474,18 @@ function install_retrieve_file($uri, $destination) { ...@@ -1472,14 +1474,18 @@ function install_retrieve_file($uri, $destination) {
else { else {
$path = $destination; $path = $destination;
} }
$result = drupal_http_request($uri);
if ($result->code != 200) { try {
return FALSE; $request = drupal_container()->get('http_default_client')->get($uri, array('Accept' => 'text/plain'));
$data = $request->send()->getBody(TRUE);
if (empty($data)) {
return FALSE;
}
} }
if (file_put_contents($path, $result->data) === FALSE) { catch (RequestException $e) {
return FALSE; return FALSE;
} }
return TRUE; return file_put_contents($path, $data) !== FALSE;
} }
/** /**
...@@ -1489,12 +1495,17 @@ function install_retrieve_file($uri, $destination) { ...@@ -1489,12 +1495,17 @@ function install_retrieve_file($uri, $destination) {
* The URI to contact. * The URI to contact.
* *
* @return string * @return string
* URI of the server if the localization server was contacted successfully. * TRUE if the URI was contacted successfully, FALSE if not.
* FALSE if not.
*/ */
function install_check_localization_server($uri) { function install_check_localization_server($uri) {
$result = drupal_http_request($uri, array('method' => 'HEAD')); try {
return (!isset($result->error) && $result->code == 200); $request = drupal_container()->get('http_default_client')->head($uri);
$response = $request->send();
return TRUE;
}
catch (RequestException $e) {
return FALSE;
}
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment