Merge pull request #531 from shikorism/fix/robots-ignore-non-plain-response
robots.txt取得時、text/plain以外の応答は失敗扱いにする
This commit is contained in:
commit
16071f7cff
@ -162,6 +162,11 @@ class MetadataResolveService
|
|||||||
$client = app(Client::class);
|
$client = app(Client::class);
|
||||||
try {
|
try {
|
||||||
$res = $client->get($robotsUrl);
|
$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();
|
return (string) $res->getBody();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user