Skip to content

fix(negotiation): distinguish missing Accept-Encoding from empty or restrictive values #11

Closed

Description

@coisa

Behavior mismatch

ContentEncoding::isSupported returns true for any coding not explicitly rejected. Its docblock and two current test expectations encode this rule, but it disagrees with HTTP negotiation: an existing Accept-Encoding field only admits listed codings or a matching wildcard, and an explicitly empty field requests no content coding.

Evidence

Commit a429fbe9a7efce6cee50b82e4a981ea7e3b47a5f.

Regression cases

With mb_trim/mb_strtolower available:

  • isSupported(Deflate, 'gzip, br'): expected false, current true.
  • isSupported(Gzip, '') when an explicitly empty header is passed: expected false, current true.
  • isSupported(Identity, 'gzip, br'): remains true.
  • An absent header should still allow any coding; the current required string parameter cannot distinguish absent from present-empty.

Impact: a caller can select compression that a client did not advertise/cannot decode.

Acceptance criteria

Document and represent absence separately (for example nullable input or caller-level presence check), apply listed/wildcard/identity rules, correct the existing test expectations and add absence vs empty cases. Preserve explicit q=0 exclusions and aliases.

Priority P2; high-confidence conceptual/standards mismatch, not a security claim. Source analysis only; no PHP runtime available. No duplicate among existing issues/PRs #1–#8 or new #9–#10; #9 covers function availability and #10 covers a separate media-type selection algorithm.

Activity

  1. coisa commented on Oct 21, 2026

    @coisa
    ContributorAuthor

    Validation update: a user-local official Debian PHP 8.4.26 CLI with mbstring became available. Executed the issue's focused cases directly against the pinned source files, without source changes or network requests. All listed current results reproduced exactly. This confirms the behavioral finding dynamically; the full PHPUnit suite has not been run.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions