Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118001 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15609 invoked from network); 19 Jun 2022 12:06:07 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Jun 2022 12:06:07 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E974E1804B1 for ; Sun, 19 Jun 2022 06:54:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 19 Jun 2022 06:54:52 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id v14so11351411wra.5 for ; Sun, 19 Jun 2022 06:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:user-agent:in-reply-to:references:message-id :mime-version:content-transfer-encoding; bh=n2GayLg2WvA8cGHhOs7eWb4Y8fq4KnQKn6EkRjTVNnk=; b=k/kuHeKszSNgMSwhXeTeyExM7a5WEmetdZhU93V9zMAHKe7FjqTYhIG54uCPSW62d9 IH4BsS3rAs4eATiSoDlE3jF9kZLhogU5Kj7yee7m0b8Cvrgnd9hod+91er8jB8lKJ8A/ zF0jQV7iL2hIzCcYDSVKLTuos0V+oK3aLdMpEY80u5uUzUSwY4+NghDokWtOECGtVBWt IQOhYN/oLKxmHvj6mPsdzWLb2xC5AUAdPXhYxWtpV8ZbIsOlj0YIDoYDkhQ/PUAaV3Zy sWwZEBhvviQQJUGPcGvhaw81BHR7vr9XHN81CELsQEGSe7UpzXF1DvZHeIJv9HsPJX2H WfnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:user-agent:in-reply-to :references:message-id:mime-version:content-transfer-encoding; bh=n2GayLg2WvA8cGHhOs7eWb4Y8fq4KnQKn6EkRjTVNnk=; b=Vf4eyZ1n7KuellsxyXLrj8kcV3/TVwn19lz6BDj6F+QB5oF3Qyu596fIQ+Zzl3wq8W 6S0lOlEHGH9F0xPta34iOy0ViaGXWaU6y1Pd697fE1Ph1TofCFeRTHPyY+E28dEZ4bDH elJj3Rnnqp6Uj8pxlHr+jGtgktAYxaY1wtIFeQzCGeFdzzjvpiUsnFnuVNFjsJAq8YJC t/jVe/SkzNvOS681ZLzOFoCXwxsKbUp9ZQwToFI+2iYUKtSF59gBicicE04b24bzvM48 hTm5/ZvFRkCuQjoarjhhfzgM+MePoDjndUOqoMV15PsCPFSfWy6/P4WuowZyzx5mQJio othw== X-Gm-Message-State: AJIora+31NKcPIOaomRWKeaaKra9/AroXtzquNNaUWmR9kk8r8jR38Jr BFOudnZGuay0idKMXxZGKwGS/nh79vc= X-Google-Smtp-Source: AGRyM1vS889Q13EQ6P44byTuy4kIewfpaaMuXXzwpCRGkgFfeL23fFewqGQoKkrzdBaCbUl7js8vdg== X-Received: by 2002:a05:6000:1b03:b0:216:43b4:82f1 with SMTP id f3-20020a0560001b0300b0021643b482f1mr18547152wrz.232.1655646891226; Sun, 19 Jun 2022 06:54:51 -0700 (PDT) Received: from [127.0.0.1] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.gmail.com with ESMTPSA id h30-20020adfaa9e000000b0020c7ec0fdf4sm12538058wrc.117.2022.06.19.06.54.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Jun 2022 06:54:50 -0700 (PDT) Date: Sun, 19 Jun 2022 14:54:41 +0100 To: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <76FA5161-16C3-4570-9EF8-B75DF2E6530A@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: =?US-ASCII?Q?Re=3A_=5BPHP-DEV=5D_Discussion_about_new_C?= =?US-ASCII?Q?url_URL_API_and_ext/curl_improvements?= From: rowan.collins@gmail.com (Rowan Tommins) On 19 June 2022 03:53:17 BST, Pierrick Charron wrote: > >I hope you don't mind, I took some of your code from your "Enable >strict_types checking for curl_setopt()" pull request [1] to do some test >on introducing this but only on the OOP API=2E It's working very well [2]= =2E >Can I know why this PR was closed ? Any issues ? Or was it more because i= t >was too much of a change for the procedural API ? While a few type errors there might be useful, it still feels a bit like p= olishing a turd=2E=20 I count about 180 different options that can be passed to curl_setopt=2E S= ome of them are used by nearly every user of PHP, and some are for very obs= cure niche uses=2E Many of them are useless on their own, and exist only to= tweak the behaviour of some other option, or need to be used in groups lik= e usernames and passwords=2E Others have unintuitive and unhelpful defaults= , that need to be overridden with a different option=2E The manual page has= long topped the league table for user comments, currently standing at 102= =2E It is simply not a practical design for what most users of PHP need=2E I think one way out of this mess is to start grouping options together, an= d providing specific methods to set them, with named, type-safe parameters= =2E For instance, CurlHandle::setProxyOptions(string $url, ?string $authUse= rName, ?string $authPassword, =2E=2E=2E) and so on=2E If the long lists of parameters still feel a bit messy, we could go a step= further and make objects for building sets of options, with methods taking= short lists of genuinely dependent options, e=2Eg=2E CurlProxyOptions::set= Auth(string $userName, string $password) and CurlProxyOptions::disableAuth(= ) Some of the options should be rethought in the process to make more sense = to PHP's common usage, rather than libcurl's=2E As just one example, enabli= ng CURLOPT_VERBOSE sends some debug information to stderr, but on a web ser= ver that is normally a log file where it will be mixed in with other inform= ation=2E To capture it instead you need to also set CURLOPT_STDERR, which r= equires an open file handle=2E What most users *actually* want is for that = information to be available to them as a string after the request is execut= ed=2E Another thing that might be useful is some new factory methods that set se= nsible defaults, like CurlHandle::createForHttp(string|CurlUrl $url, string= $method) If we can build these things on top of the existing CurlHandle, we can rel= ease a few things first, and progressively add features=2E Rather than havi= ng to decide which extension to use, users will still have access to curl_s= etopt for things there isn't a nicer interface for yet=2E We can even leave= it in place as something like CurlHandle::setRawOption for when users want= fine control of the library, or some really obscure setting=2E Regards, --=20 Rowan Tommins [IMSoP]