More adjustments to path handling.
This commit is contained in:
parent
c57d2a49f2
commit
3dbf0fa85f
2 changed files with 19 additions and 3 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2309.111925
|
||||
0.2309.111944
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
// HttpRequest.php
|
||||
// Created: 2022-02-08
|
||||
// Updated: 2023-08-16
|
||||
// Updated: 2023-09-11
|
||||
|
||||
namespace Index\Http;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Index\Version;
|
||||
use Index\MediaType;
|
||||
use Index\Http\Content\IHttpContent;
|
||||
|
@ -80,7 +81,22 @@ class HttpRequest extends HttpMessage {
|
|||
$build = new HttpRequestBuilder;
|
||||
$build->setHttpVersion(new Version(...array_map('intval', explode('.', substr($_SERVER['SERVER_PROTOCOL'], 5)))));
|
||||
$build->setMethod($_SERVER['REQUEST_METHOD']);
|
||||
$build->setPath(parse_url('/' . trim($_SERVER['REQUEST_URI'], '/'), PHP_URL_PATH));
|
||||
|
||||
// this currently doesn't "properly" support the scenario where a full url is specified in the http request
|
||||
$path = $_SERVER['REQUEST_URI'];
|
||||
$pathQueryOffset = strpos($path, '?');
|
||||
if($pathQueryOffset !== false)
|
||||
$path = substr($path, 0, $pathQueryOffset);
|
||||
else {
|
||||
$pathHashOffset = strpos($path, '#');
|
||||
if($pathHashOffset !== false)
|
||||
$path = substr($path, 0, $pathHashOffset);
|
||||
}
|
||||
|
||||
if(!str_starts_with($path, '/'))
|
||||
$path = '/' . $path;
|
||||
|
||||
$build->setPath($path);
|
||||
$build->setParams($_GET);
|
||||
$build->setCookies($_COOKIE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue