在 guzzle6 手册 ( http://guzzle.readthedocs.org/en/latest/quickstart.html#exceptions ) 中指出
A GuzzleHttp\Exception\ClientException is thrown for 400 level errors if the http_errors request option is set to true
这个“http_errors”设置是什么,如何更改它?
我试过:
$client = new \Guzzle\Http\Client();
$client->setDefaultOption('http_errors', false);
我不确定这是否有任何影响。除此之外,我在库源代码中的任何地方都找不到字符串“http_errors”,这让我怀疑我误解了文档。
那么我该如何更改这个“http_errors”设置/请求选项呢?
最佳答案
对于 Guzzle 6
$client->get('/status/500', ['http_errors' => false]);
https://guzzle.readthedocs.io/en/latest/request-options.html#http-errors
此答案由@Alcalyn 在上面的评论中提供。
关于curl - Guzzle 异常和 "http_errors request option",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31215583/