Command line curl can display response header by using -D option, but I want to see what request header it is sending. How can I do that?
the -v option for curl is too verbose in the error output which contains the leading *(status line) or >(request head field) or <(response head field). to get only the request head field:
curl -v -sS www.stackoverflow.com 2>&1 >/dev/null | grep '>' | cut -c1-2 --complement
to get only the request head field:
curl -v -sS www.stackoverflow.com 2>&1 >/dev/null | grep '<' | cut -c1-2 --complement
or to dump it into /tmp/test.txt file with the -D option
curl -D /tmp/test.txt -sS www.stackoverflow.com > /dev/null
in order to filter the -v output, you should direct the error output to terminal and the std output to /dev/null, the -s option is to forbid the progress metering