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

2.0 Update Application.php Fix Request path_info #385

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public function swoole(Request $request, Response $response)
$server['path_info'] = $_GET[$this->config->get('var_pathinfo')];
}

// Nginx兼容: proxy_set_header SERVER_PORT $server_port;
if(isset($header['server_port'])) {
$server['server_port'] = $header['server_port'];
}

$_SERVER = array_change_key_case($server, CASE_UPPER);

// 重新实例化请求对象 处理swoole请求数据
Expand All @@ -81,10 +86,10 @@ public function swoole(Request $request, Response $response)
->withCookie($_COOKIE)
->withInput($request->rawContent())
->withFiles($_FILES)
->setBaseUrl($request->server['request_uri'])
->setUrl($request->server['request_uri'] . (!empty($request->server['query_string']) ? '&' . $request->server['query_string'] : ''))
->setHost($request->header['host'])
->setPathinfo(ltrim($request->server['path_info'], '/'));
->setBaseUrl($server['request_uri'])
->setUrl($server['request_uri'] . (!empty($server['query_string']) ? '&' . $server['query_string'] : ''))
->setHost($header['host'])
->setPathinfo(ltrim($server['path_info'], '/'));

// 更新请求对象实例
$this->route->setRequest($this->request);
Expand Down