Last Updated: January 28, 2019
· sativaware

Include HTTP headers in Curl response

If you are a developer - chances are you are familiar with and use curl on a daily basis - whether it's for testing or tooling.

Lets go over the case of testing a JSON API using curl — By default, curl will make a request to the url you provide and print out the response body. In this case we are making a call to a JSON api to review the JSON data.

$ curl http://api.wildspots.org/ping

#{"ping":"Response from Wildspots API"}%

From time to time - seeing the HTTP Headers & protocol information of a request is useful - often during initial setup of a web server or during testing.

To include HTTP Headers & protocol information - we simply use the -i option with the curl command.

$ curl -i http://api.wildspots.org/ping

# HTTP/1.1 200 OK
# Server: nginx/1.2.2
# Date: Sun, 19 Jan 2014 07:38:49 GMT
# Content-Type: application/json
# Transfer-Encoding: chunked
# Connection: keep-alive
# X-Powered-By: Express

# {"ping":"Response from Wildspots API"}%

The man page on curl describes the -i option as follows:

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


curl man page

Wildspots.org API docs

3 Responses
Add your response


Hi after reading your blog I have finally found some knowledge which
I was looking for so long for that reason Thanks..


6 months ago ·
5 months ago ·

The more services and responsive request and increased the wonderful protocol information and using the great services with us. The more https://www.resumesservicesreview.com/zipjob-com-review/ electing html codes and tooling the school based methods.

3 months ago ·