zendframework / zend-diactoros

PSR-7 HTTP Message implementation
BSD 3-Clause "New" or "Revised" License
1.56k stars 152 forks source link

Version 2.0.2 breaks on Apache #346

Closed Y0lk closed 5 years ago

Y0lk commented 5 years ago

Since the update to 2.1.0, I'm getting the following error on a local Apache install on Windows. I haven't tested this anywhere else yet.

Fatal error: Uncaught Zend\Diactoros\Exception\InvalidArgumentException: "<address>Apache/2.4.9 (Win32) PHP/7.1.24 Server at website.local Port 80</address> " is not valid header value

The exact change that causes this issue is this commit: https://github.com/zendframework/zend-diactoros/commit/1e8b6c4db2aed9647945f86a3e46178fca509e04#diff-9d47206c200ee53ffe55d05493ddd000

I've tried commenting out the line that was added and it fixes the issue

Code to reproduce the issue

$request = \Zend\Diactoros\ServerRequestFactory::fromGlobals(
    $_SERVER,
    $_GET,
    $_POST,
    $_COOKIE,
    $_FILES
);
bluebaroncanada commented 5 years ago

@Y0lk, you can fix this for now by deleting line 50 from marshal_headers_from_sapi.php.

Y0lk commented 5 years ago

Yeah, as I wrote in the description, it's the commit that added this line 50 that causes problem. You can just force the version to 2.0.1 in your composer.json for a cleaner fix for now

bluebaroncanada commented 5 years ago

Ah. Sorry. I actually came upon this issue after I made the pull request. Sorry I didn't read it well enough. He was trying to fix an error where he was assuming headers with a 0 value were not being accepted. He ended up defeating the filter in the process. I think he just needs to prefix his headers with HTTP_.

bluebaroncanada commented 5 years ago

349

weierophinney commented 5 years ago

Fixed with versions 2.0.3 and 2.1.1.