One can request only the headers using HTTP HEAD, as option -I
in curl(1)
.
$ curl -I /
Lengthy HTML response bodies are a pain to get in command-line, so I'd like to get only the header as feedback for my POST requests. However, HEAD and POST are two different methods.
How do I get cURL to display only response headers to a POST request?
Best Answer
and
and
from the man page. so
follows redirects, dumps the headers to stdout and sends the data to /dev/null (that's a GET, not a POST, but you can do the same thing with a POST - just add whatever option you're already using for POSTing data)
note the
-
after the-D
which indicates that the output "file" is stdout.