Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118106 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 95694 invoked from network); 27 Jun 2022 11:19:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Jun 2022 11:19:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1D24618037E for ; Mon, 27 Jun 2022 06:10:19 -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=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 ; Mon, 27 Jun 2022 06:10:18 -0700 (PDT) Received: by mail-pl1-f177.google.com with SMTP id jb13so8122845plb.9 for ; Mon, 27 Jun 2022 06:10:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xsxKVyhBEZGqLiAOr211iqxadOKmM3nPsOc0TXW6nGA=; b=w5qQ04wzWPvIXzvVigEr1PwDK3CjFMpmwZIaNb5Unv/iNiKNfKqAj7eZWiE5CofqFR f9WcuLI4iy2oeoVarFMVdPyRu5bbCSl5wpUMXG4Ewu+Z8UdZIsGbh7yeuq36LdEbnECV kD/SheYEqMPwIyPyKBqTqboekhzH6Sew/HiXcj+LvRynVO0TjWPlv67Y4lY7T6CmZd1B nF3NmQXNkvm0ruK+u5fXs2xh63Z/2NCOvtplUQEPkkiTSFvYiaghRlvHzrO48qaalVfM 5s0Sjw+8ZIZDCOByB2Dht2ZFCQRX0lfA6TQDsOJ6NVfZ6fp5uBUgv3LHf1QN0WBRA5w5 DhQQ== X-Gm-Message-State: AJIora8arAywdGr4UICriOzty/btn4Iy5DZvy7yYSnif/kBLyIMbU1Lg bLA2ryz6T/bIvegCiRogHcVdoQ2PtJqBQANgv1uuHgTO7hxVBQ== X-Google-Smtp-Source: AGRyM1sQXXQANgPCJ56f7JjlgWE1wxbUTK+Tb/cnoPjBfAH+bJS9Runb4N/tUKDB9goj2V+93wz3pRjOmeZIHYGycN0= X-Received: by 2002:a17:902:76c4:b0:16a:deb:c0ae with SMTP id j4-20020a17090276c400b0016a0debc0aemr14628318plt.22.1656335417450; Mon, 27 Jun 2022 06:10:17 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 27 Jun 2022 09:10:06 -0400 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000002fc02705e26da42d" Subject: Re: [PHP-DEV] [RFC] [Under Discussion] New Curl URL API From: pierrick@php.net (Pierrick Charron) --0000000000002fc02705e26da42d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Micha=C5=82, Thanks for your comments. You made me realise that the RFC missed information on a crucial part which is the new CURLOPT_CURLU option that tells curl to use the CurlUrl object instead of the "standard" CURLOPT_URL option. I just added some information on it in the RFC. The purpose of the CurlUrl class is to be able to build/see/modify an URL as it is seen by libcurl before/after passing it to your CurlHandle. It is not meant to be used alone as a representation of an URL. For example, you may want to do some checks to make sure that the URL you gave to your CurlHandle is well formatted and that the host or any other parts are what you want them to be, and that it was not something else because of some differences on how the URL was parsed. Or you may want to add/delete/overwrite some parts to sanitize your URL. That's why you have those setters/getters. This class is definitively not there to replace PSR-7 UriInterface. I can imagine some Guzzle or other implementation to build a CurlUrl handle from a UriInterface before giving it to curl. So this RFC is really targeted to users of curl_* functions. Le lun. 27 juin 2022, =C3=A0 02 h 29, Micha=C5=82 Marcin Brzuchalski < michal.brzuchalski@gmail.com> a =C3=A9crit : > Hi Pierrick > > =C5=9Br., 22 cze 2022 o 06:38 Pierrick Charron napisa= =C5=82(a): > >> Hi, >> >> Following our discussions we had on the subject of the new Curl URL API, >> and other curl improvements. I decided to only focus on adding the new >> Curl >> URL API and put aside all other improvements. Here is the RFC that >> reflects >> our current conversations. >> >> https://wiki.php.net/rfc/curl-url-api > > > TBH I have a problem with the proposed Curl* classes. > IMO they present a mix of responsibilities that I don't like. > > CurlUrl is for me is a mix of Url/Uri object properties well known from > other userland implementations like the PSR one > with Uri specific like the host, scheme, port, path, query, fragment, etc= . > but on the other hand, we have flags and options which > purpose is to pass Curl specific things but in IMO wrong place instead > (for instance Guzzle use separate argument in all methods for options and > flags. > Secondly, it has some default logic like `setScheme` allows to put a > scheme but requires the supported one, with an exception that you can > ignore support checking by a flag - IMO this logic belongs to its consume= r > logic and is not part of URL class logic and the `setPort` like above. > Next thing is that it again has all the getters and setters and is not > immutable. Why can't it be a simple constructor with read-only properties= , > no getters, no setters? Maybe I miss some discussion about why here. > > > The same goes for CurlException which looks like is an exception for > handling some encoding of Url and not exactly to the Url properties itsel= f. > > But with all that said, if the target audience is only a user of low leve= r > `curl_*` functions rather than users of higher abstraction libraries like > Guzzle or Httplug then, I guess I don't care that much. > I'm only afraid that such a mix of responsibilities can lead to bad habit= s > when it gets to the separation of concerns by developers who get used to = it > and won' see the problem as I do. > > Cheers, > Micha=C5=82 Marcin Brzuchalski > --0000000000002fc02705e26da42d--