Node.js code for Curl User Agent Example
This Node.js code snippet was generated automatically for the Curl User Agent example.<< Back to the Curl User Agent example
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, and 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 many platforms, such as Linux, Windows, and macOS.
What is User-Agent?
A user agent is any software that acts on behalf of a user, making requests to a server, receiving responses from the server, and processing them. Web browsers and mobile apps are examples of user agents. When a browser connects to a 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's running on.
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 with Curl?
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 for popular browsers:
Sending User-Agent String
You can send a specific User-Agent string with the curl using the -A or --user-agent option followed by the User-Agent string.
Safari User-Agent String
Below is an example of a User-Agent string for Safari:
Google Chrome User-Agent String
Below is an example of a User-Agent string for Google Chrome:
Mozilla Firefox User-Agent String
Below is an example of a User-Agent string for Mozilla Firefox: