【问题标题】:Is it possible to differenciate proxy error from endpoint error with php curl是否可以使用 php curl 区分代理错误和端点错误
【发布时间】:2023-03-13 18:29:02
【问题描述】:

小卷曲问题^^

你有:

  • 网站网站 (endpoint.com/request.php)
  • 代理服务器 (proxy.com:8080)

是否可以通过带有 php_curl 的代理向远程网站(例如:API)发送请求以区分代理部分失败(例如:代理关闭、身份验证错误、超时...)和远程网站发生时的情况站点失败(例如:404、站点关闭、身份验证错误、超时......)

谢谢

【问题讨论】:

    标签: php curl proxy http-request


    【解决方案1】:

    请参阅PHP Curl documenation 和/或libcurl documentation

    看起来唯一特定于代理的错误代码是(CURLE_COULDNT_RESOLVE_PROXY) 5

    【讨论】:

    • 谢谢,这听起来不错……但我想知道在代理超时、代理错误身份验证的情况下会发生什么……=>要测试的案例太多……
    【解决方案2】:

    您需要检查 curl_exec($curl) 的响应结果并尝试使用显示错误

    if (!$response) {
        echo "cURL error number:" .curl_errno($curl)."\t";
        echo "cURL error:" . curl_error($curl)."\n";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-24
      • 2018-07-12
      • 2017-04-07
      • 2019-04-02
      • 2014-01-22
      • 1970-01-01
      相关资源
      最近更新 更多