Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122413 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id C976C1B0DF7 for ; Sat, 17 Feb 2024 15:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708185468; bh=5DiC6i2GsUABrDVhOzEwfigLVU6dl+oUK46PbMSwuYA=; h=In-Reply-To:References:Date:From:To:Subject:From; b=AGDhQgVsOPwDucUYc6elt6HcBEzHfzV9sLoSXIcxi4l7pVPeWvlFFDF1WpiIDQsfs Qfiw92Ke4kLR6/GCCm1LrydrxRK4mfg7hQ8QftzEn5zaaJe43CjxhFI1HwAtnqEloq TjD19k9zYNCGXhD3JgjeiAxIziitj8wzLiuWkJXEW3Nw8aBpZPmk2RdbsfbhZ94hyE SMcMUwxZLw8iPF/z/CPdwU720iXtPiSaSKmu2Ut0jvC5flP3HTrrN4TN5uRVrr2Hx3 6PdmboyUQG0dQzT4X/An02GGz+Et+sMLxmTm+2+w5Y7+mgA6x4plOvuRzCq1GFZDfr 7UCPnYxbPAJJg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 04099181822 for ; Sat, 17 Feb 2024 15:57:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 17 Feb 2024 07:57:43 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 964815C0063 for ; Sat, 17 Feb 2024 10:57:40 -0500 (EST) Received: from imap50 ([10.202.2.100]) by compute1.internal (MEProxy); Sat, 17 Feb 2024 10:57:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1708185460; x= 1708271860; bh=TCZ55C5DaLBmhshp6KShOMIW/mNw9fESkzpWPiimYrQ=; b=i TJFeCdWNCx+80PBxYZmVQHYR9FporgFuwsdfwylXJkCw57F3O5zmPIK9YRJqUZVn QJWf8nqHdvCYQFVrLuLSwzi7+Y872FQHOp4mj2bY+Au358lz8WYrc2+bkoSamnyQ AGzFoDZvA1JcTOHVNQ2S9NHG3lytPkGdJExvEhQsQ8aQJCUFtjS56jS8fKEuKsFP gt9UuyVV+g3TD60LS8SDMS4R6qiL1w4h7mDhVGPKX7MLC0Wgo4riWz83swQIjuCY SC30/HmGEazUHRZ3KBot6Ba4ge2ME4pR5Jyu6/Zx4FciRyFMxUq4KWV4hiTxOfjU OMncd6BbGbXuMM3h3vXyQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708185460; x=1708271860; bh=TCZ55C5DaLBmhshp6KShOMIW/mNw 9fESkzpWPiimYrQ=; b=WaYCtJJxFE+XeqMrVdhqDJFLyrG1GE4wtyLv6dpct5MU XCo3D7O+P4sVKOrAbfvqLtcZRNV+CN6i+xh+VmU0ZYH9ykyYqqL2P8jkXbz9qaQO e5KHHBg6Nvt403FRmoR+URb5K7kt6vhgUdPvk/9kFQtqwgYKFTu+yMW9dRfufx3n 8QHXouwwq/FPbY7QoFxSkDLEUFBj8yrza2cPmKi16T1ECdZcbE0StLehTgqhLgPS Q/8ck3O1V81pV/gbMEORtqQggPhFv8FZlWQBp1QWtFxeZuhiEvjkSwoSptCrkZ/9 N5APNoZ9wTitsbss3mk5yLlJiMSJ7ubYhPHx3GHgxw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeggdekvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepteeghffhjeeifefhkeeggfevffeitdeiieeuleelkedt veettdfgieetvddvueevnecuffhomhgrihhnpehphhhprdifrghttghhnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhf ihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5424D1700096; Sat, 17 Feb 2024 10:57:40 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <9bc2d842-5f56-4062-8b21-3b41310f2c86@app.fastmail.com> In-Reply-To: References: Date: Sat, 17 Feb 2024 09:57:20 -0600 To: "php internals" Subject: Re: [PHP-DEV] Re: [RFC] OOP API for cURL extension Content-Type: text/plain From: larry@garfieldtech.com ("Larry Garfield") On Thu, Feb 15, 2024, at 9:44 AM, Sara Golemon wrote: > Summarizing replies so far. Won't be able to update the RFC > immediately as my day job needs me, but some great discussions already, > gang. Thanks! > > * Define the conditions under which exceptions will be thrown (and > which exceptions) - I'll add these to the RFC, but in short: > * CurlException - Never, it's an interface type to group the other > exceptions. > * CurlHandleException - Whenever a CurlHandle::method() fails (in > lieu of returning false) > * CurlMultiException - Same, but for the CurlMultiHandle class. > * CurlShareException - Same, but for the CurlShareHandle class. > > * Naming styles, e.g getErrorNumber(): int vs errno() > Comment: Agreed with your points. We don't have to stick to a hard > line mapping of the function names. My initial translation did because > my bugbear is with the lack of fluency and all the rest is just window > dressing on that. > Proposal: I'll rename all the new APIs according to a get*/set* > scheme without abbreviations, e.g.: > * CurlHandle::getErrorNumber(): int > * CurlHandle::getError(): ?string > * static CurlHandle::getErrorTextFromCode(int $code): ?string > * CurlHandle::execute(): ?string // See late note about exec return > values > * CurlHandle::setOptionInt(int $option, int $value): CurlHandle > > * Better typing for setOpt() methods. > Comment: Yep, this is a good and fair point. It's going to take a > little more dicing up of the current implementation, but hopefully not > too rough. > Proposal: Keep untyped setOption() method (1/ Easier migration of > existing code, 2/ Some options may prove difficult to type), but add: > * CurlHandle::setOptionBool(int $option, bool $value): CurlHandle > * CurlHandle::setOptionInt(int $option, int $value): CurlHandle > * CurlHandle::setOptionString(int $option, string $value): CurlHandle > * etc... as needed, will this get weird when we get to Array since > there IS a setOptArray? Maybe we just don't mirror that one, or we > call it setOptionMany(). Yeah, I like Many for the multiple option set, > and Array for the single option of array type. > Internally, the setopt handler will be split by type so that each > typed setting can call explicitly, and the untyped one can call all. > > * CurlHandle::exec() mixed typing of return values. > Comment: Agreed. The `true` return value becomes meaningless in the > RETURNTRANSFER==false case. > Proposal: Update the RFC for CurlHandle::execute() to return ?string. > > * https://php.watch/articles/php-curl-security-hardening > Comment: I'll read this later when I'm updating the RFC. > > * Prefer class constants to global constants. > Comment: I'm less compelled by this. The global scope is polluted > with the constants whether we add copies or not. Adding a second way > to spell the constant name only adds a second way to spell the constant > name. > Proposal: Change my mind? > > * Request and Response objects, along the lines of PSR-18 > Comment: I'd be in favor of that, but it's not the mountain I'm > personally trying to climb today. No offense taken if you vote no > because this isn't enough, but I don't have the cycles to go in that > hard. > Proposal: Write an RFC (and get it passed) and I can probably help > you implement it? > > -Sara Obligatory: This seems like something that could be done in user-space as a wrapper around Curl. (That's basically what many HTTP clients are.) Why should this be done in C? The reasoning for that needs to be included in the RFC. The RFC would also benefit greatly from some practical examples of using the new API. Right now it's not clear to me (as someone who almost never uses Curl directly) how/why I'd use any of these, since there's still "a whole crapton of int constants I don't understand floating around." The suggestion to use an Enum (or several) here is a good one and would help a lot with that, so I'm +1 there. Overall I'm not opposed, but there's more fleshing that is needed before it's ready. (Which seems like it's happening based on Sara's response above, so that's good. --Larry Garfield