This is an old revision of the document!
PHP RFC: Your Title Here
- Version: 1.0
- Date: 2021-06-25
- Author: Michael Maroszek (maroszek@gmx.net)
- Proposed Version: PHP 8.1
- Status: Under Discussion
- First Published at: http://wiki.php.net/rfc/curl_user_agent
Introduction
PHP had a user_agent php.ini entry for decades, which would be used as a default value. But it would only be considered for stream based operations like file_get_contents. This RFC proposes a new user_agent php.ini for cURL which would also allow setting a default user_agent for all cURL request. This would benefit in better consistency for settings a default user_agent. Also this feature is very useful in a SAPI context, 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.
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