f3avyq
Last Updated: December 04, 2018
·
7.681K
· 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:

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

References

curl man page

Wildspots.org API docs

4 Responses
Add your response

30819

Play the one of the world famous online mini puzzle game,basically people clear the tiles and create the new high score https://myminesweeper.com it is very simple and is not high concept game.

4 months ago ·
30840

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

https://192-168-1-1.me
https://facetime-app.com
https://facetimeforandroid.biz

4 months ago ·
30991
3 months ago ·
31360

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.

about 1 month ago ·