What is Curl?
Curl (stands for Client URL) is a command-line tool for transferring data to or from the server using URL syntax. Curl allows you to communicate with the server by specifying the target URL and the data you want to send. Curl supports over 25+ protocols, including HTTP, HTTPS, FTP, FTPS, and SFTP, has built-in support for SSL certificates, HTTP Cookies, and more. Curl is ideal for testing APIs and for use in automation scenarios. Curl works on platforms Linux, Windows, and macOS.
What is User-Agent?
A user agent is any software acting on behalf of a user that makes a request to a server, receives a response from the server, and processes it. The user agent may have a user interface and interact with the end-user, or it may not have a user interface. In this case, it must provide a procedural or declarative language that can be used to provide a user interface. When the browser connects to the website, it includes the User-Agent string in the HTTP request header. This User-Agent header string varies from browser to browser, but usually includes the name and version of the browser, as well as some information about the operating system it runs on. Web browsers and mobile apps are examples of user agents.
How do I change the default Curl User-Agent string?
The general form of passing a custom User-Agent string to Curl is as follows:
Can I remove the User-Agent string from the Curl request?
Yes, you can use the -H command-line option with the User-Agent header name and no content after the ':' sign. This will force Curl to send the request without the User-Agent header (instead of sending it with an empty value).
How to send a custom User-Agent string?
Below is an example of sending a custom User-Agent string to the ReqBin echo URL using the --user-agent command-line parameter:
Curl User-Agent Examples
The following are examples of the User-Agent string in popular browsers:
Safari User-Agent String
Below is an example of a User-Agent string in Safari:
Google Chrome User-Agent String
Below is an example of a User-Agent string in Google Chrome:
Mozilla Firefox User-Agent String
Below is an example of a User-Agent string in Mozilla Firefox: