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

8.0.x
catch 2013-01-28 13:47:44 +00:00
parent a62c75ed68
commit bab6874e84
1 changed files with 22 additions and 11 deletions

View File

@ -10,6 +10,8 @@ use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Guzzle\Http\Exception\RequestException;
/**
* @file
* 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
* The URI of the file to grab.
@ -1467,14 +1469,18 @@ function install_retrieve_file($uri, $destination) {
else {
$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;
}
if (file_put_contents($path, $result->data) === FALSE) {
return FALSE;
}
return TRUE;
return file_put_contents($path, $data) !== FALSE;
}
/**
@ -1484,12 +1490,17 @@ function install_retrieve_file($uri, $destination) {
* The URI to contact.
*
* @return string
* URI of the server if the localization server was contacted successfully.
* FALSE if not.
* TRUE if the URI was contacted successfully, FALSE if not.
*/
function install_check_localization_server($uri) {
$result = drupal_http_request($uri, array('method' => 'HEAD'));
return (!isset($result->error) && $result->code == 200);
try {
$request = drupal_container()->get('http_default_client')->head($uri);
$response = $request->send();
return TRUE;
}
catch (RequestException $e) {
return FALSE;
}
}
/**