From 257aff07d718a2ee8f1e373222092feaaf16d109 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 23 Sep 2021 18:07:54 +0200 Subject: [PATCH] v1.1.0 changes --- json_post.md | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/json_post.md b/json_post.md index e220dfd..65ca94d 100644 --- a/json_post.md +++ b/json_post.md @@ -8,7 +8,7 @@ Parse JSON request bodies into `$_POST`. ## What it does: -This tiny extension provides a PHP content type handler for `text/json` to PHP's form data parser. +This tiny extension provides a PHP content type handler for JSON to PHP's form data parser. If the `Content-Type` of an incoming request is `application/json` or `text/json`, the JSON contents of the request body will by parsed into `$_POST`. @@ -24,8 +24,30 @@ This extension is hosted at [PECL](http://pecl.php.net) and can be installed wit ## INI Directives: -* json_post.flags = 1; json_decode() flags - * JSON_OBJECT_AS_ARRAY = 1 - * JSON_BIGINT_AS_STRING = 2 - * JSON_OBJECT_AS_ARRAY|JSON_BIGINT_AS_STRING = 3 - +json_post.flags = 1 +: json_decode() flags + * JSON_OBJECT_AS_ARRAY = 1 + * JSON_BIGINT_AS_STRING = 2 + * JSON_OBJECT_AS_ARRAY|JSON_BIGINT_AS_STRING = 3 + * JSON_INVALID_UTF8_IGNORE = 1048576 ; (PHP >= 7.2) + * JSON_INVALID_UTF8_SUBSTITUTE = 2097152 ; (PHP >= 7.2) + * JSON_THROW_ON_ERROR is ignored + +json_post.onerror.response = 0 +: Send a custom HTTP response status on failure, e.g.: + ; send `HTTP/1.1 400 Bad Request` on error + json_post.onerror.response = 400 + +json_post.onerror.warning = Off +: Raise `E_WARNING` on failure decoding JSON when enabled. + +json_post.onerror.exit = Off +: Exit PHP without running the script on decoding failure when enabled. + +## Changelog: + +0. v1.1.0 + * Ignore JSON_THROW_ON_ERROR in `json_post.flags`. + * Add `json_post.onerror.response` INI setting. + * Add `json_post.onerror.warning` INI setting. + * Add `json_post.onerror.exit` INI setting. -- 2.30.2