specific - Getting only response header from HTTP POST using curl
curl show response headers and body (4)
For long response bodies (and various other similar situations), the solution I use is always to pipe to
curl -i https://api.github.com/users | less
curl -s -D - https://api.github.com/users | less
will do the job.
One can request only the headers using HTTP HEAD, as option
$ 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?
Much easier – this is what I use to avoid Shortlink tracking – is the following:
curl -IL http://bit.ly/in-the-shadows
…which also follows links.
The other answers require the response body to be downloaded. But there's a way to make a POST request that will only fetch the header:
curl -s -I -X POST http://www.google.com
-I by itself performs a HEAD request which can be overridden by
-X POST to perform a POST (or any other) request and still only get the header data.
While the other answers have not worked for me in all situations, the best solution I could find (working with
POST as well), taken from here:
curl -vs 'https://some-site.com' 1> /dev/null