Skip to content

Allow _ (Underscore) in Header Field Names #61

@rcanavan

Description

@rcanavan

RFC 7320 permits a number of "special" characters in the field-name of header fields, including both minus (-) and underscore (_):

header-field = field-name ":" OWS field-value OWS
field-name = token
token = 1*tchar
tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA

ext-http however forces a conversion from _ to - by setting xhyphen to true in php_http_pretty_key() whenever new headers are merged. I believe the following test should work, but currently does not due to the aforementioned conversion:

--TEST--
header string with hyphens and underscores
--SKIPIF--
<?php
include "skipif.inc";
?>
--FILE--
<?php

echo "Test\n";

$h = new http\Header("foo_bar-baz", "bar");
var_dump("Foo_Bar-Baz: bar" === (string) $h);

?>
Done
--EXPECT--
Test
bool(true)
Done

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions