Skip to content

Web: CONTENT_LENGTH — incoming $_SERVER and outgoing CGI Content-Length #314

@PurHur

Description

@PurHur

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

  1. Incoming: populate $_SERVER['CONTENT_LENGTH'] from HTTP Content-Length header (or computed body size after read) in DevServer and AOT refresh.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions