[php-src] Issue #10509: cURL defaults

From: Date: Sun, 05 Feb 2023 00:23:43 +0000
Subject: [php-src] Issue #10509: cURL defaults
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243638@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10509 Author: xepozz ### Description The main problem is cURL doesn't have any *default* settings and an ability to set them. So there is no way to control all your outgoing requests. Some reasons to control them globally: proxying, removing some unacceptable headers, encoding, etc. fopen/file_get_contents/file are great to use shared configuration, but: * They are not fluent compare to cURL methods * You cannot control vendor implementations uses cURL The following code: ```php <?php stream_context_set_default([ 'http' => [ 'proxy' => 'http://default-proxy', ], ]); // Works file_get_contents('https://www.google.com'); // Doesn't work $ch = curl_init("https://www.google.com/"); curl_exec($ch); ``` I understand there are two different things, but global settings maybe incredible useful. Due to cURL doesn't use streams, it would be great to have at least an additional method to set defaults. So questions: 1. Is there any problems to connect cURL with streams as a stream wrapper? 2. Are there any cons not to share streams context with cURL options? 3. Is it possible to add a method to set defaults? ### PHP Version 8.2 ### Operating System _No response_

« previous php.bugs (#243638) next »