The User Agent
Lesson 44 of 47 in Coddy's Networking with the Terminal course.
Every request announces what made it, in the User-Agent header. curl sends its own name and version; a browser sends a long historical string.
This matters more than it looks. Servers routinely behave differently based on it: serving a mobile layout, blocking unknown clients, or rejecting anything that looks automated. So "it works in my browser but not in curl" is often exactly this header, and nothing deeper.
curl -s -A 'my-monitor/1.0' http://127.0.0.1:9133/-A sets it, and it is simply a shorthand for -H 'User-Agent: ...'.
If you run automated requests against a service, setting an honest User-Agent that names your tool is good manners: when your traffic causes a problem, whoever is on call can tell what it is and who to ask.
Challenge
HardIntroduce yourself honestly.
- Start the capture listener on port 9133
- Make a request identifying itself as
my-monitor/1.0 - Print the user agent line from
req.txt
Expected output:
User-Agent: my-monitor/1.0Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
6curl in Depth
Seeing the HeadersSaving ResponsesCustom HeadersStatus and Timingcurl Exit CodesRecap: curl Flags9Auth and Debugging
API Keys and BearerThe User AgentTimeouts and RetriesReading a FailureRecap: DebuggingPractice on your own: Terminal playground