Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121303 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 28251 invoked from network); 13 Oct 2023 17:16:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Oct 2023 17:16:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D1B0B18050B for ; Fri, 13 Oct 2023 10:16:00 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 13 Oct 2023 10:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1697217358; bh=iSI4UoFVeU74EK0fTdGR33BdholuFYvjpYmde/0jqXA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=BER3zhuB6N6L7PIbLYRy8fC+u/gsViyIvSPdR5u6HGYMJJbKTNw6RkLMvX7537Yqn e2WS5Gb+GPqgJOrdEZYBZixk0NEkPWUEJuM6tcYpQYxgokTxOCE4fEjhRu2nY5lJhr N+4BSNUVPubaosvZwliSJWWYupgbPiKIYjHmRirtK2nTvrjV8sAKNTAPWnVN+lfstJ aB5nzg9l1eEeRdS4We+FvsLnid8aAgrqchLYMeix5EubZiBs84DUyqqj3E0kc0eAnQ 1qcd1jzQZUudmE283Db1jJm6kshUHDU4DAEQpmjx9Uizt/zUiqmo79t8XanIyQIqgc Yunjtn/8HhI9A== Message-ID: <99ebd4db-18ae-42bb-9d96-388e59fa35ad@bastelstu.be> Date: Fri, 13 Oct 2023 19:15:55 +0200 MIME-Version: 1.0 To: =?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?= , Ilija Tovilo Cc: PHP internals References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: [RFC][Under discussion] RFC1867 for non-POST HTTP verbs From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 10/13/23 17:59, Michał Marcin Brzuchalski wrote: > Considering the function supports two formats multipart/form-data or > the application/x-www-form-urlencodedand > the fact that the return type and required arguments differ in regards to > format: content-type needed for multipart which returns two arrays packed > into return array aka $_POST and $_FILES and the boundary that is part of > content-type header and the other format that doesn't require content-type > header and returns effectively only one array aka $_POST why not having two > separate functions? Because then you can't just [$fields, $files] = request_parse_body($request->getBody(), $request->getHeader('content-type')); $request = $request->withParsedBody($fields); (using a PSR-7 ServerRequestInterface object for the example) and instead would need to manually parse the 'content-type' header instead of leaving the heavy lifting to PHP. > The proposal is to include two separate functions that have clear semantics > and prevent from invoking multipart without boundary or only form with > boundary: > * request_parse_body($input_stream): array - returning just $_POST > and maybe > * request_parse_multupart_body($input_stream, string $boundary): array > returning as proposed now two arrays packed $_POST and $_FILES > > Why the $inpit_stream accepts null - does it make sense to invoke the > function then? > Yes, because it effectively defaults to an optimized version of 'php://input'. Best regards Tim Düsterhus