Skip to content

Commit

Permalink
Merge pull request #4076 from stefan-korn/remote-type-try-catch
Browse files Browse the repository at this point in the history
#4075: Catch Guzzle Exception to avoid breaking harvest
  • Loading branch information
paul-m authored Dec 19, 2023
2 parents 00bfcb5 + e24842b commit 71ed465
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/metastore/src/Reference/Referencer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Drupal\metastore\ResourceMapper;

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\GuzzleException;

/**
* Metastore referencer service.
Expand Down Expand Up @@ -343,7 +344,12 @@ private function getRemoteMimeType(string $downloadUrl): ?string {
// Perform HTTP Head request against the supplied URL in order to determine
// the content type of the remote resource.
$client = new GuzzleClient();
$response = $client->head($downloadUrl);
try {
$response = $client->head($downloadUrl);
}
catch (GuzzleException $exception) {
return $mime_type;
}
// Extract the full value of the content type header.
$content_type = $response->getHeader('Content-Type');
// Attempt to extract the mime type from the content type header.
Expand Down

0 comments on commit 71ed465

Please sign in to comment.