ReadsBoundedBody
Reads a request body whole, bounded by a byte cap.
Shared because a single read($cap) is not enough: PSR-7 promises only up
to the requested length, and a stream over php://input or a chunked
transfer routinely returns less — which truncates the payload into a parse
error the caller cannot act on.
Tags
Table of Contents
Methods
- readBoundedBody() : string|null
- Returns the body contents, or `null` when the payload exceeds $maxBytes.
Methods
readBoundedBody()
Returns the body contents, or `null` when the payload exceeds $maxBytes.
private
readBoundedBody(StreamInterface $body, int $maxBytes) : string|null
A stream advertising its size is rejected up front; otherwise the read is incremental and stops at the cap, so an unbounded stream cannot exhaust memory.
Parameters
- $body : StreamInterface
- $maxBytes : int