Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document default User-Agent #15608

Closed
wants to merge 2 commits into from
Closed

Conversation

br3ndonland
Copy link
Contributor

Description

curl offers a --user-agent option for modifying the User-Agent header supplied in its requests.

The man page section for this option explains how to use the --user-agent option, but does not explain which User-Agent curl uses by default.

By default, curl uses curl/VERSION, such as User-Agent: curl/8.11.0.

curl/src/tool_paramhlp.c

Lines 638 to 644 in ca6d3d2

/*
* my_useragent: returns allocated string with default user agent
*/
static char *my_useragent(void)
{
return strdup(CURL_NAME "/" CURL_VERSION);
}

my $ua = new LWP::UserAgent(agent => "$0/$version");

Note that this appears to be different from the libcurl default (no header).

# DEFAULT
NULL, no User-Agent: header is used.

Changes

This pull request will document the default User-Agent in the man page section for the --user-agent option, as well as on the "Art of Scripting" page.

The %VERSION placeholder will be used to insert the current version as described in the man page generator docs.

### Variables
There are three different "variables" that can be used when creating the
output. They need to be written within backticks in the source file (to escape
getting spellchecked by CI jobs): `%DATE`, `%VERSION` and `%GLOBALS`.

Related

curl offers a `--user-agent` option for modifying the `User-Agent`
header supplied in its requests.

The man page section for this option explains how to use the
`--user-agent` option, but does not explain which `User-Agent` curl uses
by default.

By default, curl uses curl/VERSION, such as `User-Agent: curl/8.11.0`.

Note that this appears to be different from the libcurl default
(no User-Agent header).

This commit will document the default `User-Agent` in the man page
section for the `--user-agent` option, as well as on the
"Art of Scripting" page.

The `%VERSION` placeholder will be used to insert the current version
as described in the man page generator docs.
@@ -456,6 +456,8 @@ SPDX-License-Identifier: curl
it is time to set the User Agent field to fool the server into thinking you
are one of those browsers.

By default, curl uses curl/VERSION, such as User-Agent: curl/`%VERSION`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The %VERSION variable expansion does not work in this document. It should probably spell out an example version verbatim.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bagder thank you for clarifying. Updated with hard-coded example version number.

@bagder bagder closed this in dada880 Nov 17, 2024
@bagder
Copy link
Member

bagder commented Nov 17, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants