php cURL CURLOPT_VERBOSE not showing payload

时光怂恿深爱的人放手 提交于 2019-12-23 01:11:01

问题


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);

回答1:


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

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

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

  • WireShark

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


来源:https://stackoverflow.com/questions/15558520/php-curl-curlopt-verbose-not-showing-payload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!