在生产中运行的Symfony 3.4上,我不断收到此错误:
An Error Occurred! Uncaught PHP Exception Negotiation\Exception\InvalidMediaType: ""
at /var/www/mywebsite/vendor/willdurand/negotiation/src/Negotiation/Accept.php line 24
由于构造请求失败,因此我几乎无法调查。
完整跟踪为:
"file": "/var/www/mywebsite/vendor/willdurand/negotiation/src/Negotiation/Accept.php:24",
"trace": [
"/var/www/mywebsite/vendor/friendsofsymfony/rest-bundle/Negotiation/FormatNegotiator.php:105",
"/var/www/mywebsite/vendor/friendsofsymfony/rest-bundle/EventListener/FormatListener.php:60",
"/var/www/mywebsite/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:212",
"/var/www/mywebsite/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:44",
"/var/www/mywebsite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:127",
"/var/www/mywebsite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68",
"/var/www/mywebsite/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200",
"/var/www/mywebsite/web/app.php:17"
]
周围的代码如下:
public function __construct($value)
{
parent::__construct($value);
if ($this->type === '*') {
$this->type = '*/*';
}
$parts = explode('/', $this->type);
if (count($parts) !== 2 || !$parts[0] || !$parts[1]) {
throw new InvalidMediaType();
}
当我记录$this->type
和$value
的值时,我发现它们都等于""
(空字符串)。
当我尝试在/var/www/mywebsite/web/app.php:17
级别捕获此异常时,我一直遇到此错误...
我真的不知道谁可以经常使用这个无效的标题来调用我的网站,以及如何摆脱此污染错误日志。
有什么主意吗?