php cURL CURLOPT_VERBOSE不显示有效内容 [英] php cURL CURLOPT_VERBOSE not showing payload

查看:358
本文介绍了php cURL CURLOPT_VERBOSE不显示有效内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然curl的以下输出提供了有用的标题信息,但它不提供有效载荷信息。例如,我想在提供的调试信息中看到{jason_index,json_value}。



1。)是否可以显示有效内联详细模式?



2。)查看由cURL处理的已发送有效负载的最佳方法是什么?

  *关于连接()到domain.com端口443(#0)
*尝试IP ... * connected
*连接到domain.com(IP)端口443(#0)
*成功设置证书验证位置:
* CAfile:/ usr / share / curl / curl- bundle.crt
CApath:none
*使用RC4-SHA的SSL连接
*服务器证书:
*主题:/ serialNumber = SN / C = CA / ST = Ontario / L = Ottawa / O = ORG Inc./CN=*.domain.com
*开始日期:2010-05-10 22:23:08 GMT
*到期日期:2015-08-12 19: 17:14 GMT
* subjectAltName:alt.domain.com matched
* issuer:/ C = US / O = Equifax / OU = CA
* SSL证书验证确定。
*使用用户'userid'的Basic进行服务器授权
> POST request_uri.json HTTP / 1.1
授权:基本auth_string =
用户代理:UA
主机:alt.domain.com
接受:* / *
内容类型:application / json; charset = utf-8
Content-Length:85

< HTTP / 1.1 422不可处理实体
<服务器:ServerName
<日期:Thu,21 Mar 2013 20:08:56 GMT
< Content-Type:application / json; charset = utf-8
<传输编码:分块
<连接:keep-alive
<状态:422不可处理实体
<
*连接#0托管alt.domain.com保持原状
*关闭连接#0

cURL语句示例

  $ ch = curl_init 
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ data);
curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ ch,CURLOPT_VERBOSE,true);
curl_setopt($ ch,CURLOPT_STDERR,fopen(dirname(__ FILE__)。/headers.txt,w +));
$ result = curl_exec($ ch);


解决方案

我最近遇到这个问题,我设法看到正在发生的是通过使用调试代理如:




  • burp suite - Linux / Windows / Mac(Java)


  • 其他解决方案使用数据包检查器(此选项不会让您看到 HTTPS 流量):





    使用代理的解决方案很容易设置,只需安装并使用:

      curl_setopt($ ch,CURLOPT_PROXY,'localhost:8080' ); // default for burp suite 
    curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,false); //在连接到https时忽略断言


    While the below output from curl provides useful header information, it does not provide the payload information. For example, I would want to see {"jason_index","json_value"} in the debug information provided.

    1.) Is it possible to display the payload inline with verbose mode?

    2.) What is the best way to view the sent payload that is handled by cURL?

    * About to connect() to domain.com port 443 (#0)
    *   Trying IP... * connected
    * Connected to domain.com (IP) port 443 (#0)
    * successfully set certificate verify locations:
    *   CAfile: /usr/share/curl/curl-ca-bundle.crt
      CApath: none
    * SSL connection using RC4-SHA
    * Server certificate:
    *    subject: /serialNumber=SN/C=CA/ST=Ontario/L=Ottawa/O=ORG Inc./CN=*.domain.com
    *    start date: 2010-05-10 22:23:08 GMT
    *    expire date: 2015-08-12 19:17:14 GMT
    *    subjectAltName: alt.domain.com matched
    *    issuer: /C=US/O=Equifax/OU=CA
    * SSL certificate verify ok.
    * Server auth using Basic with user 'userid'
    > POST request_uri.json HTTP/1.1
    Authorization: Basic auth_string=
    User-Agent: UA
    Host: alt.domain.com
    Accept: */*
    Content-Type: application/json; charset=utf-8
    Content-Length: 85
    
    < HTTP/1.1 422 Unprocessable Entity
    < Server: ServerName
    < Date: Thu, 21 Mar 2013 20:08:56 GMT
    < Content-Type: application/json; charset=utf-8
    < Transfer-Encoding: chunked
    < Connection: keep-alive
    < Status: 422 Unprocessable Entity
    < 
    * Connection #0 to host alt.domain.com left intact
    * Closing connection #0
    

    Example of cURL statement

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_STDERR, fopen(dirname(__FILE__) . "/headers.txt", "w+"));
    $result = curl_exec($ch);
    

    解决方案

    I've recently came across this problem, and only way I manage to see what is going on is by using debug proxy like:

    Other solution is using packet inspector like (this option won't let You see HTTPS traffic):

    Solution with proxy is easy to setup, just install, and use:

    curl_setopt($ch, CURLOPT_PROXY, 'localhost:8080'); // default for burp suite
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // ignore certs while connecting to https
    

    这篇关于php cURL CURLOPT_VERBOSE不显示有效内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆