[409] ClientException in RequestException.php line 113
Client error: `GET http://b.k2.fwycg.com:8170/wgs/v1/openapi/products?productName=&upcBarcode=&barcoder=&fnsku=&businessCode=&warehouseCode=US-HSAJ` resulted in a `409 Conflict` response
搜索了很多资料,
new Client([
'header' => [
'Accept' => 'application/json',
'Content-Type' => 'application/x-www-form-urlencoded'
],
'verify' => false
]);
默认配置
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => true,
'cookies' => false
];
$defaults['proxy']['http']
$defaults['proxy']['https']
$defaults['proxy']['no']
$defaults['cookies']
配置有这么多选项,?
'verify' => false 没有起效
但是 用
解决办法
$client = new \GuzzleHttp\Client(['http_errors' => false]);
就不用返回错误了
/**
* Middleware that throws exceptions for 4xx or 5xx responses when the
* "http_error" request option is set to true.
*
* @return callable Returns a function that accepts the next handler.
*/
public static function httpErrors()
{
return function (callable $handler) {
return function ($request, array $options) use ($handler) {
if (empty($options['http_errors'])) {
return $handler($request, $options);
}
return $handler($request, $options)->then(
function (ResponseInterface $response) use ($request, $handler) {
$code = $response->getStatusCode();
if ($code < 400) {
return $response;
}
throw RequestException::create($request, $response);
}
);
};
};
}
我们来看下源码
|