php - 请求的媒体类型无效
问题描述
在生产中运行的 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
级别捕获此异常时,我一直遇到此错误...
我真的不知道谁能经常用这个无效的标题调用我的网站,以及如何摆脱这个污染错误日志。
任何想法?
解决方案
推荐阅读
- php - 使用队列生成 pdf 有时会显示旧设计,有时会显示新设计
- mongodb - 数据库中不那么紧急的字段我应该填写什么?
- mysql - mariadb-server 已被 mysql-community-server 淘汰
- typescript - TypeScript 条件类型扩展对象,仅可用属性
- gis - 如何在 QGIS 中合并来自两个栅格图层的数据?
- timer - Arduino P10 显示和时间计数
- wso2 - WSO2 Ei 代理服务和 DS
- mysql - 在 Mysql 中使用随机数据更新大量行
- java - 未知模式字母:T - 使用模式 T 将字符串日期解析为 LocalDateTime
- json - 从数组中获取数据以响应 Swift