Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114045 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44448 invoked from network); 12 Apr 2021 20:45:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Apr 2021 20:45:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B976E1804BD for ; Mon, 12 Apr 2021 13:46: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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, MISSING_HEADERS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 12 Apr 2021 13:46:19 -0700 (PDT) Received: by mail-io1-f54.google.com with SMTP id h141so6477538iof.2 for ; Mon, 12 Apr 2021 13:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:cc; bh=dOtIaAAWj0D+XNKqLgyW2sT1kGGhgGVTla98QDEYuYo=; b=Gqa1xXs8/tHTv7yycd5/jtJWilhFQpId/E53MG2qc21zJvmr1YWsPXuwI5bPifCpFq KTz8TBiGfOfae/yr4QSsaWm7fwwaY+QqMw+7UnO/aS+xcpJMcO2NmyqHKn5kP3/v+/Pa JIh6/Z1tCemgsky6WSShb2Z0w1MmgFlGRqRPFBotkw4V5GDls7/XvQDN85BJumYLK6/v WasdpNDFZyDdInFRkJGWLO/ukoG3cl65fZDyWX4TV+nI3plOyIwDUiQcColIoCrK7rZv V0s3rG7zI1T0S4pflVUleH1bCgbRHiOm8DcvXJRaHo7qMgNqrGhaxrpVfvEa/ILZinLU Jc4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:cc; bh=dOtIaAAWj0D+XNKqLgyW2sT1kGGhgGVTla98QDEYuYo=; b=mY5Hv6Utl/rprP5iOhkY0LVoVLjl2aM2VOaZcy3yjMU9HdQQvXCE/tEHyRwYXiXbqW fSobwR68UtcPn+T96qvXpjsGaKxKtHkiqkLHB1MY0mznx79RzHEyK81OjFcocQn14Yt4 2WLuUFRyqZ69nm6tacULXnlG+swhY+uf+EDbDWlSs9FfiDt5uA9LZgThXwPa27yUVKcq UF3axnwBvOqR8Mi5f5EB+XoD70fnqyHeAwVSD9+v2+sRuK1JcqxDq5XcZX4Jho06rrRB gZy2CKjWDy1AQcGAMNw+bHrnwxvju6L/1nZ9lPBAGFKnbri3qTrR5l7qmAXTrEkpV0U/ sYSQ== X-Gm-Message-State: AOAM530/pJMlFpH76SYsXHS7bBh80RAm5Zuw8mmsAplcN7fOBr2XT348 VJcX08nSl273QGHODgM46OKVvgZejev7/EGIZxPkXOZ9ZCk= X-Google-Smtp-Source: ABdhPJxKd54VchWbwvCyu79a4NNQqL2iaw5qlurz1RhYq4+4Z62Cua5zansRo+KxRj0Nx9HJhFU43tX1bYDf+nWqaZ0= X-Received: by 2002:a05:6638:22a:: with SMTP id f10mr30925743jaq.38.1618260376525; Mon, 12 Apr 2021 13:46:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 12 Apr 2021 22:46:04 +0200 Message-ID: Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000e59e7805bfcc9a8e" Subject: Re: [PHP-DEV] add php.ini entry to set default user_agent for curl From: paresy@gmail.com (Michael Maroszek) --000000000000e59e7805bfcc9a8e Content-Type: text/plain; charset="UTF-8" Hi Nikita, sure! We are embedding PHP through SAPI to allow our users interaction through PHP scripts. That allows them to automate a lot of things and one of them is doing web requests. For our new version we wanted to set the user-agent, to properly recognize/categorize requests on our infrastructure and where they are coming from. Therefore we liked the idea of doing it "globally" via a php.ini switch. This way we found the inconsistency between file_get_contents et al. and cURL and the missing possibility to define a default user agent for cURL. (I am aware that anyone can override the user-agent in userspace) If you prefer to reuse the already available user_agent ini entry i will gladly update my PR. Doing the patch was quick. Making good tests took time. I know that my use case might not represent the majority of PHP users, therefore i tried to argue in direction of consistency instead of my rather minor use case. I hope that it helps to understand my motivation. Michael Am Mo., 12. Apr. 2021 um 17:02 Uhr schrieb Nikita Popov < nikita.ppv@gmail.com>: > On Thu, Apr 8, 2021 at 2:41 PM Michael Maroszek wrote: > >> Dear Internals, >> I'd like to suggest a new enhancement for 8.1 as outlined in the title. >> >> The initial pull request is here: >> https://github.com/php/php-src/pull/6834/files >> >> --- Details: >> Since quite a while PHP offers a dedicated user_agent php.ini entry, but >> it >> affects only all internal implementations like file_get_contents. cURL has >> no default and you need to modify CURLOPT_USERAGENT in the code and for >> the >> SoapClient there is a parameter 'user-agent' in the constructor which can >> be set. >> >> Therefore I'd like to introduce an equal entry for curl.user_agent which >> would set a default user_agent when making curl requests. Of course you >> can >> override it with CURLOPT_USERAGENT if required. (I can implement the same >> for SoapClient, if requested) >> >> --- Alternative: >> I could also use the default user_agent entry, but I wasn't sure what the >> best practise is and went for the more "local" approach for the initial >> implementation. >> >> --- Bigger picture: >> When the preferred solution is to use the default user_agent, we could >> also >> try to determine more places where i could send the default user_agent to >> give this php.ini entry a more consistent feeling. >> >> Thanks for your consideration, >> Michael >> > > Could you please describe what your use case for this change is? > > I'm generally not a fan of adding more ini settings (aka global state) > without a strong motivation, and it's not immediately obvious what that > motivation is in this case. This seems useful if you have both a) one user > agent you want to use for everything and b) a lot of heterogeneous code > that doesn't use any common abstraction, which seems like a rather odd > situation to be in. > > Regards, > Nikita > --000000000000e59e7805bfcc9a8e--