HOWTO observe network traffic for curl debugging
I'm trying to make a curl call that also pass an ima开发者_JAVA技巧ge file along.
Obviously it's not working for me. However, I've got a test working that just use straight up html form.How can I debug / print out the raw data that is being passed from curl?
Trying to compare the call with the form version to see what is different.I've tried these:
curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_VERBOSE, true);
print_r(curl_getinfo($curl));
But those seems to just return the response as opposed the raw request. (it's through a 3rd party so I have no access to the end point)
Thank you,
Teecurl
the command line client has a --trace-ascii
option for that. But that feature is not exposed in the PHP interface.
The _VERBOSE
output might however still contain some information (if it's really a server error). You must redirect it into a separate file however before:
$fp = fopen("curl.log", "w");
curl_setopt($ch, CURLOPT_STDERR, $fp);
Failing that, I'm afraid the best option is to peek at the network traffic (using a separate tool, ad-hoc proxy maybe).
see previous answer on stackoverflow for similar question.
Use wireshark to observe network traffic and add a filter 'ip.addr == x.x.x.x' with the IP of the target website.
This one helped me debug it. Doesn't print the entire thing, but did print the header which was super helpful.
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
Thanks,
Tee
精彩评论