Issue
I want to send a CURL GET
request to retrieve information from a web server and trick the webserver to think that I am sending the request from:
- Android phone
- iPhone
- iPad
- Smart TV (optional)
- Desktop Windows
The webserver has rules set up and depending on the requesting device it should serve different information or return 404. I want to test if those rules are indeed set correctly. I think I can trick it by manipulating the request header, but not sure how to do it.
Solution
The User-Agent
header is used to differentiate device types / browsers. You can set headers on a cURL command with the -H
parameter.
This question / answer shows an example how to set the User-Agent
header to act as a chrome browser: How to use curl to get a GET request exactly same as using Chrome?
Here is a site that maintains a list of user-agent strings for various platforms and browsers: https://developers.whatismybrowser.com/useragents/explore/
Answered By - Simon McLoughlin