Warning, /webapps/ocs-webserver/library/vendor/guzzlehttp/psr7/README.md is written in an unsupported language. File is not indexed.
0001 # PSR-7 Message Implementation
0002
0003 This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
0004 message implementation, several stream decorators, and some helpful
0005 functionality like query string parsing.
0006
0007
0008 [](https://travis-ci.org/guzzle/psr7)
0009
0010
0011 # Stream implementation
0012
0013 This package comes with a number of stream implementations and stream
0014 decorators.
0015
0016
0017 ## AppendStream
0018
0019 `GuzzleHttp\Psr7\AppendStream`
0020
0021 Reads from multiple streams, one after the other.
0022
0023 ```php
0024 use GuzzleHttp\Psr7;
0025
0026 $a = Psr7\stream_for('abc, ');
0027 $b = Psr7\stream_for('123.');
0028 $composed = new Psr7\AppendStream([$a, $b]);
0029
0030 $composed->addStream(Psr7\stream_for(' Above all listen to me'));
0031
0032 echo $composed; // abc, 123. Above all listen to me.
0033 ```
0034
0035
0036 ## BufferStream
0037
0038 `GuzzleHttp\Psr7\BufferStream`
0039
0040 Provides a buffer stream that can be written to fill a buffer, and read
0041 from to remove bytes from the buffer.
0042
0043 This stream returns a "hwm" metadata value that tells upstream consumers
0044 what the configured high water mark of the stream is, or the maximum
0045 preferred size of the buffer.
0046
0047 ```php
0048 use GuzzleHttp\Psr7;
0049
0050 // When more than 1024 bytes are in the buffer, it will begin returning
0051 // false to writes. This is an indication that writers should slow down.
0052 $buffer = new Psr7\BufferStream(1024);
0053 ```
0054
0055
0056 ## CachingStream
0057
0058 The CachingStream is used to allow seeking over previously read bytes on
0059 non-seekable streams. This can be useful when transferring a non-seekable
0060 entity body fails due to needing to rewind the stream (for example, resulting
0061 from a redirect). Data that is read from the remote stream will be buffered in
0062 a PHP temp stream so that previously read bytes are cached first in memory,
0063 then on disk.
0064
0065 ```php
0066 use GuzzleHttp\Psr7;
0067
0068 $original = Psr7\stream_for(fopen('http://www.google.com', 'r'));
0069 $stream = new Psr7\CachingStream($original);
0070
0071 $stream->read(1024);
0072 echo $stream->tell();
0073 // 1024
0074
0075 $stream->seek(0);
0076 echo $stream->tell();
0077 // 0
0078 ```
0079
0080
0081 ## DroppingStream
0082
0083 `GuzzleHttp\Psr7\DroppingStream`
0084
0085 Stream decorator that begins dropping data once the size of the underlying
0086 stream becomes too full.
0087
0088 ```php
0089 use GuzzleHttp\Psr7;
0090
0091 // Create an empty stream
0092 $stream = Psr7\stream_for();
0093
0094 // Start dropping data when the stream has more than 10 bytes
0095 $dropping = new Psr7\DroppingStream($stream, 10);
0096
0097 $dropping->write('01234567890123456789');
0098 echo $stream; // 0123456789
0099 ```
0100
0101
0102 ## FnStream
0103
0104 `GuzzleHttp\Psr7\FnStream`
0105
0106 Compose stream implementations based on a hash of functions.
0107
0108 Allows for easy testing and extension of a provided stream without needing
0109 to create a concrete class for a simple extension point.
0110
0111 ```php
0112
0113 use GuzzleHttp\Psr7;
0114
0115 $stream = Psr7\stream_for('hi');
0116 $fnStream = Psr7\FnStream::decorate($stream, [
0117 'rewind' => function () use ($stream) {
0118 echo 'About to rewind - ';
0119 $stream->rewind();
0120 echo 'rewound!';
0121 }
0122 ]);
0123
0124 $fnStream->rewind();
0125 // Outputs: About to rewind - rewound!
0126 ```
0127
0128
0129 ## InflateStream
0130
0131 `GuzzleHttp\Psr7\InflateStream`
0132
0133 Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
0134
0135 This stream decorator skips the first 10 bytes of the given stream to remove
0136 the gzip header, converts the provided stream to a PHP stream resource,
0137 then appends the zlib.inflate filter. The stream is then converted back
0138 to a Guzzle stream resource to be used as a Guzzle stream.
0139
0140
0141 ## LazyOpenStream
0142
0143 `GuzzleHttp\Psr7\LazyOpenStream`
0144
0145 Lazily reads or writes to a file that is opened only after an IO operation
0146 take place on the stream.
0147
0148 ```php
0149 use GuzzleHttp\Psr7;
0150
0151 $stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
0152 // The file has not yet been opened...
0153
0154 echo $stream->read(10);
0155 // The file is opened and read from only when needed.
0156 ```
0157
0158
0159 ## LimitStream
0160
0161 `GuzzleHttp\Psr7\LimitStream`
0162
0163 LimitStream can be used to read a subset or slice of an existing stream object.
0164 This can be useful for breaking a large file into smaller pieces to be sent in
0165 chunks (e.g. Amazon S3's multipart upload API).
0166
0167 ```php
0168 use GuzzleHttp\Psr7;
0169
0170 $original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+'));
0171 echo $original->getSize();
0172 // >>> 1048576
0173
0174 // Limit the size of the body to 1024 bytes and start reading from byte 2048
0175 $stream = new Psr7\LimitStream($original, 1024, 2048);
0176 echo $stream->getSize();
0177 // >>> 1024
0178 echo $stream->tell();
0179 // >>> 0
0180 ```
0181
0182
0183 ## MultipartStream
0184
0185 `GuzzleHttp\Psr7\MultipartStream`
0186
0187 Stream that when read returns bytes for a streaming multipart or
0188 multipart/form-data stream.
0189
0190
0191 ## NoSeekStream
0192
0193 `GuzzleHttp\Psr7\NoSeekStream`
0194
0195 NoSeekStream wraps a stream and does not allow seeking.
0196
0197 ```php
0198 use GuzzleHttp\Psr7;
0199
0200 $original = Psr7\stream_for('foo');
0201 $noSeek = new Psr7\NoSeekStream($original);
0202
0203 echo $noSeek->read(3);
0204 // foo
0205 var_export($noSeek->isSeekable());
0206 // false
0207 $noSeek->seek(0);
0208 var_export($noSeek->read(3));
0209 // NULL
0210 ```
0211
0212
0213 ## PumpStream
0214
0215 `GuzzleHttp\Psr7\PumpStream`
0216
0217 Provides a read only stream that pumps data from a PHP callable.
0218
0219 When invoking the provided callable, the PumpStream will pass the amount of
0220 data requested to read to the callable. The callable can choose to ignore
0221 this value and return fewer or more bytes than requested. Any extra data
0222 returned by the provided callable is buffered internally until drained using
0223 the read() function of the PumpStream. The provided callable MUST return
0224 false when there is no more data to read.
0225
0226
0227 ## Implementing stream decorators
0228
0229 Creating a stream decorator is very easy thanks to the
0230 `GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
0231 implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
0232 stream. Just `use` the `StreamDecoratorTrait` and implement your custom
0233 methods.
0234
0235 For example, let's say we wanted to call a specific function each time the last
0236 byte is read from a stream. This could be implemented by overriding the
0237 `read()` method.
0238
0239 ```php
0240 use Psr\Http\Message\StreamInterface;
0241 use GuzzleHttp\Psr7\StreamDecoratorTrait;
0242
0243 class EofCallbackStream implements StreamInterface
0244 {
0245 use StreamDecoratorTrait;
0246
0247 private $callback;
0248
0249 public function __construct(StreamInterface $stream, callable $cb)
0250 {
0251 $this->stream = $stream;
0252 $this->callback = $cb;
0253 }
0254
0255 public function read($length)
0256 {
0257 $result = $this->stream->read($length);
0258
0259 // Invoke the callback when EOF is hit.
0260 if ($this->eof()) {
0261 call_user_func($this->callback);
0262 }
0263
0264 return $result;
0265 }
0266 }
0267 ```
0268
0269 This decorator could be added to any existing stream and used like so:
0270
0271 ```php
0272 use GuzzleHttp\Psr7;
0273
0274 $original = Psr7\stream_for('foo');
0275
0276 $eofStream = new EofCallbackStream($original, function () {
0277 echo 'EOF!';
0278 });
0279
0280 $eofStream->read(2);
0281 $eofStream->read(1);
0282 // echoes "EOF!"
0283 $eofStream->seek(0);
0284 $eofStream->read(3);
0285 // echoes "EOF!"
0286 ```
0287
0288
0289 ## PHP StreamWrapper
0290
0291 You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
0292 PSR-7 stream as a PHP stream resource.
0293
0294 Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
0295 stream from a PSR-7 stream.
0296
0297 ```php
0298 use GuzzleHttp\Psr7\StreamWrapper;
0299
0300 $stream = GuzzleHttp\Psr7\stream_for('hello!');
0301 $resource = StreamWrapper::getResource($stream);
0302 echo fread($resource, 6); // outputs hello!
0303 ```
0304
0305
0306 # Function API
0307
0308 There are various functions available under the `GuzzleHttp\Psr7` namespace.
0309
0310
0311 ## `function str`
0312
0313 `function str(MessageInterface $message)`
0314
0315 Returns the string representation of an HTTP message.
0316
0317 ```php
0318 $request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
0319 echo GuzzleHttp\Psr7\str($request);
0320 ```
0321
0322
0323 ## `function uri_for`
0324
0325 `function uri_for($uri)`
0326
0327 This function accepts a string or `Psr\Http\Message\UriInterface` and returns a
0328 UriInterface for the given value. If the value is already a `UriInterface`, it
0329 is returned as-is.
0330
0331 ```php
0332 $uri = GuzzleHttp\Psr7\uri_for('http://example.com');
0333 assert($uri === GuzzleHttp\Psr7\uri_for($uri));
0334 ```
0335
0336
0337 ## `function stream_for`
0338
0339 `function stream_for($resource = '', array $options = [])`
0340
0341 Create a new stream based on the input type.
0342
0343 Options is an associative array that can contain the following keys:
0344
0345 * - metadata: Array of custom metadata.
0346 * - size: Size of the stream.
0347
0348 This method accepts the following `$resource` types:
0349
0350 - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
0351 - `string`: Creates a stream object that uses the given string as the contents.
0352 - `resource`: Creates a stream object that wraps the given PHP stream resource.
0353 - `Iterator`: If the provided value implements `Iterator`, then a read-only
0354 stream object will be created that wraps the given iterable. Each time the
0355 stream is read from, data from the iterator will fill a buffer and will be
0356 continuously called until the buffer is equal to the requested read size.
0357 Subsequent read calls will first read from the buffer and then call `next`
0358 on the underlying iterator until it is exhausted.
0359 - `object` with `__toString()`: If the object has the `__toString()` method,
0360 the object will be cast to a string and then a stream will be returned that
0361 uses the string value.
0362 - `NULL`: When `null` is passed, an empty stream object is returned.
0363 - `callable` When a callable is passed, a read-only stream object will be
0364 created that invokes the given callable. The callable is invoked with the
0365 number of suggested bytes to read. The callable can return any number of
0366 bytes, but MUST return `false` when there is no more data to return. The
0367 stream object that wraps the callable will invoke the callable until the
0368 number of requested bytes are available. Any additional bytes will be
0369 buffered and used in subsequent reads.
0370
0371 ```php
0372 $stream = GuzzleHttp\Psr7\stream_for('foo');
0373 $stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r'));
0374
0375 $generator function ($bytes) {
0376 for ($i = 0; $i < $bytes; $i++) {
0377 yield ' ';
0378 }
0379 }
0380
0381 $stream = GuzzleHttp\Psr7\stream_for($generator(100));
0382 ```
0383
0384
0385 ## `function parse_header`
0386
0387 `function parse_header($header)`
0388
0389 Parse an array of header values containing ";" separated data into an array of
0390 associative arrays representing the header key value pair data of the header.
0391 When a parameter does not contain a value, but just contains a key, this
0392 function will inject a key with a '' string value.
0393
0394
0395 ## `function normalize_header`
0396
0397 `function normalize_header($header)`
0398
0399 Converts an array of header values that may contain comma separated headers
0400 into an array of headers with no comma separated values.
0401
0402
0403 ## `function modify_request`
0404
0405 `function modify_request(RequestInterface $request, array $changes)`
0406
0407 Clone and modify a request with the given changes. This method is useful for
0408 reducing the number of clones needed to mutate a message.
0409
0410 The changes can be one of:
0411
0412 - method: (string) Changes the HTTP method.
0413 - set_headers: (array) Sets the given headers.
0414 - remove_headers: (array) Remove the given headers.
0415 - body: (mixed) Sets the given body.
0416 - uri: (UriInterface) Set the URI.
0417 - query: (string) Set the query string value of the URI.
0418 - version: (string) Set the protocol version.
0419
0420
0421 ## `function rewind_body`
0422
0423 `function rewind_body(MessageInterface $message)`
0424
0425 Attempts to rewind a message body and throws an exception on failure. The body
0426 of the message will only be rewound if a call to `tell()` returns a value other
0427 than `0`.
0428
0429
0430 ## `function try_fopen`
0431
0432 `function try_fopen($filename, $mode)`
0433
0434 Safely opens a PHP stream resource using a filename.
0435
0436 When fopen fails, PHP normally raises a warning. This function adds an error
0437 handler that checks for errors and throws an exception instead.
0438
0439
0440 ## `function copy_to_string`
0441
0442 `function copy_to_string(StreamInterface $stream, $maxLen = -1)`
0443
0444 Copy the contents of a stream into a string until the given number of bytes
0445 have been read.
0446
0447
0448 ## `function copy_to_stream`
0449
0450 `function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)`
0451
0452 Copy the contents of a stream into another stream until the given number of
0453 bytes have been read.
0454
0455
0456 ## `function hash`
0457
0458 `function hash(StreamInterface $stream, $algo, $rawOutput = false)`
0459
0460 Calculate a hash of a Stream. This method reads the entire stream to calculate
0461 a rolling hash (based on PHP's hash_init functions).
0462
0463
0464 ## `function readline`
0465
0466 `function readline(StreamInterface $stream, $maxLength = null)`
0467
0468 Read a line from the stream up to the maximum allowed buffer length.
0469
0470
0471 ## `function parse_request`
0472
0473 `function parse_request($message)`
0474
0475 Parses a request message string into a request object.
0476
0477
0478 ## `function parse_response`
0479
0480 `function parse_response($message)`
0481
0482 Parses a response message string into a response object.
0483
0484
0485 ## `function parse_query`
0486
0487 `function parse_query($str, $urlEncoding = true)`
0488
0489 Parse a query string into an associative array.
0490
0491 If multiple values are found for the same key, the value of that key value pair
0492 will become an array. This function does not parse nested PHP style arrays into
0493 an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into
0494 `['foo[a]' => '1', 'foo[b]' => '2']`).
0495
0496
0497 ## `function build_query`
0498
0499 `function build_query(array $params, $encoding = PHP_QUERY_RFC3986)`
0500
0501 Build a query string from an array of key value pairs.
0502
0503 This function can use the return value of parse_query() to build a query string.
0504 This function does not modify the provided keys when an array is encountered
0505 (like http_build_query would).
0506
0507
0508 ## `function mimetype_from_filename`
0509
0510 `function mimetype_from_filename($filename)`
0511
0512 Determines the mimetype of a file by looking at its extension.
0513
0514
0515 ## `function mimetype_from_extension`
0516
0517 `function mimetype_from_extension($extension)`
0518
0519 Maps a file extensions to a mimetype.
0520
0521
0522 # Additional URI Methods
0523
0524 Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
0525 this library also provides additional functionality when working with URIs as static methods.
0526
0527 ## URI Types
0528
0529 An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
0530 An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
0531 the base URI. Relative references can be divided into several forms according to
0532 [RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
0533
0534 - network-path references, e.g. `//example.com/path`
0535 - absolute-path references, e.g. `/path`
0536 - relative-path references, e.g. `subpath`
0537
0538 The following methods can be used to identify the type of the URI.
0539
0540 ### `GuzzleHttp\Psr7\Uri::isAbsolute`
0541
0542 `public static function isAbsolute(UriInterface $uri): bool`
0543
0544 Whether the URI is absolute, i.e. it has a scheme.
0545
0546 ### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
0547
0548 `public static function isNetworkPathReference(UriInterface $uri): bool`
0549
0550 Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
0551 termed an network-path reference.
0552
0553 ### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
0554
0555 `public static function isAbsolutePathReference(UriInterface $uri): bool`
0556
0557 Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
0558 termed an absolute-path reference.
0559
0560 ### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
0561
0562 `public static function isRelativePathReference(UriInterface $uri): bool`
0563
0564 Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
0565 termed a relative-path reference.
0566
0567 ### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
0568
0569 `public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
0570
0571 Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
0572 fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
0573 (apart from its fragment) is considered a same-document reference.
0574
0575 ## URI Components
0576
0577 Additional methods to work with URI components.
0578
0579 ### `GuzzleHttp\Psr7\Uri::isDefaultPort`
0580
0581 `public static function isDefaultPort(UriInterface $uri): bool`
0582
0583 Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
0584 or the standard port. This method can be used independently of the implementation.
0585
0586 ### `GuzzleHttp\Psr7\Uri::composeComponents`
0587
0588 `public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
0589
0590 Composes a URI reference string from its various components according to
0591 [RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
0592 manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
0593
0594 ### `GuzzleHttp\Psr7\Uri::fromParts`
0595
0596 `public static function fromParts(array $parts): UriInterface`
0597
0598 Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components.
0599
0600
0601 ### `GuzzleHttp\Psr7\Uri::withQueryValue`
0602
0603 `public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
0604
0605 Creates a new URI with a specific query string value. Any existing query string values that exactly match the
0606 provided key are removed and replaced with the given key value pair. A value of null will set the query string
0607 key without a value, e.g. "key" instead of "key=value".
0608
0609
0610 ### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
0611
0612 `public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
0613
0614 Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
0615 provided key are removed.
0616
0617 ## Reference Resolution
0618
0619 `GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
0620 to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
0621 do when resolving a link in a website based on the current request URI.
0622
0623 ### `GuzzleHttp\Psr7\UriResolver::resolve`
0624
0625 `public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
0626
0627 Converts the relative URI into a new URI that is resolved against the base URI.
0628
0629 ### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
0630
0631 `public static function removeDotSegments(string $path): string`
0632
0633 Removes dot segments from a path and returns the new path according to
0634 [RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
0635
0636 ### `GuzzleHttp\Psr7\UriResolver::relativize`
0637
0638 `public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
0639
0640 Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
0641
0642 ```php
0643 (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
0644 ```
0645
0646 One use-case is to use the current request URI as base URI and then generate relative links in your documents
0647 to reduce the document size or offer self-contained downloadable document archives.
0648
0649 ```php
0650 $base = new Uri('http://example.com/a/b/');
0651 echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.
0652 echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.
0653 echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
0654 echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
0655 ```
0656
0657 ## Normalization and Comparison
0658
0659 `GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
0660 [RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
0661
0662 ### `GuzzleHttp\Psr7\UriNormalizer::normalize`
0663
0664 `public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
0665
0666 Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
0667 This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
0668 of normalizations to apply. The following normalizations are available:
0669
0670 - `UriNormalizer::PRESERVING_NORMALIZATIONS`
0671
0672 Default normalizations which only include the ones that preserve semantics.
0673
0674 - `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
0675
0676 All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
0677
0678 Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
0679
0680 - `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
0681
0682 Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
0683 ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
0684 not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
0685 characters by URI normalizers.
0686
0687 Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
0688
0689 - `UriNormalizer::CONVERT_EMPTY_PATH`
0690
0691 Converts the empty path to "/" for http and https URIs.
0692
0693 Example: `http://example.org` → `http://example.org/`
0694
0695 - `UriNormalizer::REMOVE_DEFAULT_HOST`
0696
0697 Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
0698 "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
0699 RFC 3986.
0700
0701 Example: `file://localhost/myfile` → `file:///myfile`
0702
0703 - `UriNormalizer::REMOVE_DEFAULT_PORT`
0704
0705 Removes the default port of the given URI scheme from the URI.
0706
0707 Example: `http://example.org:80/` → `http://example.org/`
0708
0709 - `UriNormalizer::REMOVE_DOT_SEGMENTS`
0710
0711 Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
0712 change the semantics of the URI reference.
0713
0714 Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
0715
0716 - `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
0717
0718 Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
0719 and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
0720 may change the semantics. Encoded slashes (%2F) are not removed.
0721
0722 Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
0723
0724 - `UriNormalizer::SORT_QUERY_PARAMETERS`
0725
0726 Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
0727 significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
0728 of the URI.
0729
0730 Example: `?lang=en&article=fred` → `?article=fred&lang=en`
0731
0732 ### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
0733
0734 `public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
0735
0736 Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
0737 `$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
0738 This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
0739 equivalence or difference of relative references does not mean anything.