[英]Guzzlehttp 7.3 JSON_UNESCAPED_SLASHES not working (Lumen/Laravel)
I am having an issue with an app created in Lumen and Guzzlehttp requests.我在使用 Lumen 和 Guzzlehttp 请求中创建的应用时遇到问题。 Looks like I cannot pass options like JSON_UNESCAPED_SLASHES whenever I am doing a request:
看起来我在执行请求时无法传递 JSON_UNESCAPED_SLASHES 之类的选项:
$response = (new Client())->request($this->typeRequest, $endpoint, $options);
This is hitting my server with unescaped slashes and causing some troubles.这会用未转义的斜杠击中我的服务器并造成一些麻烦。
Everything seems to be related with the vendor/guzzlehttp/guzzle/src/Client.php into applyOptions() function which is using jsonEncode and not giving the option to pass anything:一切似乎都与vendor/guzzlehttp/guzzle/src/Client.php到 applyOptions() function 相关,它正在使用 jsonEncode 并且没有提供传递任何东西的选项:
$options['body'] = Utils::jsonEncode($options['json']);
This can be easily fixed just putting the option into jsonEncode:只需将选项放入 jsonEncode 即可轻松解决此问题:
$options['body'] = Utils::jsonEncode($options['json'], JSON_UNESCAPED_SLASHES);
The issue here is in case I am updating something with composer then will be override.这里的问题是,如果我用作曲家更新某些东西,那么将被覆盖。
Someone has faced an issue like this?有人遇到过这样的问题吗? thanks a lot beforehand.
非常感谢。
You can just pass body directly - ['body'=>json_encode($data, JSON_UNESCAPED_SLASHES)]
.您可以直接传递 body -
['body'=>json_encode($data, JSON_UNESCAPED_SLASHES)]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.