Skip to content

Stdlib: get_headers() parity — associative arg index + wrapper behavior (ext/standard/head.c) #9212

Description

@PurHur

Category

stdlib

Problem

get_headers() behavior diverges from Zend/php-src. The in-tree implementation is VM-only and has an argument-index bug for the optional $associative flag (second argument is parsed with position 2).

This also lacks JIT/AOT support (throws).

php-src reference

  • php-src: ext/standard/head.c — PHP_FUNCTION(get_headers)
  • Wrapper plumbing (indirect): main/streams/http_fopen_wrapper.c

Repro

<?php
// 1) arg parsing / flag position
var_dump(get_headers('http://example.com', true));

// 2) non-http URLs: Zend returns false (and may warn depending on wrapper)
var_dump(get_headers('file:///etc/hosts'));

Zend expected

  • For (1): returns an array; when $associative=true, headers are grouped per php-src rules.
  • For (2): returns false with php-src-consistent warning / no-warning behavior for unsupported wrappers.

Current behavior (php-compiler)

  • Implementation: ext/standard/get_headers.php
  • Second arg is parsed via VmMath::parseBoolBuiltinArg(..., argnum=2, ...) even though it is the 2nd parameter.
  • JIT/AOT: call() throws LogicException('get_headers() is not supported in JIT/AOT in this compiler build').

Scope (this repo)

  • ext/standard/get_headers.php
  • ext/standard/VmHttpFetchNative.php / VmHttpHeaders.php / VmHttpLastResponseHeaders.php (as needed)
  • JIT lowering (optional, preferred): lib/JIT/Builtin/* or ext/standard/Jit*

Done when

  • Repro above matches Zend/php-src under php-src-strict on VM.
  • $associative parsing uses correct parameter index and php-src-consistent error messages.
  • Preferably: JIT no longer throws for get_headers() (or capability matrix explicitly documents VM-only).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions