Skip to content

Web: $_SERVER['SERVER_PROTOCOL'] from HTTP request line #306

@PurHur

Description

@PurHur

Problem

CGI/FastCGI deployments and frameworks expect $_SERVER['SERVER_PROTOCOL'] (typically HTTP/1.1). Dev server and Superglobals::populateServer() set GATEWAY_INTERFACE but do not populate SERVER_PROTOCOL, so portable code like:

if (($_SERVER['SERVER_PROTOCOL'] ?? '') === 'HTTP/1.1') { /* ... */ }

behaves differently under phpc serve than under PHP-FPM.

Blocks #50 CGI driver parity and #173 FastCGI adapter.

Goal

Set $_SERVER['SERVER_PROTOCOL'] from the parsed HTTP request line in DevServer and from CGI env when present. AOT refresh copies env through superglobals_refresh.c.

Scope

  • lib/Web/DevServer.php — parse HTTP/1.1 from request line; putenv('SERVER_PROTOCOL=...')
  • lib/Web/Superglobals.phppopulateServer() reads SERVER_PROTOCOL env (default HTTP/1.1 for dev server)
  • lib/AOT/runtime/superglobals_refresh.c — mirror other $_SERVER string keys
  • PHPT: test/real/cases/web_server_protocol.phpt
  • ServeTest / ServeAotTest assert protocol in $_SERVER for one fixture

Acceptance criteria

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./script/ci-local.sh --filter web_server_protocol

Fixture echoes HTTP/1.1 when served via phpc serve.

Verification (local / Docker only)

No .github/workflows/* changes 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