Issue #1887046 by Sutharsan: Convert drupal_http_request() usage in install.core.inc to Guzzle.
parent
a62c75ed68
commit
bab6874e84
|
@ -10,6 +10,8 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||||
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.
|
||||||
|
@ -1445,7 +1447,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.
|
||||||
|
@ -1467,14 +1469,18 @@ function install_retrieve_file($uri, $destination) {
|
||||||
else {
|
else {
|
||||||
$path = $destination;
|
$path = $destination;
|
||||||
}
|
}
|
||||||
$result = drupal_http_request($uri);
|
|
||||||
if ($result->code != 200) {
|
try {
|
||||||
|
$request = drupal_container()->get('http_default_client')->get($uri, array('Accept' => 'text/plain'));
|
||||||
|
$data = $request->send()->getBody(TRUE);
|
||||||
|
if (empty($data)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (RequestException $e) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (file_put_contents($path, $result->data) === FALSE) {
|
return file_put_contents($path, $data) !== FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1484,12 +1490,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue