I'm building a Curl web automation app and am having some issue with not getting the desired outcome of my POST action, I am having some trouble figuring out how I can show the full POST request I am sending over (with headers), I have been searching on this but everything that comes up is the response headers, actually I want these too but also the request, which none of the posts I find on google seem to mention..
I know I can display the result of a curl request using something like this (forgive me if my syntax is off, I already shut down my virtual machine with my ide and code to refer to
$result = curl($curl_exect) ;
Anyways, I would greatly appreciate any advice on how to view the full headers, thanks
Curl by default adds headers such as Content-type and User-agent .
The -I option is used to tell curl to only fetch the HTTP headers ( HEAD method) of a particular page or resource.
By default, curl doesn't print the response headers. It only prints the response body. To print the response headers, too, use the -i command line argument.
Here is all you need:
curl_setopt($curlHandle, CURLINFO_HEADER_OUT, true); // enable tracking ... // do curl request $headerSent = curl_getinfo($curlHandle, CURLINFO_HEADER_OUT ); // request headers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With