Developing software in the Real World

View header and body with curl

I recently discovered the -i switch to curl! I have no idea why I didn’t know about this before…

Curl is one of those tools that every developer should know. It’s universal and tends to be available everywhere.

When developing APIs, I prefer to use curl to view the output of a request like this:

-v is for verbose and so you get told all the information you could possibly want. However, usually, I only want to know the response’s headers and body.

Enter the -i switch!

Much better!

-i is for include and from the man page:

Include the HTTP-header in the output. The HTTP-header includes things like server-name, date ofthe document, HTTP-version and more…

This is exactly what I want without the information that I don’t!

4 thoughts on “View header and body with curl

  1. I have been looking for this since a long time and actually if you check on stack overflow the "-v" option is the most common advice.

    Thanks for sharing this gem! ;)

Leave a Reply to Luciano Mammino Cancel reply

Your email address will not be published. Required fields are marked *