curl - Guzzle 异常和 "http_errors request option"

标签 curl guzzle

在 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/

相关文章:

php - POST文件Curl命令行到PHP Curl

php - 编译后的php 5.4 curl安装

php - Guzzle PUT 请求身份验证错误

php - Telegram Bot 错误网关

c - 无法使用 CURL 发送 HTTPS post 服务器请求

php - mpesa ssl握手失败怎么办

php - 如何在 Guzzle http 中添加 header

PHP Guzzle 客户端错误响应/错误请求 400 Google OAuth2 token

php - Guzzle3 发送原始 Post 请求

linux - Cron 每分钟通过 CURL 触发 url