Guzzle 异常和“http_errors 请求选项”

Sam*_*ony 2 curl guzzle

在 guzzle6 手册(http://guzzle.readthedocs.org/en/latest/quickstart.html#exceptions)中,它指出

如果 http_errors 请求选项设置为 true,则会引发 400 级错误的 GuzzleHttp\Exception\ClientException

这个“http_errors”设置是什么,如何更改它?

我努力了:

$client = new \Guzzle\Http\Client();
$client->setDefaultOption('http_errors', false);
Run Code Online (Sandbox Code Playgroud)

我不确定这是否有任何影响。除此之外,我在库源代码中的任何地方都找不到字符串“http_errors”,这让我怀疑我误解了文档。

那么如何更改此“http_errors”设置/请求选项?

Sam*_*ony 6

对于狂饮 6

 $client->get('/status/500', ['http_errors' => false]);
Run Code Online (Sandbox Code Playgroud)

https://guzzle.readthedocs.io/en/latest/request-options.html#http-errors

这个答案是由 @Alcalyn 在上面的评论中提供的。