Skip to content

Commit 6df4de4

Browse files
committed
Remove UriData
1 parent ffd7ca3 commit 6df4de4

File tree

4 files changed

+5
-38
lines changed

4 files changed

+5
-38
lines changed

src/Request.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace HttpSoft\Request;
66

7-
use HttpSoft\Uri\UriData;
87
use Psr\Http\Message\RequestInterface;
98
use Psr\Http\Message\StreamInterface;
109
use Psr\Http\Message\UriInterface;
@@ -22,7 +21,7 @@ final class Request implements RequestInterface, RequestMethodInterface
2221
*/
2322
public function __construct(
2423
string $method = self::METHOD_GET,
25-
$uri = UriData::EMPTY_STRING,
24+
$uri = '',
2625
$body = 'php://temp',
2726
array $headers = [],
2827
string $protocol = '1.1'

src/RequestTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use HttpSoft\Stream\MessageTrait;
88
use HttpSoft\Stream\StreamFactory;
9-
use HttpSoft\Uri\UriData;
109
use HttpSoft\Uri\UriFactory;
1110
use InvalidArgumentException;
1211
use Psr\Http\Message\RequestInterface;
@@ -225,7 +224,7 @@ public function withUri(UriInterface $uri, $preserveHost = false): RequestInterf
225224
*/
226225
private function init(
227226
string $method = RequestMethodInterface::METHOD_GET,
228-
$uri = UriData::EMPTY_STRING,
227+
$uri = '',
229228
$body = 'php://temp',
230229
array $headers = [],
231230
string $protocol = '1.1'

src/SapiNormalizer.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44

55
namespace HttpSoft\Request;
66

7-
use HttpSoft\Uri\Uri;
8-
use HttpSoft\Uri\UriData;
7+
use HttpSoft\Uri\UriFactory;
98
use Psr\Http\Message\UriInterface;
109

1110
use function array_key_exists;
12-
use function explode;
13-
use function in_array;
1411
use function is_string;
15-
use function preg_replace;
1612
use function strpos;
1713
use function str_replace;
1814
use function strtolower;
@@ -50,33 +46,7 @@ public function normalizeProtocolVersion(array $server): string
5046
*/
5147
public function normalizeUri(array $server): UriInterface
5248
{
53-
$uriData = new UriData();
54-
55-
if (isset($server['HTTPS']) && in_array(strtolower((string) $server['HTTPS']), ['on', '1'])) {
56-
$uriData->setScheme(UriData::SCHEMES[UriData::SECURE_PORT]);
57-
} elseif ($scheme = $server['HTTP_X_FORWARDED_PROTO'] ?? $server['REQUEST_SCHEME'] ?? UriData::EMPTY_STRING) {
58-
$uriData->setScheme((string) $scheme);
59-
}
60-
61-
if ($host = $server['HTTP_X_FORWARDED_HOST'] ?? $server['HTTP_HOST'] ?? UriData::EMPTY_STRING) {
62-
$uriData->setHost((string) $host);
63-
} elseif ($host = $server['SERVER_NAME'] ?? $server['SERVER_ADDR'] ?? UriData::EMPTY_STRING) {
64-
$uriData->setHost((string) $host);
65-
}
66-
67-
if (($port = $server['SERVER_PORT'] ?? null) && (strpos($uriData->getHost(), ':') === false)) {
68-
$uriData->setPort((int) $port);
69-
}
70-
71-
if ($path = $server['REQUEST_URI'] ?? $server['ORIG_PATH_INFO'] ?? UriData::EMPTY_STRING) {
72-
$uriData->setPath(explode('?', preg_replace('/^[^\/:]+:\/\/[^\/]+/', '', (string) $path), 2)[0]);
73-
}
74-
75-
if ($query = $server['QUERY_STRING'] ?? UriData::EMPTY_STRING) {
76-
$uriData->setQuery((string) $query);
77-
}
78-
79-
return new Uri($uriData->__toString());
49+
return UriFactory::createFromServer($server);
8050
}
8151

8252
/**

src/ServerRequest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace HttpSoft\Request;
66

7-
use HttpSoft\Uri\UriData;
87
use InvalidArgumentException;
98
use Psr\Http\Message\ServerRequestInterface;
109
use Psr\Http\Message\StreamInterface;
@@ -71,7 +70,7 @@ public function __construct(
7170
array $queryParams = [],
7271
$parsedBody = null,
7372
string $method = self::METHOD_GET,
74-
$uri = UriData::EMPTY_STRING,
73+
$uri = '',
7574
$body = 'php://input',
7675
array $headers = [],
7776
string $protocol = '1.1'

0 commit comments

Comments
 (0)