diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 616637c..36b3c05 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -21,7 +21,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Guzzle\Http\Exception\RequestException; +use GuzzleHttp\Exception\RequestException; /** * @file @@ -1580,8 +1580,8 @@ function install_retrieve_file($uri, $destination) { } try { - $request = \Drupal::httpClient()->get($uri, array('Accept' => 'text/plain')); - $data = $request->send()->getBody(TRUE); + $request = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain'))); + $data = $request->getBody(TRUE); if (empty($data)) { return FALSE; } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php index 611fc46..d839df1 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -69,7 +69,7 @@ public function fetch(FeedInterface $feed) { } try { - $response = $request->send(); + $response = $this->httpClient->send($request); // In case of a 304 Not Modified, there is no new content, so return // FALSE. diff --git a/core/modules/aggregator/tests/modules/aggregator_test/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php b/core/modules/aggregator/tests/modules/aggregator_test/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php index 8aaf8e0..8c06a96 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php +++ b/core/modules/aggregator/tests/modules/aggregator_test/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php @@ -10,7 +10,6 @@ use Drupal\aggregator\Plugin\FetcherInterface; use Drupal\aggregator\Plugin\aggregator\fetcher\DefaultFetcher; use Drupal\aggregator\FeedInterface; -use Guzzle\Http\Exception\BadResponseException; /** * Defines a test fetcher implementation. diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index 5085a2b..ae0ea48 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -5,8 +5,7 @@ * Batch process to check the availability of remote or local po files. */ -use Guzzle\Http\Exception\BadResponseException; -use Guzzle\Http\Exception\RequestException; +use GuzzleHttp\Exception\RequestException; /** * Load the common translation API. @@ -231,9 +230,7 @@ function locale_translation_batch_fetch_finished($success, $results) { function locale_translation_http_check($uri) { try { - $response = \Drupal::httpClient() - ->head($uri) - ->send(); + $response = \Drupal::httpClient()->head($uri); $result = array(); // Return the effective URL if it differs from the requested. @@ -244,7 +241,7 @@ function locale_translation_http_check($uri) { $result['last_modified'] = $response->getLastModified() ? strtotime($response->getLastModified()) : 0; return $result; } - catch (BadResponseException $e) { + catch (RequestException $e) { // Handle 4xx and 5xx http responses. $response = $e->getResponse(); if ($response->getStatusCode() == 404) { @@ -258,11 +255,7 @@ function locale_translation_http_check($uri) { } watchdog('locale', 'HTTP request to @url failed with error: @error.', array('@url' => $uri, '@error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase())); } - catch (RequestException $e) { - // Handle connection problems and cURL specific errors (CurlException) and - // other http related errors. - watchdog('locale', 'HTTP request to @url failed with error: @error.', array('@url' => $uri, '@error' => $e->getMessage())); - } + return FALSE; } diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php index e1dc9f6..9f90a27 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsReportsTest.php @@ -37,7 +37,7 @@ function testPopularContentBlock() { global $base_url; $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php'; $client = \Drupal::httpClient(); - $client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10))); + $client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10)); $client->post($stats_path, $headers, $post)->send(); // Configure and save the block. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index 712c5ab..e6d17cb 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -41,7 +41,7 @@ function testStatisticsTokenReplacement() { global $base_url; $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php'; $client = \Drupal::httpClient(); - $client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10))); + $client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10)); $client->post($stats_path, $headers, $post)->send(); $statistics = statistics_get($node->id()); diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php index 7d3e567..e417f27 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/Views/IntegrationTest.php @@ -83,8 +83,8 @@ public function testNodeCounterIntegration() { global $base_url; $stats_path = $base_url . '/' . drupal_get_path('module', 'statistics'). '/statistics.php'; $client = \Drupal::httpClient(); - $client->setConfig(array('curl.options' => array(CURLOPT_TIMEOUT => 10))); - $client->post($stats_path, array(), array('nid' => $this->node->id()))->send(); + $client->setDefaultOption('config/curl', array(CURLOPT_TIMEOUT => 10)); + $client->post($stats_path, array(), array('nid' => $this->node->id())); $this->drupalGet('test_statistics_integration'); $expected = statistics_get($this->node->id()); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 7b35fca..b08039e 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -18,8 +18,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; -use Guzzle\Http\Exception\BadResponseException; -use Guzzle\Http\Exception\RequestException; +use GuzzleHttp\Exception\RequestException; /** * Maximum age of temporary files in seconds. @@ -1690,11 +1689,6 @@ function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $repl ->getBody(TRUE); $local = $managed ? file_save_data($data, $path, $replace) : file_unmanaged_save_data($data, $path, $replace); } - catch (BadResponseException $exception) { - $response = $exception->getResponse(); - drupal_set_message(t('Failed to fetch file due to HTTP error "%error"', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase())), 'error'); - return FALSE; - } catch (RequestException $exception) { drupal_set_message(t('Failed to fetch file due to error "%error"', array('%error' => $exception->getMessage())), 'error'); return FALSE; diff --git a/core/modules/update/tests/Drupal/update/Tests/UpdateFetcherTest.php b/core/modules/update/tests/Drupal/update/Tests/UpdateFetcherTest.php index e43a3ae..4b55261 100644 --- a/core/modules/update/tests/Drupal/update/Tests/UpdateFetcherTest.php +++ b/core/modules/update/tests/Drupal/update/Tests/UpdateFetcherTest.php @@ -39,7 +39,7 @@ public static function getInfo() { */ protected function setUp() { $config_factory = $this->getConfigFactoryStub(array('update.settings' => array('fetch_url' => 'http://www.example.com'))); - $this->updateFetcher = new UpdateFetcher($config_factory, $this->getMock('Guzzle\Http\Client')); + $this->updateFetcher = new UpdateFetcher($config_factory, $this->getMock('Drupal\Core\Http\Client')); } /** diff --git a/core/modules/xmlrpc/xmlrpc.inc b/core/modules/xmlrpc/xmlrpc.inc index 445993a..cb2180e 100644 --- a/core/modules/xmlrpc/xmlrpc.inc +++ b/core/modules/xmlrpc/xmlrpc.inc @@ -11,8 +11,7 @@ * This version is made available under the GNU GPL License */ -use Guzzle\Http\Exception\BadResponseException; -use Guzzle\Http\Exception\RequestException; +use GuzzleHttp\Exception\RequestException; /** * Turns a data structure into objects with 'data' and 'type' attributes. @@ -561,15 +560,11 @@ function _xmlrpc($url, array $args, array $headers = array()) { $args = $args[$method]; } $xmlrpc_request = xmlrpc_request($method, $args); - $request = \Drupal::httpClient()->post($url, $headers, $xmlrpc_request->xml); - $request->setHeader('Content-Type', 'text/xml'); + + $headers['Content-Type'] = 'text/xml'; + try { - $response = $request->send(); - } - catch (BadResponseException $exception) { - $response = $exception->getResponse(); - xmlrpc_error($response->getStatusCode(), $response->getReasonPhrase()); - return FALSE; + $response = \Drupal::httpClient()->post($url, array('headers' => $headers, 'body' => $xmlrpc_request->xml)); } catch (RequestException $exception) { xmlrpc_error(NULL, $exception->getMethod());