3 Commits

Author SHA1 Message Date
5f1d8bd46e Rename .claude knowledge base directory to docs
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 02:32:50 +03:00
b13885b002 Parse request body by Content-Type with 400 on bad input
Request::fromGlobals now accepts $_POST and chooses how to fill body()
based on Content-Type: JSON via json_decode, urlencoded via $_POST
(POST) or parse_str (PUT/PATCH/...), multipart via $_POST. Anything
else, or empty Content-Type, yields []. Charset suffix on JSON is
honoured.

Body parse failures throw HttpException(400) directly from fromGlobals
("Invalid JSON body" / "JSON body must be an object or array") so the
controller never sees garbage. Top-level JSON list ([1,2,3]) is
accepted as a valid body.

HttpApplication moves Request::fromGlobals into dispatch's try block
so the new HttpException maps to a 400 response uniformly. OPTIONS
preflight reads the method directly from $server and skips body
parsing entirely. The opportunistic catch (\JsonException) in dispatch
is gone — controller-level json_decode errors now correctly produce
500 instead of being mislabelled as "Invalid JSON body".

Adds Request::input(key, default) for per-field access alongside the
existing body() that returns the full array.

Tests: tests/Http/RequestTest.php (14 cases) covering JSON
object/list/scalar/null/malformed/charset/empty, urlencoded POST/PUT,
multipart, missing Content-Type, GET, and input() with/without default.
Suite: 34 tests, 55 assertions, all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 01:57:39 +03:00
4857be3d41 Update knowledge base 2026-04-06 18:47:11 +03:00