The cURL is an open-source tool for transferring data using communication protocols such as FTP, HTTP, TELNET, and many more. In this article, we will describe how to display headers for requests and responses using cURL. HTTP headers allow passing additional information with the request or the response.
2. Display request/response headers using --verbose parameter
To present some extra information about HTTP operation, we can use the -v or --verbose parameter. The curl tool will display more data about requests and responses, and also will present HTTP headers used in communication.
This could be useful for debugging and checking what is going on "under the hood".
Let's check the -v parameter with an HTTP GET request to google.com website:
The output:
Requests headers:
Response headers:
2. Display response data with headers using cURL and -i parameter
With curl we also have an option to display only HTTP headers from the response.
To do so we need to use -i or --include parameter - cURL-i.
The output:
3. Display only headers using cURL with -I parameter
To fetch only the headers we could use -I or --head option - cURL-I.
The output:
4. Conclusion
In this article, we present how to display response/request headers using cURL options.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}