I'm always excited to take on new projects and collaborate with innovative minds.

Phone

+91-9723273747

Email

contact@manojitaliya.com

Address

Surat, Gujarat, INDIA

Social Links

Web Servers

How to Show and Send HTTP Headers with cURL (Examples & Guide)

Learn how to show and send HTTP headers with cURL. Step-by-step guide with practical examples to display response headers, send custom headers, debug API requests, and test endpoints directly from the command line.

How to Show and Send HTTP Headers with cURL (Examples & Guide)

cURL is a powerful command-line tool used to transfer data with URLs. It supports multiple protocols including HTTP, HTTPS, FTP, and more. Developers often use cURL to test APIs, debug requests, and manage data transfers. In this guide, we’ll cover how to view HTTP headers and send custom headers with cURL.

Show HTTP Response Headers with cURL

To display only the response headers, use the -I (or --head) option:

curl -I https://example.com

This command sends a HEAD request and shows headers like:

HTTP/2 200 
date: Sat, 13 Sep 2025 08:00:00 GMT
content-type: text/html; charset=UTF-8
server: nginx

Show Headers with the Response Body

If you want both headers and the body, use the -i option:

curl -i https://example.com

The output will include headers first, followed by the HTML body of the response.

Send Custom HTTP Headers with cURL

To send custom headers, use the -H (or --header) option:

curl -H "Accept: application/json" https://api.example.com/data

You can pass multiple headers by repeating the -H flag:

curl -H "Content-Type: application/json" \
     -H "Authorization: Bearer your_token_here" \
     https://api.example.com/data

Send POST Request with Headers

When sending a POST request with headers:

curl -X POST https://api.example.com/login \
     -H "Content-Type: application/json" \
     -d '{"username":"user","password":"pass"}'

This example sends JSON data with custom headers to an API endpoint.

Verbose Output (Debugging)

For debugging, use the -v option to see detailed request and response headers:

curl -v https://example.com

It prints the full communication including request headers, making it useful for troubleshooting.

Quick Summary

  • -I → Show only response headers
  • -i → Show headers + body
  • -H → Send custom headers
  • -X → Specify request method (GET, POST, PUT, DELETE)
  • -v → Verbose mode (request + response headers)

Conclusion

Using cURL Post, you can easily send and view HTTP headers for debugging and API testing. Whether you need to check server response headers, send authentication tokens, or test custom requests, cURL provides a simple yet powerful way to handle HTTP communication directly from the command line.

 

Frequently Asked Questions (FAQs)

Use the -I option with cURL to show only response headers. Example:
curl -I https://example.com

Use the -i option with cURL to display both the headers and the response body. Example:
curl -i https://example.com

You can send custom headers using the -H flag. Example:
curl -H "Accept: application/json" -H "Authorization: Bearer token" https://api.example.com

Use the -X POST option with -H to set headers and -d to send data. Example:
curl -X POST https://api.example.com/login -H "Content-Type: application/json" -d '{"username":"user","password":"pass"}'

Use the -v option for verbose mode. It displays both request and response headers. Example:
curl -v https://example.com

curl curl http headers curl send headers curl show headers curl custom headers curl verbose mode curl examples curl API testing curl post headers curl request headers curl response headers curl linux curl ubuntu curl tutorial
2 min read
Sep 13, 2025
By MANOJ ITALIYA
Share

Leave a comment

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

Related posts

Sep 14, 2025 • 2 min read
Install and Configure Helm on Ubuntu 24.04

Helm is the package manager for Kubernetes that simplifies deploying and managing applications. This...

Jun 24, 2025 • 2 min read
How to Install Nginx on Ubuntu 22.04 (Step-by-Step Guide)
Jun 24, 2025 • 2 min read
How to Install WordPress on Ubuntu
Your experience on this site will be improved by allowing cookies. Cookie Policy