Set Client User Agent with Curl

Set Client User Agent with Curl

When using Curl to make HTTP requests, it's useful to specify a User-Agent header to identify the client making the request. The User-Agent header typically includes information about the client, such as its name, version, operating system, and more. This header is added by various applications, including web browsers, bots, testing tools, and others. This tutorial explains how to set client user agent with a Curl.

With Curl, you can customize the User-Agent header by using the -A or --user-agent option, followed by the desired string.

curl -A "TestingApp/1.0" https://httpbin.org/get
curl --user-agent "TestingApp/1.0" https://httpbin.org/get

In this case, the output you'll obtain will be formatted in JSON, including the provided User-Agent header:

{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "TestingApp/1.0",
    "X-Amzn-Trace-Id": "Root=1-6416c45e-47a4828a557d5fca764271d6"
  },
  "origin": "XXX.XXX.XXX.XXX",
  "url": "https://httpbin.org/get"
}

Leave a Comment

Cancel reply

Your email address will not be published.