Problem
CGI responses and phpc serve should expose accurate Content-Length when the body size is known. Today DevServer may rely on connection close for small responses; some clients and proxies behave better with explicit length. $_SERVER['CONTENT_LENGTH'] for incoming requests is separate but often paired in frameworks.
Outgoing: scripts cannot set Content-Length via header() reliably in all modes (#51). Incoming: POST bodies may not set CONTENT_LENGTH env when chunked (#287).
Goal
- Incoming: populate
$_SERVER['CONTENT_LENGTH'] from HTTP Content-Length header (or computed body size after read) in DevServer and AOT refresh.
- Outgoing (v1): when serve driver buffers the full response body, emit
Content-Length: N in CGI header block unless Transfer-Encoding: chunked is required later.
Scope
Acceptance criteria
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
./script/ci-local.sh --filter content_length
Fixture echoes $_SERVER['CONTENT_LENGTH'] matching posted body size.
Verification (local / Docker only)
No GitHub Actions required.
Dependencies
Links
Problem
CGI responses and
phpc serveshould expose accurateContent-Lengthwhen the body size is known. Today DevServer may rely on connection close for small responses; some clients and proxies behave better with explicit length.$_SERVER['CONTENT_LENGTH']for incoming requests is separate but often paired in frameworks.Outgoing: scripts cannot set
Content-Lengthviaheader()reliably in all modes (#51). Incoming: POST bodies may not setCONTENT_LENGTHenv when chunked (#287).Goal
$_SERVER['CONTENT_LENGTH']from HTTPContent-Lengthheader (or computed body size after read) in DevServer and AOT refresh.Content-Length: Nin CGI header block unlessTransfer-Encoding: chunkedis required later.Scope
lib/Web/DevServer.php— setCONTENT_LENGTHenv +$_SERVERwhen body readlib/AOT/runtime/superglobals_refresh.c— copyCONTENT_LENGTHfrom envServeTestfor POST withContent-Length: 12Acceptance criteria
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \ ./script/ci-local.sh --filter content_lengthFixture echoes
$_SERVER['CONTENT_LENGTH']matching posted body size.Verification (local / Docker only)
No GitHub Actions required.
Dependencies
Links
lib/Web/Superglobals.php,lib/Web/DevServer.php