Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Curl POST Request Headers? Is there a way to do this?

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

like image 809
Rick Avatar asked Jul 02 '10 09:07

Rick


People also ask

Does curl automatically add headers?

Curl by default adds headers such as Content-type and User-agent .

What is the correct command to get only the headers for a given URL using curl command?

The -I option is used to tell curl to only fetch the HTTP headers ( HEAD method) of a particular page or resource.

How do I print a curl response?

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.


1 Answers

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 
like image 50
Joseph Lust Avatar answered Sep 30 '22 10:09

Joseph Lust