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

Built-in webserver not passing header correctly #16137

Closed
susnux opened this issue Sep 30, 2024 · 1 comment
Closed

Built-in webserver not passing header correctly #16137

susnux opened this issue Sep 30, 2024 · 1 comment

Comments

@susnux
Copy link

susnux commented Sep 30, 2024

Description

E.g. the ´Forwarded` header might appear more then once, NGinx and Apache correctly merge them into a comma separated list.
But the built-in server does not and just passes the first header set.

To test:

<?php
// index.php
var_dump($_SERVER['HTTP_FORWARDED']);

Run with:

php -S localhost:8000

Test with curl:

 curl -v -H 'Forwarded: for=127.0.0.1' -H 'Forwarded: for=unknown' localhost:8000
* Host localhost:8000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8000...
* Connected to localhost (::1) port 8000
* using HTTP/1.x
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/8.10.1
> Accept: */*
> Forwarded: for=127.0.0.1
> Forwarded: for=unknown
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Host: localhost:8000
< Date: Mon, 30 Sep 2024 17:28:59 GMT
< Connection: close
< X-Powered-By: PHP/8.3.11
< Content-type: text/html; charset=UTF-8
< 
string(13) "for=127.0.0.1"

Expected output:
for=127.0.0.1,for=unknown

PHP Version

8.3.11

Operating System

openSUSE Tumbleweek

@devnexen
Copy link
Member

devnexen commented Oct 1, 2024

not familiar that much with cli but seems to me the callback to concat value to headers need to handle Forwarded based headers values differently to address it, will start to look at it later today.

devnexen added a commit to devnexen/php-src that referenced this issue Oct 1, 2024
Those are meant to have 1 or plus values separated by a comma even
 if the client set them separately.
devnexen added a commit to devnexen/php-src that referenced this issue Oct 2, 2024
Those are meant to have 1 or plus values separated by a comma even
 if the client set them separately.
devnexen added a commit to devnexen/php-src that referenced this issue Oct 3, 2024
Those are meant to have 1 or plus values separated by a comma even
 if the client set them separately.
devnexen added a commit to devnexen/php-src that referenced this issue Oct 3, 2024
Those are meant to have 1 or plus values separated by a comma even
 if the client set them separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants