Ajedi32
Ajedi32

Reputation: 48368

How do I check what user agent curl is using?

I'm attempting using curl to monitor the contents of a page served by a remote HTTP server (which I have very little control over), and for some reason the server is returning different results depending on what machine I'm running curl from. I suspect this might be due to a difference in the user agent strings curl is using on each machine.

How do I check (not set) what user agent string curl is sending to the remote server in its HTTP requests?

Upvotes: 23

Views: 27848

Answers (3)

Supersharp
Supersharp

Reputation: 31171

You can also call the JSON service https://ifconfig.co:

curl ifconfig.co/json -s | grep  "raw_value"

It will return the full user-agent string.

Exemple of answer for curl version 8.1.2:

"raw_value": "curl/8.1.2"

Upvotes: 0

TachyonVortex
TachyonVortex

Reputation: 8572

Use the --verbose option to see all the headers sent by curl, including User-Agent:

A line starting with '>' means "header data" sent by curl

For example:

$ curl --verbose 'http://www.google.com/'
> GET / HTTP/1.1
> User-Agent: curl/7.37.0
> Host: www.google.com
> Accept: */*

Upvotes: 36

Zech
Zech

Reputation: 31

Try this

curl ifconfig.me/ua

However the output would be "Curl and your curl version"

for example:

curl/7.64.0 

Upvotes: 3

Related Questions