Hi Michael,
Thanks for opening this conversation and the PR.

Most HTTP client libraries that need to set a custom user agent do so
with `curl_setopt` because it needs to contain a library version or
some sort of dynamic values. They will likely not benefit from this
change. On the other hand, libraries that do not bother to set a UA
string probably wanted it that way too, because Curl's default UA
string is useful as it contains the Curl version.

That said, if it comes to it that we add this feature, I'd be in favor
of a new `curl.user_agent` as opposed to inheriting the global
`user_agent` because that would be BC break. We already have
`curl.cainfo` INI setting, and adding a new `curl.user_agent` wouldn't
be a drastic change to configuration either.

-- Ayesh.



>
> Dear Internals,
> I'd like to suggest a new enhancement for 8.1 as outlined in the title.
>
> The initial pull request is here:
> https://github.com/php/php-src/pull/6834/files
>
> --- Details:
> Since quite a while PHP offers a dedicated user_agent php.ini entry, but it
> affects only all internal implementations like file_get_contents. cURL has
> no default and you need to modify CURLOPT_USERAGENT in the code and for the
> SoapClient there is a parameter 'user-agent' in the constructor which can
> be set.
>
> Therefore I'd like to introduce an equal entry for curl.user_agent which
> would set a default user_agent when making curl requests. Of course you can
> override it with CURLOPT_USERAGENT if required. (I can implement the same
> for SoapClient, if requested)
>
> --- Alternative:
> I could also use the default user_agent entry, but I wasn't sure what the
> best practise is and went for the more "local" approach for the initial
> implementation.
>
> --- Bigger picture:
> When the preferred solution is to use the default user_agent, we could also
> try to determine more places where i could send the default user_agent to
> give this php.ini entry a more consistent feeling.
>
> Thanks for your consideration,
> Michael
>
> PS: Subscribing to the list through https://www.php.net/mailing-lists.php is
> not possible and quits with the following error: We were unable to
> subscribe you due to some technical problems. Please try again later.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to