To add a custom header to Curl, you need to pass the -H "header: value" command line parameter to the Curl request. In this Curl Custom Headers example, we are sending a custom header to the ReqBin echo URL. The target URL is passed as the first parameter, and the custom header is passed as the second parameter to the Curl command. Click Run to execute the Curl Custom Headers example online and see the results.
Curl is a popular open-source command-line tool and cross-platform library (libcurl) for transferring data between servers, designed to work without user intervention. Curl can upload or download data using popular protocols including HTTP, HTTPS, SFTP, SCP, and FTP. Curl has built-in support for HTTP Cookies, SSL, proxies, certificate validation, user authentication and works on all modern platforms and hardware, including Linux, Windows, and macOS.
What is HTTP?
HTTP (Hypertext Transfer Protocol) is a protocol for exchanging data between multiple network devices that are used to transfer data between an HTTP client (browser or mobile application) and a server. Now the HTTP protocol is the most popular and primary communication method on the Internet. HTTP is built on messages called "request" and "response" based on the client-server architecture. Devices communicate with each other by sending HTTP requests and receiving HTTP responses.
What is Custom Headers?
HTTP headers allow clients to send information to the server and return data to the client. The headers are usually invisible to the end-user and are only visible to server soft and network administrators. Custom headers are intended to provide additional information related to the current request or response, or for troubleshooting purposes.
How to add Custom Headers using Curl?
Use the -H "header: value" command-line option to add a custom header to Сurl: