Merge pull request #531 from shikorism/fix/robots-ignore-non-plain-response

robots.txt取得時、text/plain以外の応答は失敗扱いにする
This commit is contained in:
shibafu
2020-10-21 20:47:19 +09:00
committed by GitHub

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) {