robots.txt取得時、text/plain以外の応答は失敗扱いにする

This commit is contained in:
shibafu 2020-10-17 16:54:00 +09:00
parent 4360144d6f
commit 3fd62dcd6f

View File

@ -162,6 +162,11 @@ class MetadataResolveService
$client = app(Client::class);
try {
$res = $client->get($robotsUrl);
if (stripos($res->getHeaderLine('Content-Type'), 'text/plain') !== 0) {
Log::error('robots.txtの取得に失敗: 不適切なContent-Type (' . $res->getHeaderLine('Content-Type') . ')');
return null;
}
return (string) $res->getBody();
} catch (\Exception $e) {