Fixed bad host header in PSR-7 (if using 'php -S localhost:8000 system/router.php') part 2

This commit is contained in:
Matias Griese
2019-01-30 21:04:53 +02:00
parent d45efb484c
commit 604361045b
3 changed files with 58 additions and 61 deletions

View File

@@ -20,7 +20,7 @@
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
"nyholm/psr7-server": "^0.3",
"kodus/psr7-server": "*",
"nyholm/psr7": "^1.0",
"twig/twig": "~1.35",

109
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "15456de6102c76e49b23e3dad39658d5",
"content-hash": "96bb72327a133062393d3391201403d9",
"packages": [
{
"name": "antoligy/dom-string-iterators",
@@ -655,6 +655,61 @@
],
"time": "2018-12-04T20:46:45+00:00"
},
{
"name": "kodus/psr7-server",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/kodus/psr7-server.git",
"reference": "7c0e9c72e6cb282bf58e9e73386e4ded26c6ae13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/kodus/psr7-server/zipball/7c0e9c72e6cb282bf58e9e73386e4ded26c6ae13",
"reference": "7c0e9c72e6cb282bf58e9e73386e4ded26c6ae13",
"shasum": ""
},
"require": {
"php": "^7.1",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"replace": {
"nyholm/psr7-server": "^0.3"
},
"require-dev": {
"nyholm/nsa": "^1.1",
"nyholm/psr7": "^1.0",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Nyholm\\Psr7Server\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
},
{
"name": "Martijn van der Ven",
"email": "martijn@vanderven.se"
}
],
"description": "Helper classes to handle PSR-7 server requests",
"homepage": "http://tnyholm.se",
"keywords": [
"psr-17",
"psr-7"
],
"time": "2018-12-05T09:09:19+00:00"
},
{
"name": "league/climate",
"version": "3.4.1",
@@ -1081,58 +1136,6 @@
],
"time": "2018-09-02T11:50:33+00:00"
},
{
"name": "nyholm/psr7-server",
"version": "0.3.0",
"source": {
"type": "git",
"url": "https://github.com/Nyholm/psr7-server.git",
"reference": "1b71a848fcb066fb805b7a9ab3f41ff65bffcde8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/1b71a848fcb066fb805b7a9ab3f41ff65bffcde8",
"reference": "1b71a848fcb066fb805b7a9ab3f41ff65bffcde8",
"shasum": ""
},
"require": {
"php": "^7.1",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"nyholm/nsa": "^1.1",
"nyholm/psr7": "^1.0",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Nyholm\\Psr7Server\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
},
{
"name": "Martijn van der Ven",
"email": "martijn@vanderven.se"
}
],
"description": "Helper classes to handle PSR-7 server requests",
"homepage": "http://tnyholm.se",
"keywords": [
"psr-17",
"psr-7"
],
"time": "2018-09-02T10:41:28+00:00"
},
{
"name": "phive/twig-extensions-deferred",
"version": "v1.0.2",

View File

@@ -26,13 +26,7 @@ class RequestServiceProvider implements ServiceProviderInterface
$psr17Factory // StreamFactory
);
$request = $creator->fromGlobals();
// TODO: Remove workaround for bad host header (if using 'php -S localhost:8000 system/router.php').
$hosts = $request->getHeader('Host');
$host = end($hosts);
return $request->withHeader('Host', $host);
return $creator->fromGlobals();
};
}
}