Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127943 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 lists.php.net (Postfix) with ESMTPS id E78431A00BC for ; Mon, 7 Jul 2025 16:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751907128; bh=1Hb5ayvvY7WadO/oqrlrLYL9+cIjbkV8C+lppl+y7a4=; h=References:In-Reply-To:Reply-To:From:Date:Subject:Cc:From; b=Tjojx6HI0OhTAuqWe3iFmZdDpucYXrYgmjXa6Ld+WRN9SM4jMhIMJUu92cv5vUoxs 4WEtQK5gz3y1mEUQ/hs3paJWnRL1D12iM6Wawo8pyuuLPO/5lQYHQhIihLpXSvcsFW pr3W/Lh5KFcnp23CsOPyCmIW4SWL5blUYs0bq0nq3zArF6H+S6qRkpMK21Gwy946fU E62XrNsznTt3y44ESDqlFhCH3AVEGuRtzU07nOeAi3hZWC4S6nPhM169ymIHffQhMt VbTRKfP2l3p/E+9KJAiLY7ebsgy9ToPKE3yMkoXIxYAc+4LZPhSXgTAaBRybognYO9 49Yw7O3X6s+QQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 982181807DF for ; Mon, 7 Jul 2025 16:52:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLYTO,MALFORMED_FREEMAIL,MISSING_HEADERS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Jul 2025 16:52:05 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-3da73df6b6bso13258255ab.3 for ; Mon, 07 Jul 2025 09:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751907235; x=1752512035; darn=lists.php.net; h=content-transfer-encoding:cc:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1Hb5ayvvY7WadO/oqrlrLYL9+cIjbkV8C+lppl+y7a4=; b=UC/0aVy2aJ7Tjvv0MpEgsVZJxTzB0txFUB9oE/q0EtMrTN7479pyPRppm+2Z7DM2sn U6lupMuC9avHYz+gw0iiKqai3/fX2vm6CpnXPzLDFGhAMx7UERcoHydgF68l66NP8kIb XC4PgJUR/56cjoB6Rpb3IIVnXUgPMMaqkw3eXz/t9I5RdHJs9xnfFaxOA8d9+PhkVl6d 6TFKP+GpNKWeJLrboOWB/QXnjgtJ53wIXWIbmpocFLkNEW5R67AYlOUM8SCWDtu7afGP szzea9gJrWvnPj5ArDtDBbmKgg4TkFqQx0OGV74M60IgY+pGBBr6rqq5dFmmiqSAFn9K b06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751907235; x=1752512035; h=content-transfer-encoding:cc:subject:message-id:date:from:reply-to :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Hb5ayvvY7WadO/oqrlrLYL9+cIjbkV8C+lppl+y7a4=; b=rtrKREtwXrqTvWfMiy1PAB74x5eH207LY6m9SBQEk0fotn6QpBeQhbLp3Ob573X5+y yg6Alu6vhXuip4N1Y0norQ7tx8Lcn2DPCPqV/MOnlJ3snT+A9SWX6IoaGGLhhH3oDglo ydnY3nhtf0Qm332dVONTSV6iA3Hk/rkbaVXJ1tJyTKHPHB/0FwAEg8LiuKHf4V4fqW1Y uv9h5PXcPREdP9TK2bsw91XiFdT9nsLDRHIqYAxO/z5ENhsZt1tbKqIVwdFi/K2rMLFE MYurN23eB33C4ukZw72DxXfOfgC/hmCl5HHo+cA8K+kHLA6LJk37+BKdrrzDNJ7CzYpK h8vg== X-Gm-Message-State: AOJu0YxrxM+Gnb08n9azWd8/M4hRUhKCSF3deVc3iSUB+KAqABzkIwiT +Sh7s3zOhn0g24i0jsYs3lO+A/IwhEAHJ1epS+ymx6KpLGA0QrwpQYkJwpNnLveyGN+eqnxiIbl nijgERsDxCceFDCoav5zyOJFjaq35AfheQrM6 X-Gm-Gg: ASbGncufhBZ8M/o1nvDg/eqMZbOtMzCWZ7RdYszCc9xYpYC1WPnotplCwkSlAdCofhi NdqM9FUkOdyEl+RwYtIW6Xij6RI2PLxFzrYdGUArx3DhVZLwQa4/kR29r+Gtn/IshiRb9dU9Od6 XEZLKNdDczgAgoF45ifXdQq8x3FRdopeG4v4H8rROUI7jwpRMHP9YBDQ0SXjcJZ+Bb6zVvS4FqL nlBww== X-Google-Smtp-Source: AGHT+IF/D5oLOtYhR0LdjCTf8UFWc5k85lPuTx+Oul4w9/Ku51rv24WjlWEiss8zBJB0WtQGdwlBBowy33XhMFCW6ps= X-Received: by 2002:a05:6e02:2303:b0:3dd:f4d5:1c1a with SMTP id e9e14a558f8ab-3e1371dc051mr102736125ab.17.1751907234901; Mon, 07 Jul 2025 09:53:54 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Reply-To: erictnorris@gmail.com Date: Mon, 7 Jul 2025 12:53:38 -0400 X-Gm-Features: Ac12FXzheNP9MW_buPM-tvRArLdSrG8i0b-GiiipWtm1JpobKQX33NRoFX-L6xM Message-ID: Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Object-oriented curl API v2 Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: eric.t.norris@gmail.com (Eric Norris) On Wed, Jul 2, 2025 at 11:48=E2=80=AFAM Eric Norris wrote: > > > Based on the feedback so far (I do plan on waiting for more responses > > to your email), and on my own preferences, I wonder if there is a > > hybrid option I could propose. Perhaps the RFC could offer both a > > \Curl\Handle (tentative name) to address position 1, and a > > \Curl\BasicHttpHandle (also tentative name) that addresses position 2? > > If people were amenable, I'd even make the BasicHttpHandle a separate > > vote. > > > > I agree that 3 is both more bikesheddable and also possibly ideal, but > > I feel my above suggestion maybe strikes the right balance between the > > "status quo is fine, I don't want to see random HTTP-related methods > > on my low(est)-level curl object" and the "I'd like to do basic HTTP > > stuff with curl, without a library" crowds. > > > > Barring that, my preference would be 2, but I'd accept 1 just to have > > it pass - like I mentioned elsewhere, I think there is value in > > introducing namespaces and object-oriented APIs for "modernization" > > and language consistency reasons. > > Having thought about this some more, while I'm still feeling somewhat > positive about my suggestion I'm just not sure it's the best way to > proceed. I started to sketch what a BasicHttpHandle class would look > like, and I'm stuck on how to get data about the response out of the > class. > > Naively, we could have $response_status_code and $response_headers > properties, and have the same fetch() and execute() methods I > suggested elsewhere to get the response body. Alternatively, we could > return a simple CurlHttpResponse object which contains all three > properties in the fetch() and execute() implementations for the > BasicHttpHandle class. > > Both of these are fine, but they would lock us out of being PSR7 > compatible. I think that people would probably desire PSR7 > compatibility, and I would feel uncomfortable with eliminating or > tainting the possibility of achieving this. For example, if we had > this BasicHttpHandle and then later introduced PSR7 response objects, > we'd need to either break backwards compatibility for the class, or > introduce a second class. We could also go straight to returning a > PSR7 compatible response for the BasicHttpHandle class, but I think > that likely deserves its own RFC. > > So in closing, if people felt generally okay with the limitation of > not being PSR7 compatible, I'd probably still add some form of my > BasicHttpHandle suggestion as a secondary vote. If people thought PSR7 > was necessary, I'd drop it, and leave a PSR7-in-core RFC for the > future. In that case, I'd go with Larry's option 1 for the RFC; I've > currently updated the RFC to match that option for now. Thanks Ben, Larry, and Paul for your responses to my suggestion for a BasicHttpHandle class. After reflecting further, I have decided to move this to the Future Scope section, as it feels weighty enough to stand as its own RFC. I'd like to think about this a bit more, but I will note that having a Request and Response interface in core would greatly simplify the proposal for a simple curl-based HTTP client, so I'd likely support any effort on that front. I've also updated the Curl\MultiHandle class proposal to account for removing the CURLOPT_RETURNTRANSFER option. At this point I believe the RFC is in a semi-final state at this point, barring any additional discussion. Thanks all for the feedback so far!