Skip to content

Latest commit

 

History

History
82 lines (47 loc) · 2.01 KB

File metadata and controls

82 lines (47 loc) · 2.01 KB

Request Body Normalization

HTTPKernel normalizes request bodies through the upstream RequestBodyInterface and RequestBodyType.

The raw body and structured body remain separate:

HttpRequestInterface::body()        -> raw string or null
HttpRequestInterface::requestBody() -> normalized body classification

Implemented Classifier

The package currently ships:

  • LiquidRazor\HttpKernel\Lib\Adapter\HttpRequestBodyNormalizer

Supported outcomes are:

  • EMPTY
  • RAW_STRING
  • FORM_FIELDS
  • JSON_ASSOCIATIVE
  • JSON_OBJECT
  • MULTIPART
  • UNKNOWN

Normalization Rules

Empty

An empty raw body with no structured parameters becomes EMPTY.

Form Fields

application/x-www-form-urlencoded becomes FORM_FIELDS.

Structured parameters are stored in RequestBodyInterface::parameters().

JSON Associative

JSON dictionary payloads can become JSON_ASSOCIATIVE.

This mode keeps decoded key/value data in parameters().

JSON Object

JSON object preservation is explicit.

When object preservation is requested, the normalizer produces JSON_OBJECT and stores the decoded object in objects().

Multipart

multipart/* becomes MULTIPART.

The current implementation keeps multipart metadata in the upstream dictionary-shaped request body form.

Raw String

Non-empty textual or otherwise unclassified raw payloads become RAW_STRING.

Unknown

Opaque binary media types such as application/octet-stream become UNKNOWN.

UNKNOWN does not expose normalized parameter or object mappings.

Failure Behavior

Malformed JSON does not silently degrade.

The normalizer throws HttpRequestBodyNormalizationFailed for:

  • malformed JSON
  • unsupported JSON top-level shapes for the requested JSON mode
  • invalid structured data for the selected request body type

Current JSON Constraint

The current implementation expects a top-level JSON object for both supported JSON modes.

Top-level JSON arrays are rejected explicitly instead of being forced into an incorrect body type.