public function Http::getResponse in Migrate Plus 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/migrate_plus/data_fetcher/Http.php \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http::getResponse()
- 8 src/Plugin/migrate_plus/data_fetcher/Http.php \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http::getResponse()
- 8.2 src/Plugin/migrate_plus/data_fetcher/Http.php \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http::getResponse()
- 8.3 src/Plugin/migrate_plus/data_fetcher/Http.php \Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http::getResponse()
Return Http Response object for a given url.
Parameters
string $url: URL to retrieve from.
Return value
\Psr\Http\Message\ResponseInterface The HTTP response message.
Overrides DataFetcherPluginInterface::getResponse
1 call to Http::getResponse()
- Http::getResponseContent in src/
Plugin/ migrate_plus/ data_fetcher/ Http.php - Return content.
File
- src/
Plugin/ migrate_plus/ data_fetcher/ Http.php, line 96
Class
- Http
- Retrieve data over an HTTP connection for migration.
Namespace
Drupal\migrate_plus\Plugin\migrate_plus\data_fetcherCode
public function getResponse($url) {
try {
$options = [
'headers' => $this
->getRequestHeaders(),
];
if (!empty($this->configuration['authentication'])) {
$options = array_merge($options, $this
->getAuthenticationPlugin()
->getAuthenticationOptions());
}
$response = $this->httpClient
->get($url, $options);
if (empty($response)) {
throw new MigrateException('No response at ' . $url . '.');
}
} catch (RequestException $e) {
throw new MigrateException('Error message: ' . $e
->getMessage() . ' at ' . $url . '.');
}
return $response;
}