Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / How can I set the request header for curl?

How can I set the request header for curl?

August 23, 2021 by James Palmer

Just use the -H parameter several times:
curl -H “Accept-Charset: utf-8” -H “Content-Type: application/x-www-form-urlencoded” http://www.some-domain.com

To pass multiple headers in a curl request you simply add additional -H or –header to your curl command.
Example
//Simplified
$ curl -v -H ‘header1:val’ -H ‘header2:val’ URL

//Explanatory
$ curl -v -H ‘Connection: keep-alive’ -H ‘Content-Type: application/json’ https://www.example.com

Going Further
For standard HTTP header fields such as User-Agent, Cookie, Host, there is actually another way to setting them. The curl command offers designated options for setting these header fields:

-A (or –user-agent): set “User-Agent” field.
-b (or –cookie): set “Cookie” field.
-e (or –referer): set “Referer” field.
-H (or –header): set “Header” field

For example, the following two commands are equivalent. Both of them change “User-Agent” string in the HTTP header.
$ curl -v -H “Content-Type: application/json” -H “User-Agent: UserAgentString” https://www.example.com
$ curl -v -H “Content-Type: application/json” -A “UserAgentString” https://www.example.com

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in