rfc:curl_user_agent

This is an old revision of the document!


PHP RFC: Your Title Here

Introduction

PHP has a user_agent php.ini entry for decades, which can be set as a default value. But it is considered for stream based operations like file_get_contents. This RFC proposes a new curl.user_agent php.ini entry which would allow setting a default user_agent for all cURL request. This would benefit in better consistency for setting a default user_agent. This feature will mainly be used in a SAPI context in my use-case, which i will illustrate later.

Proposal

Add a new php.ini entry for cURL named curl.user_agent, which will set the default User-Agent HTTP Header for all cURL related requests. Of course anyone can override the default value using curl_setopt.

An alternative approach would be to reuse the existing (global) user_agent ini setting also for cURL, but this would touch backwards compatibility, which isn't favorable.

Backward Incompatible Changes

None

Proposed PHP Version(s)

8.1

RFC Impact

To SAPIs

This feature is especially useful for SAPI usage, as it allows a default header for all HTTP requests (independently if stream based or cURL based) that will allow the remote side to detect the application. At the moment you need to have a workflow or a wrapper that will ensure that the User-Agent is set for all streams and cURL requests. In our use-case the user is also allowed to create PHP scripts by himself. In this situation the user will most probably not set the User-Agent at all, but rely on the defaults.

To Existing Extensions

No impact. By default the new entry is empty and will not do anything.

To Opcache

No impact.

New Constants

No

php.ini Defaults

curl.user_agent is unset by default for development and production.

Open Issues

No issues left.

Unaffected PHP Functionality

This feature does not affect PHP very much and there does not collide with any currently proposed RFCs.

Future Scope

This RFC does not have any future scope.

Proposed Voting Choices

At the moment the php.ini option is placed inside the curl section.

Patches and Tests

Links to any external patches and tests go here.

If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed.

Make it clear if the patch is intended to be the final patch, or is just a prototype.

For changes affecting the core language, you should also provide a patch for the language specification.

Implementation

References

Rejected Features

None yet

rfc/curl_user_agent.1624629545.txt.gz · Last modified: 2021/06/25 13:59 by paresy