Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow _ (Underscore) in Header Field Names #61

Open
rcanavan opened this issue Feb 21, 2017 · 5 comments
Open

Allow _ (Underscore) in Header Field Names #61

rcanavan opened this issue Feb 21, 2017 · 5 comments

Comments

@rcanavan
Copy link

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
@m6w6
Copy link
Owner

m6w6 commented Feb 23, 2017

Hm, yeah, that origins from importing headers from the (CGI) environment where header names look like HTTP_ACCEPT_ENCODING.

@m6w6
Copy link
Owner

m6w6 commented Apr 4, 2017

Looks like Apache as well as nginx drop headers with underscores.

@afflerbach
Copy link

At least for nginx, you can explicitly allow underscores by setting underscores_in_headers on.

@filex
Copy link

filex commented Apr 4, 2017 via email

@m6w6
Copy link
Owner

m6w6 commented Apr 4, 2017

For Apache+mod_php: only with apache_request_headers(), but not through the environment, i.e. $_SERVER.

@m6w6 m6w6 added the suspended label Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants