fix for #602
This commit is contained in:
parent
341fe344d0
commit
00ad891fce
2 changed files with 23 additions and 15 deletions
28
api.php
28
api.php
|
|
@ -2941,7 +2941,7 @@ namespace Nyholm\Psr7Server {
|
|||
|
||||
$headers = \function_exists('getallheaders') ? getallheaders() : static::getHeadersFromServer($_SERVER);
|
||||
|
||||
return $this->fromArrays($server, $headers, $_COOKIE, $_GET, $_POST, $_FILES, fopen('php://input', 'r') ?: null);
|
||||
return $this->fromArrays($server, $headers, $_COOKIE, $_GET, $_POST, $_FILES, \fopen('php://input', 'r') ?: null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3132,22 +3132,30 @@ namespace Nyholm\Psr7Server {
|
|||
{
|
||||
$uri = $this->uriFactory->createUri('');
|
||||
|
||||
if (isset($server['REQUEST_SCHEME'])) {
|
||||
$uri = $uri->withScheme($server['REQUEST_SCHEME']);
|
||||
} elseif (isset($server['HTTPS'])) {
|
||||
$uri = $uri->withScheme('on' === $server['HTTPS'] ? 'https' : 'http');
|
||||
if (isset($server['HTTP_X_FORWARDED_PROTO'])) {
|
||||
$uri = $uri->withScheme($server['HTTP_X_FORWARDED_PROTO']);
|
||||
} else {
|
||||
if (isset($server['REQUEST_SCHEME'])) {
|
||||
$uri = $uri->withScheme($server['REQUEST_SCHEME']);
|
||||
} elseif (isset($server['HTTPS'])) {
|
||||
$uri = $uri->withScheme('on' === $server['HTTPS'] ? 'https' : 'http');
|
||||
}
|
||||
|
||||
if (isset($server['SERVER_PORT'])) {
|
||||
$uri = $uri->withPort($server['SERVER_PORT']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($server['HTTP_HOST'])) {
|
||||
$uri = $uri->withHost($server['HTTP_HOST']);
|
||||
if (1 === \preg_match('/^(.+)\:(\d+)$/', $server['HTTP_HOST'], $matches)) {
|
||||
$uri = $uri->withHost($matches[1])->withPort($matches[2]);
|
||||
} else {
|
||||
$uri = $uri->withHost($server['HTTP_HOST']);
|
||||
}
|
||||
} elseif (isset($server['SERVER_NAME'])) {
|
||||
$uri = $uri->withHost($server['SERVER_NAME']);
|
||||
}
|
||||
|
||||
if (isset($server['SERVER_PORT'])) {
|
||||
$uri = $uri->withPort($server['SERVER_PORT']);
|
||||
}
|
||||
|
||||
if (isset($server['REQUEST_URI'])) {
|
||||
$uri = $uri->withPath(\current(\explode('?', $server['REQUEST_URI'])));
|
||||
}
|
||||
|
|
|
|||
10
composer.lock
generated
10
composer.lock
generated
|
|
@ -70,16 +70,16 @@
|
|||
},
|
||||
{
|
||||
"name": "nyholm/psr7-server",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Nyholm/psr7-server.git",
|
||||
"reference": "1b71a848fcb066fb805b7a9ab3f41ff65bffcde8"
|
||||
"reference": "e6a526e9170e6e33a13efc2b61703ca476b7ea68"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/1b71a848fcb066fb805b7a9ab3f41ff65bffcde8",
|
||||
"reference": "1b71a848fcb066fb805b7a9ab3f41ff65bffcde8",
|
||||
"url": "https://api.github.com/repos/Nyholm/psr7-server/zipball/e6a526e9170e6e33a13efc2b61703ca476b7ea68",
|
||||
"reference": "e6a526e9170e6e33a13efc2b61703ca476b7ea68",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -118,7 +118,7 @@
|
|||
"psr-17",
|
||||
"psr-7"
|
||||
],
|
||||
"time": "2018-09-02T10:41:28+00:00"
|
||||
"time": "2019-11-05T20:36:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-http/message-factory",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue