Skip to content

Commit

Permalink
FPM 模式支持 PATH_INFO,增强 https 判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 8, 2021
1 parent fa1632f commit a8582d8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Http/Message/FpmRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ protected function initBody(): void
*/
protected function initUri(): void
{
if ('on' === ($_SERVER['HTTPS'] ?? null))
$https = $_SERVER['HTTPS'] ?? null;
if ('on' === $https || '1' === $https || 'https' === ($_SERVER['REQUEST_SCHEME'] ?? null))
{
$url = 'https://';
}
Expand All @@ -75,7 +76,19 @@ protected function initUri(): void
$url = 'http://';
}

$this->uri = new Uri($url . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if (isset($_SERVER['PATH_INFO']))
{
$path = $_SERVER['PATH_INFO'];
if (isset($_SERVER['QUERY_STRING']))
{
$path .= '?' . $_SERVER['QUERY_STRING'];
}
}
else
{
$path = $_SERVER['REQUEST_URI'];
}
$this->uri = new Uri($url . $_SERVER['HTTP_HOST'] . $path);
}

/**
Expand Down

0 comments on commit a8582d8

Please sign in to comment.