From f9bf486c463cd78e78c222bb45606722dc4f65c9 Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Wed, 20 Nov 2024 03:08:49 +0000 Subject: [PATCH 1/9] Create stub --- .../network/functions/request-parse-body.xml | 91 +++++++++++++++++++ reference/network/versions.xml | 1 + 2 files changed, 92 insertions(+) create mode 100644 reference/network/functions/request-parse-body.xml diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml new file mode 100644 index 000000000000..eaaeda57678a --- /dev/null +++ b/reference/network/functions/request-parse-body.xml @@ -0,0 +1,91 @@ + + + + request_parse_body + REF PURPOSE FOR request_parse_body + + + + &reftitle.description; + + arrayrequest_parse_body + arraynulloptions&null; + + + DESCRIPTION + + + + + &reftitle.parameters; + + + options + + + The Internet host name. + + + + + + + + &reftitle.returnvalues; + + DESCRIPTION + If there are none, &null; is returned instead. + + + + + &reftitle.examples; + + <function>request_parse_body</function> example + + Description. + + + +]]> + + &example.outputs.similar; + + + + + + + + &reftitle.seealso; + + function_name + + + + + diff --git a/reference/network/versions.xml b/reference/network/versions.xml index 424810d9a6e1..bd08fcc45831 100644 --- a/reference/network/versions.xml +++ b/reference/network/versions.xml @@ -34,6 +34,7 @@ + From 8ec284a0f4cedb6b4d892ebb89f59bf6cb4770b8 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 26 Nov 2024 16:39:02 +0100 Subject: [PATCH 2/9] Document request_parse_body() --- language/errors/php7.xml | 3 + language/predefined/exceptions.xml | 1 + .../predefined/requestparsebodyexception.xml | 72 +++++++++++++ language/predefined/versions.xml | 2 + .../network/functions/request-parse-body.xml | 102 ++++++++++++++---- 5 files changed, 157 insertions(+), 23 deletions(-) create mode 100644 language/predefined/requestparsebodyexception.xml diff --git a/language/errors/php7.xml b/language/errors/php7.xml index 49fbdcfb1072..55400297825c 100644 --- a/language/errors/php7.xml +++ b/language/errors/php7.xml @@ -75,6 +75,9 @@ FiberError + + RequestParseBodyException + diff --git a/language/predefined/exceptions.xml b/language/predefined/exceptions.xml index d655ffb6335c..14a3f914d56c 100644 --- a/language/predefined/exceptions.xml +++ b/language/predefined/exceptions.xml @@ -27,6 +27,7 @@ &language.predefined.valueerror; &language.predefined.unhandledmatcherror; &language.predefined.fibererror; + &language.predefined.requestparsebodyexception; + + RequestParseBodyException + RequestParseBodyException + + + + +
+ &reftitle.intro; + + An RequestParseBodyException is + thrown in request_parse_body when the request body is + invalid, according to the Content-Type header. + +
+ + +
+ &reftitle.classsynopsis; + + + + + RequestParseBodyException + + + + extends + Exception + + + &InheritedProperties; + + + + + &InheritedMethods; + + + + + + + + + + +
+
+
+ diff --git a/language/predefined/versions.xml b/language/predefined/versions.xml index d79b0320fb76..122484e8f9e1 100644 --- a/language/predefined/versions.xml +++ b/language/predefined/versions.xml @@ -101,6 +101,8 @@ + + diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index eaaeda57678a..1fecfbef1fed 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -1,8 +1,8 @@ - + request_parse_body - REF PURPOSE FOR request_parse_body + Read and parse the request body and return the result @@ -12,8 +12,37 @@ arraynulloptions&null; - DESCRIPTION + This function reads the request body and parses it according to the + Content-Type header. Currently, two content types are + supported: + + + + + application/x-www-form-urlencoded + + + + + multipart/form-data + + + + + + This function is used primarily to parse + multipart/form-data requests with HTTP verbs other than + POST which do not automatically populate the + $_POST and $_FILES superglobals. + + + + + request_parse_body consumes the request body without + buffering it to the php://input stream. + + @@ -23,7 +52,22 @@ options - The Internet host name. + The options parameter accepts an associative array + to override the following global INI settings for parsing of the request + body. + + + + max_file_uploads + max_input_vars + max_multipart_body_parts + post_max_size + upload_max_filesize + + + + Providing invalid keys or values will result in a + ValueError. @@ -33,41 +77,53 @@ &reftitle.returnvalues; - DESCRIPTION - If there are none, &null; is returned instead. + request_parse_body returns an array pair with the + equivalent of $_POST at index 0 and + $_FILES at index 1. + + + When the request body is invalid, according to the + Content-Type header, a + RequestParseBodyException is thrown. &reftitle.examples; - + <function>request_parse_body</function> example - - Description. - ]]> - &example.outputs.similar; - + + + <function>request_parse_body</function> example with customized options + '10M', + 'upload_max_filesize' => '10M', +]); + +// Do something with the uploaded files. +?> ]]> - + - - - &reftitle.seealso; - - function_name - - - From b1d5e5debb41eeb3370d176b8008a304c5b17fa0 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 16:56:10 +0100 Subject: [PATCH 4/9] Fix whitespace --- language/predefined/requestparsebodyexception.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/predefined/requestparsebodyexception.xml b/language/predefined/requestparsebodyexception.xml index 61c00c3222e9..6bf9225fa952 100644 --- a/language/predefined/requestparsebodyexception.xml +++ b/language/predefined/requestparsebodyexception.xml @@ -13,7 +13,7 @@ A RequestParseBodyException is thrown in request_parse_body when the request body is invalid, according to the Content-Type header. - + From 5f6b135b1e3bd93f7df2695927fa6696367ca611 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 17:00:05 +0100 Subject: [PATCH 5/9] Fix whitespace and remove unused tags --- .../network/functions/request-parse-body.xml | 68 +++++++++---------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index 1fecfbef1fed..c923878b99d9 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -12,29 +12,27 @@ arraynulloptions&null; - This function reads the request body and parses it according to the - Content-Type header. Currently, two content types are - supported: + This function reads the request body and parses it according to the + Content-Type header. Currently, two content types are + supported: - - - - - application/x-www-form-urlencoded - - - - - multipart/form-data - - - - + + + + application/x-www-form-urlencoded + + + + + multipart/form-data + + + - This function is used primarily to parse - multipart/form-data requests with HTTP verbs other than - POST which do not automatically populate the - $_POST and $_FILES superglobals. + This function is used primarily to parse + multipart/form-data requests with HTTP verbs other than + POST which do not automatically populate the + $_POST and $_FILES superglobals. @@ -56,15 +54,13 @@ to override the following global INI settings for parsing of the request body. - - - max_file_uploads - max_input_vars - max_multipart_body_parts - post_max_size - upload_max_filesize - - + + max_file_uploads + max_input_vars + max_multipart_body_parts + post_max_size + upload_max_filesize + Providing invalid keys or values will result in a ValueError. @@ -77,14 +73,14 @@ &reftitle.returnvalues; - request_parse_body returns an array pair with the - equivalent of $_POST at index 0 and - $_FILES at index 1. + request_parse_body returns an array pair with the + equivalent of $_POST at index 0 and + $_FILES at index 1. - When the request body is invalid, according to the - Content-Type header, a - RequestParseBodyException is thrown. + When the request body is invalid, according to the + Content-Type header, a + RequestParseBodyException is thrown. From 797fb3c26ce75355df6a15516eb62be7868496c2 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 17:03:02 +0100 Subject: [PATCH 6/9] Use varname for $_POST and $_FILES --- reference/network/functions/request-parse-body.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index c923878b99d9..cc2f25b142fc 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -32,7 +32,7 @@ This function is used primarily to parse multipart/form-data requests with HTTP verbs other than POST which do not automatically populate the - $_POST and $_FILES superglobals. + $_POST and $_FILES superglobals. @@ -74,8 +74,8 @@ &reftitle.returnvalues; request_parse_body returns an array pair with the - equivalent of $_POST at index 0 and - $_FILES at index 1. + equivalent of $_POST at index 0 and + $_FILES at index 1. When the request body is invalid, according to the From 827116b3951d52c319ac6b95b19fbea80eac8b0c Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 17:06:09 +0100 Subject: [PATCH 7/9] Use &php.ini; directive --- reference/network/functions/request-parse-body.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index cc2f25b142fc..5d32f46f5fdc 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -51,8 +51,8 @@ The options parameter accepts an associative array - to override the following global INI settings for parsing of the request - body. + to override the following global &php.ini; settings for parsing of the + request body. max_file_uploads From 46f167407f9f5644d471c2ced00e7afd0fb5ffb3 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 20:11:37 +0100 Subject: [PATCH 8/9] Update reference/network/functions/request-parse-body.xml Co-authored-by: Gina Peter Banyard --- .../network/functions/request-parse-body.xml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index 5d32f46f5fdc..727bfde47b0f 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -77,10 +77,19 @@ equivalent of $_POST at index 0 and $_FILES at index 1. + + + + &reftitle.errors; + + When the request body is invalid, + according to the Content-Type header, + a RequestParseBodyException is thrown. + - When the request body is invalid, according to the - Content-Type header, a - RequestParseBodyException is thrown. + A ValueError is thrown when + options contains invalid keys, + or invalid values for the corresponding key. From 02350362ce9023c292ab900b3c3b440ed6599575 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 27 Nov 2024 20:11:42 +0100 Subject: [PATCH 9/9] Update reference/network/functions/request-parse-body.xml Co-authored-by: Gina Peter Banyard --- reference/network/functions/request-parse-body.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reference/network/functions/request-parse-body.xml b/reference/network/functions/request-parse-body.xml index 727bfde47b0f..2dea65b633bc 100644 --- a/reference/network/functions/request-parse-body.xml +++ b/reference/network/functions/request-parse-body.xml @@ -61,10 +61,6 @@ post_max_size upload_max_filesize - - Providing invalid keys or values will result in a - ValueError. -