Browse code

added appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:35:09
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,887 @@
1
+# PSR-7 Message Implementation
2
+
3
+This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
4
+message implementation, several stream decorators, and some helpful
5
+functionality like query string parsing.
6
+
7
+![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg)
8
+![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg)
9
+
10
+
11
+## Features
12
+
13
+This package comes with a number of stream implementations and stream
14
+decorators.
15
+
16
+
17
+## Installation
18
+
19
+```shell
20
+composer require guzzlehttp/psr7
21
+```
22
+
23
+## Version Guidance
24
+
25
+| Version | Status              | PHP Version  |
26
+|---------|---------------------|--------------|
27
+| 1.x     | EOL (2024-06-30)    | >=5.4,<8.2   |
28
+| 2.x     | Latest              | >=7.2.5,<8.6 |
29
+
30
+
31
+## AppendStream
32
+
33
+`GuzzleHttp\Psr7\AppendStream`
34
+
35
+Reads from multiple streams, one after the other.
36
+
37
+```php
38
+use GuzzleHttp\Psr7;
39
+
40
+$a = Psr7\Utils::streamFor('abc, ');
41
+$b = Psr7\Utils::streamFor('123.');
42
+$composed = new Psr7\AppendStream([$a, $b]);
43
+
44
+$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
45
+
46
+echo $composed; // abc, 123. Above all listen to me.
47
+```
48
+
49
+
50
+## BufferStream
51
+
52
+`GuzzleHttp\Psr7\BufferStream`
53
+
54
+Provides a buffer stream that can be written to fill a buffer, and read
55
+from to remove bytes from the buffer.
56
+
57
+This stream returns a "hwm" metadata value that tells upstream consumers
58
+what the configured high water mark of the stream is, or the maximum
59
+preferred size of the buffer.
60
+
61
+```php
62
+use GuzzleHttp\Psr7;
63
+
64
+// When more than 1024 bytes are in the buffer, it will begin returning
65
+// false to writes. This is an indication that writers should slow down.
66
+$buffer = new Psr7\BufferStream(1024);
67
+```
68
+
69
+
70
+## CachingStream
71
+
72
+The CachingStream is used to allow seeking over previously read bytes on
73
+non-seekable streams. This can be useful when transferring a non-seekable
74
+entity body fails due to needing to rewind the stream (for example, resulting
75
+from a redirect). Data that is read from the remote stream will be buffered in
76
+a PHP temp stream so that previously read bytes are cached first in memory,
77
+then on disk.
78
+
79
+```php
80
+use GuzzleHttp\Psr7;
81
+
82
+$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
83
+$stream = new Psr7\CachingStream($original);
84
+
85
+$stream->read(1024);
86
+echo $stream->tell();
87
+// 1024
88
+
89
+$stream->seek(0);
90
+echo $stream->tell();
91
+// 0
92
+```
93
+
94
+
95
+## DroppingStream
96
+
97
+`GuzzleHttp\Psr7\DroppingStream`
98
+
99
+Stream decorator that begins dropping data once the size of the underlying
100
+stream becomes too full.
101
+
102
+```php
103
+use GuzzleHttp\Psr7;
104
+
105
+// Create an empty stream
106
+$stream = Psr7\Utils::streamFor();
107
+
108
+// Start dropping data when the stream has more than 10 bytes
109
+$dropping = new Psr7\DroppingStream($stream, 10);
110
+
111
+$dropping->write('01234567890123456789');
112
+echo $stream; // 0123456789
113
+```
114
+
115
+
116
+## FnStream
117
+
118
+`GuzzleHttp\Psr7\FnStream`
119
+
120
+Compose stream implementations based on a hash of functions.
121
+
122
+Allows for easy testing and extension of a provided stream without needing
123
+to create a concrete class for a simple extension point.
124
+
125
+```php
126
+
127
+use GuzzleHttp\Psr7;
128
+
129
+$stream = Psr7\Utils::streamFor('hi');
130
+$fnStream = Psr7\FnStream::decorate($stream, [
131
+    'rewind' => function () use ($stream) {
132
+        echo 'About to rewind - ';
133
+        $stream->rewind();
134
+        echo 'rewound!';
135
+    }
136
+]);
137
+
138
+$fnStream->rewind();
139
+// Outputs: About to rewind - rewound!
140
+```
141
+
142
+
143
+## InflateStream
144
+
145
+`GuzzleHttp\Psr7\InflateStream`
146
+
147
+Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
148
+
149
+This stream decorator converts the provided stream to a PHP stream resource,
150
+then appends the zlib.inflate filter. The stream is then converted back
151
+to a Guzzle stream resource to be used as a Guzzle stream.
152
+
153
+
154
+## LazyOpenStream
155
+
156
+`GuzzleHttp\Psr7\LazyOpenStream`
157
+
158
+Lazily reads or writes to a file that is opened only after an IO operation
159
+take place on the stream.
160
+
161
+```php
162
+use GuzzleHttp\Psr7;
163
+
164
+$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
165
+// The file has not yet been opened...
166
+
167
+echo $stream->read(10);
168
+// The file is opened and read from only when needed.
169
+```
170
+
171
+
172
+## LimitStream
173
+
174
+`GuzzleHttp\Psr7\LimitStream`
175
+
176
+LimitStream can be used to read a subset or slice of an existing stream object.
177
+This can be useful for breaking a large file into smaller pieces to be sent in
178
+chunks (e.g. Amazon S3's multipart upload API).
179
+
180
+```php
181
+use GuzzleHttp\Psr7;
182
+
183
+$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
184
+echo $original->getSize();
185
+// >>> 1048576
186
+
187
+// Limit the size of the body to 1024 bytes and start reading from byte 2048
188
+$stream = new Psr7\LimitStream($original, 1024, 2048);
189
+echo $stream->getSize();
190
+// >>> 1024
191
+echo $stream->tell();
192
+// >>> 0
193
+```
194
+
195
+
196
+## MultipartStream
197
+
198
+`GuzzleHttp\Psr7\MultipartStream`
199
+
200
+Stream that when read returns bytes for a streaming multipart or
201
+multipart/form-data stream.
202
+
203
+
204
+## NoSeekStream
205
+
206
+`GuzzleHttp\Psr7\NoSeekStream`
207
+
208
+NoSeekStream wraps a stream and does not allow seeking.
209
+
210
+```php
211
+use GuzzleHttp\Psr7;
212
+
213
+$original = Psr7\Utils::streamFor('foo');
214
+$noSeek = new Psr7\NoSeekStream($original);
215
+
216
+echo $noSeek->read(3);
217
+// foo
218
+var_export($noSeek->isSeekable());
219
+// false
220
+$noSeek->seek(0);
221
+var_export($noSeek->read(3));
222
+// NULL
223
+```
224
+
225
+
226
+## PumpStream
227
+
228
+`GuzzleHttp\Psr7\PumpStream`
229
+
230
+Provides a read only stream that pumps data from a PHP callable.
231
+
232
+When invoking the provided callable, the PumpStream will pass the amount of
233
+data requested to read to the callable. The callable can choose to ignore
234
+this value and return fewer or more bytes than requested. Any extra data
235
+returned by the provided callable is buffered internally until drained using
236
+the read() function of the PumpStream. The provided callable MUST return
237
+false when there is no more data to read.
238
+
239
+
240
+## Implementing stream decorators
241
+
242
+Creating a stream decorator is very easy thanks to the
243
+`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
244
+implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
245
+stream. Just `use` the `StreamDecoratorTrait` and implement your custom
246
+methods.
247
+
248
+For example, let's say we wanted to call a specific function each time the last
249
+byte is read from a stream. This could be implemented by overriding the
250
+`read()` method.
251
+
252
+```php
253
+use Psr\Http\Message\StreamInterface;
254
+use GuzzleHttp\Psr7\StreamDecoratorTrait;
255
+
256
+class EofCallbackStream implements StreamInterface
257
+{
258
+    use StreamDecoratorTrait;
259
+
260
+    private $callback;
261
+
262
+    private $stream;
263
+
264
+    public function __construct(StreamInterface $stream, callable $cb)
265
+    {
266
+        $this->stream = $stream;
267
+        $this->callback = $cb;
268
+    }
269
+
270
+    public function read($length)
271
+    {
272
+        $result = $this->stream->read($length);
273
+
274
+        // Invoke the callback when EOF is hit.
275
+        if ($this->eof()) {
276
+            ($this->callback)();
277
+        }
278
+
279
+        return $result;
280
+    }
281
+}
282
+```
283
+
284
+This decorator could be added to any existing stream and used like so:
285
+
286
+```php
287
+use GuzzleHttp\Psr7;
288
+
289
+$original = Psr7\Utils::streamFor('foo');
290
+
291
+$eofStream = new EofCallbackStream($original, function () {
292
+    echo 'EOF!';
293
+});
294
+
295
+$eofStream->read(2);
296
+$eofStream->read(1);
297
+// echoes "EOF!"
298
+$eofStream->seek(0);
299
+$eofStream->read(3);
300
+// echoes "EOF!"
301
+```
302
+
303
+
304
+## PHP StreamWrapper
305
+
306
+You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
307
+PSR-7 stream as a PHP stream resource.
308
+
309
+Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
310
+stream from a PSR-7 stream.
311
+
312
+```php
313
+use GuzzleHttp\Psr7\StreamWrapper;
314
+
315
+$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
316
+$resource = StreamWrapper::getResource($stream);
317
+echo fread($resource, 6); // outputs hello!
318
+```
319
+
320
+
321
+# Static API
322
+
323
+There are various static methods available under the `GuzzleHttp\Psr7` namespace.
324
+
325
+
326
+## `GuzzleHttp\Psr7\Message::toString`
327
+
328
+`public static function toString(MessageInterface $message): string`
329
+
330
+Returns the string representation of an HTTP message.
331
+
332
+```php
333
+$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
334
+echo GuzzleHttp\Psr7\Message::toString($request);
335
+```
336
+
337
+
338
+## `GuzzleHttp\Psr7\Message::bodySummary`
339
+
340
+`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
341
+
342
+Get a short summary of the message body.
343
+
344
+Will return `null` if the response is not printable.
345
+
346
+
347
+## `GuzzleHttp\Psr7\Message::rewindBody`
348
+
349
+`public static function rewindBody(MessageInterface $message): void`
350
+
351
+Attempts to rewind a message body and throws an exception on failure.
352
+
353
+The body of the message will only be rewound if a call to `tell()`
354
+returns a value other than `0`.
355
+
356
+
357
+## `GuzzleHttp\Psr7\Message::parseMessage`
358
+
359
+`public static function parseMessage(string $message): array`
360
+
361
+Parses an HTTP message into an associative array.
362
+
363
+The array contains the "start-line" key containing the start line of
364
+the message, "headers" key containing an associative array of header
365
+array values, and a "body" key containing the body of the message.
366
+
367
+
368
+## `GuzzleHttp\Psr7\Message::parseRequestUri`
369
+
370
+`public static function parseRequestUri(string $path, array $headers): string`
371
+
372
+Constructs a URI for an HTTP request message.
373
+
374
+
375
+## `GuzzleHttp\Psr7\Message::parseRequest`
376
+
377
+`public static function parseRequest(string $message): Request`
378
+
379
+Parses a request message string into a request object.
380
+
381
+
382
+## `GuzzleHttp\Psr7\Message::parseResponse`
383
+
384
+`public static function parseResponse(string $message): Response`
385
+
386
+Parses a response message string into a response object.
387
+
388
+
389
+## `GuzzleHttp\Psr7\Header::parse`
390
+
391
+`public static function parse(string|array $header): array`
392
+
393
+Parse an array of header values containing ";" separated data into an
394
+array of associative arrays representing the header key value pair data
395
+of the header. When a parameter does not contain a value, but just
396
+contains a key, this function will inject a key with a '' string value.
397
+
398
+
399
+## `GuzzleHttp\Psr7\Header::splitList`
400
+
401
+`public static function splitList(string|string[] $header): string[]`
402
+
403
+Splits a HTTP header defined to contain a comma-separated list into
404
+each individual value:
405
+
406
+```
407
+$knownEtags = Header::splitList($request->getHeader('if-none-match'));
408
+```
409
+
410
+Example headers include `accept`, `cache-control` and `if-none-match`.
411
+
412
+
413
+## `GuzzleHttp\Psr7\Header::normalize` (deprecated)
414
+
415
+`public static function normalize(string|array $header): array`
416
+
417
+`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist)
418
+which performs the same operation with a cleaned up API and improved
419
+documentation.
420
+
421
+Converts an array of header values that may contain comma separated
422
+headers into an array of headers with no comma separated values.
423
+
424
+
425
+## `GuzzleHttp\Psr7\Query::parse`
426
+
427
+`public static function parse(string $str, int|bool $urlEncoding = true): array`
428
+
429
+Parse a query string into an associative array.
430
+
431
+If multiple values are found for the same key, the value of that key
432
+value pair will become an array. This function does not parse nested
433
+PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
434
+will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
435
+
436
+
437
+## `GuzzleHttp\Psr7\Query::build`
438
+
439
+`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986, bool $treatBoolsAsInts = true): string`
440
+
441
+Build a query string from an array of key value pairs.
442
+
443
+This function can use the return value of `parse()` to build a query
444
+string. This function does not modify the provided keys when an array is
445
+encountered (like `http_build_query()` would).
446
+
447
+
448
+## `GuzzleHttp\Psr7\Utils::caselessRemove`
449
+
450
+`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
451
+
452
+Remove the items given by the keys, case insensitively from the data.
453
+
454
+
455
+## `GuzzleHttp\Psr7\Utils::copyToStream`
456
+
457
+`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
458
+
459
+Copy the contents of a stream into another stream until the given number
460
+of bytes have been read.
461
+
462
+
463
+## `GuzzleHttp\Psr7\Utils::copyToString`
464
+
465
+`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
466
+
467
+Copy the contents of a stream into a string until the given number of
468
+bytes have been read.
469
+
470
+
471
+## `GuzzleHttp\Psr7\Utils::hash`
472
+
473
+`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
474
+
475
+Calculate a hash of a stream.
476
+
477
+This method reads the entire stream to calculate a rolling hash, based on
478
+PHP's `hash_init` functions.
479
+
480
+
481
+## `GuzzleHttp\Psr7\Utils::modifyRequest`
482
+
483
+`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
484
+
485
+Clone and modify a request with the given changes.
486
+
487
+This method is useful for reducing the number of clones needed to mutate
488
+a message.
489
+
490
+- method: (string) Changes the HTTP method.
491
+- set_headers: (array) Sets the given headers.
492
+- remove_headers: (array) Remove the given headers.
493
+- body: (mixed) Sets the given body.
494
+- uri: (UriInterface) Set the URI.
495
+- query: (string) Set the query string value of the URI.
496
+- version: (string) Set the protocol version.
497
+
498
+
499
+## `GuzzleHttp\Psr7\Utils::readLine`
500
+
501
+`public static function readLine(StreamInterface $stream, ?int $maxLength = null): string`
502
+
503
+Read a line from the stream up to the maximum allowed buffer length.
504
+
505
+
506
+## `GuzzleHttp\Psr7\Utils::redactUserInfo`
507
+
508
+`public static function redactUserInfo(UriInterface $uri): UriInterface`
509
+
510
+Redact the password in the user info part of a URI.
511
+
512
+
513
+## `GuzzleHttp\Psr7\Utils::streamFor`
514
+
515
+`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
516
+
517
+Create a new stream based on the input type.
518
+
519
+Options is an associative array that can contain the following keys:
520
+
521
+- metadata: Array of custom metadata.
522
+- size: Size of the stream.
523
+
524
+This method accepts the following `$resource` types:
525
+
526
+- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
527
+- `string`: Creates a stream object that uses the given string as the contents.
528
+- `resource`: Creates a stream object that wraps the given PHP stream resource.
529
+- `Iterator`: If the provided value implements `Iterator`, then a read-only
530
+  stream object will be created that wraps the given iterable. Each time the
531
+  stream is read from, data from the iterator will fill a buffer and will be
532
+  continuously called until the buffer is equal to the requested read size.
533
+  Subsequent read calls will first read from the buffer and then call `next`
534
+  on the underlying iterator until it is exhausted.
535
+- `object` with `__toString()`: If the object has the `__toString()` method,
536
+  the object will be cast to a string and then a stream will be returned that
537
+  uses the string value.
538
+- `NULL`: When `null` is passed, an empty stream object is returned.
539
+- `callable` When a callable is passed, a read-only stream object will be
540
+  created that invokes the given callable. The callable is invoked with the
541
+  number of suggested bytes to read. The callable can return any number of
542
+  bytes, but MUST return `false` when there is no more data to return. The
543
+  stream object that wraps the callable will invoke the callable until the
544
+  number of requested bytes are available. Any additional bytes will be
545
+  buffered and used in subsequent reads.
546
+
547
+```php
548
+$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
549
+$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
550
+
551
+$generator = function ($bytes) {
552
+    for ($i = 0; $i < $bytes; $i++) {
553
+        yield ' ';
554
+    }
555
+}
556
+
557
+$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
558
+```
559
+
560
+
561
+## `GuzzleHttp\Psr7\Utils::tryFopen`
562
+
563
+`public static function tryFopen(string $filename, string $mode): resource`
564
+
565
+Safely opens a PHP stream resource using a filename.
566
+
567
+When fopen fails, PHP normally raises a warning. This function adds an
568
+error handler that checks for errors and throws an exception instead.
569
+
570
+
571
+## `GuzzleHttp\Psr7\Utils::tryGetContents`
572
+
573
+`public static function tryGetContents(resource $stream): string`
574
+
575
+Safely gets the contents of a given stream.
576
+
577
+When stream_get_contents fails, PHP normally raises a warning. This
578
+function adds an error handler that checks for errors and throws an
579
+exception instead.
580
+
581
+
582
+## `GuzzleHttp\Psr7\Utils::uriFor`
583
+
584
+`public static function uriFor(string|UriInterface $uri): UriInterface`
585
+
586
+Returns a UriInterface for the given value.
587
+
588
+This function accepts a string or UriInterface and returns a
589
+UriInterface for the given value. If the value is already a
590
+UriInterface, it is returned as-is.
591
+
592
+
593
+## `GuzzleHttp\Psr7\MimeType::fromFilename`
594
+
595
+`public static function fromFilename(string $filename): string|null`
596
+
597
+Determines the mimetype of a file by looking at its extension.
598
+
599
+
600
+## `GuzzleHttp\Psr7\MimeType::fromExtension`
601
+
602
+`public static function fromExtension(string $extension): string|null`
603
+
604
+Maps a file extensions to a mimetype.
605
+
606
+
607
+## Upgrading from Function API
608
+
609
+The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience:
610
+
611
+| Original Function | Replacement Method |
612
+|----------------|----------------|
613
+| `str` | `Message::toString` |
614
+| `uri_for` | `Utils::uriFor` |
615
+| `stream_for` | `Utils::streamFor` |
616
+| `parse_header` | `Header::parse` |
617
+| `normalize_header` | `Header::normalize` |
618
+| `modify_request` | `Utils::modifyRequest` |
619
+| `rewind_body` | `Message::rewindBody` |
620
+| `try_fopen` | `Utils::tryFopen` |
621
+| `copy_to_string` | `Utils::copyToString` |
622
+| `copy_to_stream` | `Utils::copyToStream` |
623
+| `hash` | `Utils::hash` |
624
+| `readline` | `Utils::readLine` |
625
+| `parse_request` | `Message::parseRequest` |
626
+| `parse_response` | `Message::parseResponse` |
627
+| `parse_query` | `Query::parse` |
628
+| `build_query` | `Query::build` |
629
+| `mimetype_from_filename` | `MimeType::fromFilename` |
630
+| `mimetype_from_extension` | `MimeType::fromExtension` |
631
+| `_parse_message` | `Message::parseMessage` |
632
+| `_parse_request_uri` | `Message::parseRequestUri` |
633
+| `get_message_body_summary` | `Message::bodySummary` |
634
+| `_caseless_remove` | `Utils::caselessRemove` |
635
+
636
+
637
+# Additional URI Methods
638
+
639
+Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
640
+this library also provides additional functionality when working with URIs as static methods.
641
+
642
+## URI Types
643
+
644
+An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
645
+An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
646
+the base URI. Relative references can be divided into several forms according to
647
+[RFC 3986 Section 4.2](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2):
648
+
649
+- network-path references, e.g. `//example.com/path`
650
+- absolute-path references, e.g. `/path`
651
+- relative-path references, e.g. `subpath`
652
+
653
+The following methods can be used to identify the type of the URI.
654
+
655
+### `GuzzleHttp\Psr7\Uri::isAbsolute`
656
+
657
+`public static function isAbsolute(UriInterface $uri): bool`
658
+
659
+Whether the URI is absolute, i.e. it has a scheme.
660
+
661
+### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
662
+
663
+`public static function isNetworkPathReference(UriInterface $uri): bool`
664
+
665
+Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
666
+termed an network-path reference.
667
+
668
+### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
669
+
670
+`public static function isAbsolutePathReference(UriInterface $uri): bool`
671
+
672
+Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
673
+termed an absolute-path reference.
674
+
675
+### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
676
+
677
+`public static function isRelativePathReference(UriInterface $uri): bool`
678
+
679
+Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
680
+termed a relative-path reference.
681
+
682
+### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
683
+
684
+`public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null): bool`
685
+
686
+Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
687
+fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
688
+(apart from its fragment) is considered a same-document reference.
689
+
690
+## URI Components
691
+
692
+Additional methods to work with URI components.
693
+
694
+### `GuzzleHttp\Psr7\Uri::isDefaultPort`
695
+
696
+`public static function isDefaultPort(UriInterface $uri): bool`
697
+
698
+Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
699
+or the standard port. This method can be used independently of the implementation.
700
+
701
+### `GuzzleHttp\Psr7\Uri::composeComponents`
702
+
703
+`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
704
+
705
+Composes a URI reference string from its various components according to
706
+[RFC 3986 Section 5.3](https://datatracker.ietf.org/doc/html/rfc3986#section-5.3). Usually this method does not need
707
+to be called manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
708
+
709
+### `GuzzleHttp\Psr7\Uri::fromParts`
710
+
711
+`public static function fromParts(array $parts): UriInterface`
712
+
713
+Creates a URI from a hash of [`parse_url`](https://www.php.net/manual/en/function.parse-url.php) components.
714
+
715
+
716
+### `GuzzleHttp\Psr7\Uri::withQueryValue`
717
+
718
+`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
719
+
720
+Creates a new URI with a specific query string value. Any existing query string values that exactly match the
721
+provided key are removed and replaced with the given key value pair. A value of null will set the query string
722
+key without a value, e.g. "key" instead of "key=value".
723
+
724
+### `GuzzleHttp\Psr7\Uri::withQueryValues`
725
+
726
+`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
727
+
728
+Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
729
+associative array of key => value.
730
+
731
+### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
732
+
733
+`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
734
+
735
+Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
736
+provided key are removed.
737
+
738
+## Cross-Origin Detection
739
+
740
+`GuzzleHttp\Psr7\UriComparator` provides methods to determine if a modified URL should be considered cross-origin.
741
+
742
+### `GuzzleHttp\Psr7\UriComparator::isCrossOrigin`
743
+
744
+`public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool`
745
+
746
+Determines if a modified URL should be considered cross-origin with respect to an original URL.
747
+
748
+## Reference Resolution
749
+
750
+`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
751
+to [RFC 3986 Section 5](https://datatracker.ietf.org/doc/html/rfc3986#section-5). This is for example also what web
752
+browsers do when resolving a link in a website based on the current request URI.
753
+
754
+### `GuzzleHttp\Psr7\UriResolver::resolve`
755
+
756
+`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
757
+
758
+Converts the relative URI into a new URI that is resolved against the base URI.
759
+
760
+### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
761
+
762
+`public static function removeDotSegments(string $path): string`
763
+
764
+Removes dot segments from a path and returns the new path according to
765
+[RFC 3986 Section 5.2.4](https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4).
766
+
767
+### `GuzzleHttp\Psr7\UriResolver::relativize`
768
+
769
+`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
770
+
771
+Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
772
+
773
+```php
774
+(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
775
+```
776
+
777
+One use-case is to use the current request URI as base URI and then generate relative links in your documents
778
+to reduce the document size or offer self-contained downloadable document archives.
779
+
780
+```php
781
+$base = new Uri('http://example.com/a/b/');
782
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
783
+echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
784
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
785
+echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
786
+```
787
+
788
+## Normalization and Comparison
789
+
790
+`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
791
+[RFC 3986 Section 6](https://datatracker.ietf.org/doc/html/rfc3986#section-6).
792
+
793
+### `GuzzleHttp\Psr7\UriNormalizer::normalize`
794
+
795
+`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
796
+
797
+Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
798
+This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
799
+of normalizations to apply. The following normalizations are available:
800
+
801
+- `UriNormalizer::PRESERVING_NORMALIZATIONS`
802
+
803
+    Default normalizations which only include the ones that preserve semantics.
804
+
805
+- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
806
+
807
+    All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
808
+
809
+    Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
810
+
811
+- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
812
+
813
+    Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
814
+    ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
815
+    not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
816
+    characters by URI normalizers.
817
+
818
+    Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
819
+
820
+- `UriNormalizer::CONVERT_EMPTY_PATH`
821
+
822
+    Converts the empty path to "/" for http and https URIs.
823
+
824
+    Example: `http://example.org` → `http://example.org/`
825
+
826
+- `UriNormalizer::REMOVE_DEFAULT_HOST`
827
+
828
+    Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
829
+    "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
830
+    RFC 3986.
831
+
832
+    Example: `file://localhost/myfile` → `file:///myfile`
833
+
834
+- `UriNormalizer::REMOVE_DEFAULT_PORT`
835
+
836
+    Removes the default port of the given URI scheme from the URI.
837
+
838
+    Example: `http://example.org:80/` → `http://example.org/`
839
+
840
+- `UriNormalizer::REMOVE_DOT_SEGMENTS`
841
+
842
+    Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
843
+    change the semantics of the URI reference.
844
+
845
+    Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
846
+
847
+- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
848
+
849
+    Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
850
+    and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
851
+    may change the semantics. Encoded slashes (%2F) are not removed.
852
+
853
+    Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
854
+
855
+- `UriNormalizer::SORT_QUERY_PARAMETERS`
856
+
857
+    Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
858
+    significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
859
+    of the URI.
860
+
861
+    Example: `?lang=en&article=fred` → `?article=fred&lang=en`
862
+
863
+### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
864
+
865
+`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
866
+
867
+Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
868
+`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
869
+This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
870
+equivalence or difference of relative references does not mean anything.
871
+
872
+
873
+## Security
874
+
875
+If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information.
876
+
877
+
878
+## License
879
+
880
+Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
881
+
882
+
883
+## For Enterprise
884
+
885
+Available as part of the Tidelift Subscription
886
+
887
+The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-psr7?utm_source=packagist-guzzlehttp-psr7&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
Browse code

removed appinfo/info.xml appinfo/signature.json CHANGELOG.txt lib/AppInfo/Application.php css/style.css providers/Plivo

DoubleBastionAdmin authored on 05/11/2025 13:12:22
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,809 +0,0 @@
1
-# PSR-7 Message Implementation
2
-
3
-This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
4
-message implementation, several stream decorators, and some helpful
5
-functionality like query string parsing.
6
-
7
-
8
-[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
9
-
10
-
11
-# Stream implementation
12
-
13
-This package comes with a number of stream implementations and stream
14
-decorators.
15
-
16
-
17
-## AppendStream
18
-
19
-`GuzzleHttp\Psr7\AppendStream`
20
-
21
-Reads from multiple streams, one after the other.
22
-
23
-```php
24
-use GuzzleHttp\Psr7;
25
-
26
-$a = Psr7\Utils::streamFor('abc, ');
27
-$b = Psr7\Utils::streamFor('123.');
28
-$composed = new Psr7\AppendStream([$a, $b]);
29
-
30
-$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
31
-
32
-echo $composed; // abc, 123. Above all listen to me.
33
-```
34
-
35
-
36
-## BufferStream
37
-
38
-`GuzzleHttp\Psr7\BufferStream`
39
-
40
-Provides a buffer stream that can be written to fill a buffer, and read
41
-from to remove bytes from the buffer.
42
-
43
-This stream returns a "hwm" metadata value that tells upstream consumers
44
-what the configured high water mark of the stream is, or the maximum
45
-preferred size of the buffer.
46
-
47
-```php
48
-use GuzzleHttp\Psr7;
49
-
50
-// When more than 1024 bytes are in the buffer, it will begin returning
51
-// false to writes. This is an indication that writers should slow down.
52
-$buffer = new Psr7\BufferStream(1024);
53
-```
54
-
55
-
56
-## CachingStream
57
-
58
-The CachingStream is used to allow seeking over previously read bytes on
59
-non-seekable streams. This can be useful when transferring a non-seekable
60
-entity body fails due to needing to rewind the stream (for example, resulting
61
-from a redirect). Data that is read from the remote stream will be buffered in
62
-a PHP temp stream so that previously read bytes are cached first in memory,
63
-then on disk.
64
-
65
-```php
66
-use GuzzleHttp\Psr7;
67
-
68
-$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
69
-$stream = new Psr7\CachingStream($original);
70
-
71
-$stream->read(1024);
72
-echo $stream->tell();
73
-// 1024
74
-
75
-$stream->seek(0);
76
-echo $stream->tell();
77
-// 0
78
-```
79
-
80
-
81
-## DroppingStream
82
-
83
-`GuzzleHttp\Psr7\DroppingStream`
84
-
85
-Stream decorator that begins dropping data once the size of the underlying
86
-stream becomes too full.
87
-
88
-```php
89
-use GuzzleHttp\Psr7;
90
-
91
-// Create an empty stream
92
-$stream = Psr7\Utils::streamFor();
93
-
94
-// Start dropping data when the stream has more than 10 bytes
95
-$dropping = new Psr7\DroppingStream($stream, 10);
96
-
97
-$dropping->write('01234567890123456789');
98
-echo $stream; // 0123456789
99
-```
100
-
101
-
102
-## FnStream
103
-
104
-`GuzzleHttp\Psr7\FnStream`
105
-
106
-Compose stream implementations based on a hash of functions.
107
-
108
-Allows for easy testing and extension of a provided stream without needing
109
-to create a concrete class for a simple extension point.
110
-
111
-```php
112
-
113
-use GuzzleHttp\Psr7;
114
-
115
-$stream = Psr7\Utils::streamFor('hi');
116
-$fnStream = Psr7\FnStream::decorate($stream, [
117
-    'rewind' => function () use ($stream) {
118
-        echo 'About to rewind - ';
119
-        $stream->rewind();
120
-        echo 'rewound!';
121
-    }
122
-]);
123
-
124
-$fnStream->rewind();
125
-// Outputs: About to rewind - rewound!
126
-```
127
-
128
-
129
-## InflateStream
130
-
131
-`GuzzleHttp\Psr7\InflateStream`
132
-
133
-Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
134
-
135
-This stream decorator skips the first 10 bytes of the given stream to remove
136
-the gzip header, converts the provided stream to a PHP stream resource,
137
-then appends the zlib.inflate filter. The stream is then converted back
138
-to a Guzzle stream resource to be used as a Guzzle stream.
139
-
140
-
141
-## LazyOpenStream
142
-
143
-`GuzzleHttp\Psr7\LazyOpenStream`
144
-
145
-Lazily reads or writes to a file that is opened only after an IO operation
146
-take place on the stream.
147
-
148
-```php
149
-use GuzzleHttp\Psr7;
150
-
151
-$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
152
-// The file has not yet been opened...
153
-
154
-echo $stream->read(10);
155
-// The file is opened and read from only when needed.
156
-```
157
-
158
-
159
-## LimitStream
160
-
161
-`GuzzleHttp\Psr7\LimitStream`
162
-
163
-LimitStream can be used to read a subset or slice of an existing stream object.
164
-This can be useful for breaking a large file into smaller pieces to be sent in
165
-chunks (e.g. Amazon S3's multipart upload API).
166
-
167
-```php
168
-use GuzzleHttp\Psr7;
169
-
170
-$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
171
-echo $original->getSize();
172
-// >>> 1048576
173
-
174
-// Limit the size of the body to 1024 bytes and start reading from byte 2048
175
-$stream = new Psr7\LimitStream($original, 1024, 2048);
176
-echo $stream->getSize();
177
-// >>> 1024
178
-echo $stream->tell();
179
-// >>> 0
180
-```
181
-
182
-
183
-## MultipartStream
184
-
185
-`GuzzleHttp\Psr7\MultipartStream`
186
-
187
-Stream that when read returns bytes for a streaming multipart or
188
-multipart/form-data stream.
189
-
190
-
191
-## NoSeekStream
192
-
193
-`GuzzleHttp\Psr7\NoSeekStream`
194
-
195
-NoSeekStream wraps a stream and does not allow seeking.
196
-
197
-```php
198
-use GuzzleHttp\Psr7;
199
-
200
-$original = Psr7\Utils::streamFor('foo');
201
-$noSeek = new Psr7\NoSeekStream($original);
202
-
203
-echo $noSeek->read(3);
204
-// foo
205
-var_export($noSeek->isSeekable());
206
-// false
207
-$noSeek->seek(0);
208
-var_export($noSeek->read(3));
209
-// NULL
210
-```
211
-
212
-
213
-## PumpStream
214
-
215
-`GuzzleHttp\Psr7\PumpStream`
216
-
217
-Provides a read only stream that pumps data from a PHP callable.
218
-
219
-When invoking the provided callable, the PumpStream will pass the amount of
220
-data requested to read to the callable. The callable can choose to ignore
221
-this value and return fewer or more bytes than requested. Any extra data
222
-returned by the provided callable is buffered internally until drained using
223
-the read() function of the PumpStream. The provided callable MUST return
224
-false when there is no more data to read.
225
-
226
-
227
-## Implementing stream decorators
228
-
229
-Creating a stream decorator is very easy thanks to the
230
-`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
231
-implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
232
-stream. Just `use` the `StreamDecoratorTrait` and implement your custom
233
-methods.
234
-
235
-For example, let's say we wanted to call a specific function each time the last
236
-byte is read from a stream. This could be implemented by overriding the
237
-`read()` method.
238
-
239
-```php
240
-use Psr\Http\Message\StreamInterface;
241
-use GuzzleHttp\Psr7\StreamDecoratorTrait;
242
-
243
-class EofCallbackStream implements StreamInterface
244
-{
245
-    use StreamDecoratorTrait;
246
-
247
-    private $callback;
248
-
249
-    public function __construct(StreamInterface $stream, callable $cb)
250
-    {
251
-        $this->stream = $stream;
252
-        $this->callback = $cb;
253
-    }
254
-
255
-    public function read($length)
256
-    {
257
-        $result = $this->stream->read($length);
258
-
259
-        // Invoke the callback when EOF is hit.
260
-        if ($this->eof()) {
261
-            call_user_func($this->callback);
262
-        }
263
-
264
-        return $result;
265
-    }
266
-}
267
-```
268
-
269
-This decorator could be added to any existing stream and used like so:
270
-
271
-```php
272
-use GuzzleHttp\Psr7;
273
-
274
-$original = Psr7\Utils::streamFor('foo');
275
-
276
-$eofStream = new EofCallbackStream($original, function () {
277
-    echo 'EOF!';
278
-});
279
-
280
-$eofStream->read(2);
281
-$eofStream->read(1);
282
-// echoes "EOF!"
283
-$eofStream->seek(0);
284
-$eofStream->read(3);
285
-// echoes "EOF!"
286
-```
287
-
288
-
289
-## PHP StreamWrapper
290
-
291
-You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
292
-PSR-7 stream as a PHP stream resource.
293
-
294
-Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
295
-stream from a PSR-7 stream.
296
-
297
-```php
298
-use GuzzleHttp\Psr7\StreamWrapper;
299
-
300
-$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
301
-$resource = StreamWrapper::getResource($stream);
302
-echo fread($resource, 6); // outputs hello!
303
-```
304
-
305
-
306
-# Static API
307
-
308
-There are various static methods available under the `GuzzleHttp\Psr7` namespace.
309
-
310
-
311
-## `GuzzleHttp\Psr7\Message::toString`
312
-
313
-`public static function toString(MessageInterface $message): string`
314
-
315
-Returns the string representation of an HTTP message.
316
-
317
-```php
318
-$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
319
-echo GuzzleHttp\Psr7\Message::toString($request);
320
-```
321
-
322
-
323
-## `GuzzleHttp\Psr7\Message::bodySummary`
324
-
325
-`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
326
-
327
-Get a short summary of the message body.
328
-
329
-Will return `null` if the response is not printable.
330
-
331
-
332
-## `GuzzleHttp\Psr7\Message::rewindBody`
333
-
334
-`public static function rewindBody(MessageInterface $message): void`
335
-
336
-Attempts to rewind a message body and throws an exception on failure.
337
-
338
-The body of the message will only be rewound if a call to `tell()`
339
-returns a value other than `0`.
340
-
341
-
342
-## `GuzzleHttp\Psr7\Message::parseMessage`
343
-
344
-`public static function parseMessage(string $message): array`
345
-
346
-Parses an HTTP message into an associative array.
347
-
348
-The array contains the "start-line" key containing the start line of
349
-the message, "headers" key containing an associative array of header
350
-array values, and a "body" key containing the body of the message.
351
-
352
-
353
-## `GuzzleHttp\Psr7\Message::parseRequestUri`
354
-
355
-`public static function parseRequestUri(string $path, array $headers): string`
356
-
357
-Constructs a URI for an HTTP request message.
358
-
359
-
360
-## `GuzzleHttp\Psr7\Message::parseRequest`
361
-
362
-`public static function parseRequest(string $message): Request`
363
-
364
-Parses a request message string into a request object.
365
-
366
-
367
-## `GuzzleHttp\Psr7\Message::parseResponse`
368
-
369
-`public static function parseResponse(string $message): Response`
370
-
371
-Parses a response message string into a response object.
372
-
373
-
374
-## `GuzzleHttp\Psr7\Header::parse`
375
-
376
-`public static function parse(string|array $header): array`
377
-
378
-Parse an array of header values containing ";" separated data into an
379
-array of associative arrays representing the header key value pair data
380
-of the header. When a parameter does not contain a value, but just
381
-contains a key, this function will inject a key with a '' string value.
382
-
383
-
384
-## `GuzzleHttp\Psr7\Header::normalize`
385
-
386
-`public static function normalize(string|array $header): array`
387
-
388
-Converts an array of header values that may contain comma separated
389
-headers into an array of headers with no comma separated values.
390
-
391
-
392
-## `GuzzleHttp\Psr7\Query::parse`
393
-
394
-`public static function parse(string $str, int|bool $urlEncoding = true): array`
395
-
396
-Parse a query string into an associative array.
397
-
398
-If multiple values are found for the same key, the value of that key
399
-value pair will become an array. This function does not parse nested
400
-PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
401
-will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
402
-
403
-
404
-## `GuzzleHttp\Psr7\Query::build`
405
-
406
-`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986): string`
407
-
408
-Build a query string from an array of key value pairs.
409
-
410
-This function can use the return value of `parse()` to build a query
411
-string. This function does not modify the provided keys when an array is
412
-encountered (like `http_build_query()` would).
413
-
414
-
415
-## `GuzzleHttp\Psr7\Utils::caselessRemove`
416
-
417
-`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
418
-
419
-Remove the items given by the keys, case insensitively from the data.
420
-
421
-
422
-## `GuzzleHttp\Psr7\Utils::copyToStream`
423
-
424
-`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
425
-
426
-Copy the contents of a stream into another stream until the given number
427
-of bytes have been read.
428
-
429
-
430
-## `GuzzleHttp\Psr7\Utils::copyToString`
431
-
432
-`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
433
-
434
-Copy the contents of a stream into a string until the given number of
435
-bytes have been read.
436
-
437
-
438
-## `GuzzleHttp\Psr7\Utils::hash`
439
-
440
-`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
441
-
442
-Calculate a hash of a stream.
443
-
444
-This method reads the entire stream to calculate a rolling hash, based on
445
-PHP's `hash_init` functions.
446
-
447
-
448
-## `GuzzleHttp\Psr7\Utils::modifyRequest`
449
-
450
-`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
451
-
452
-Clone and modify a request with the given changes.
453
-
454
-This method is useful for reducing the number of clones needed to mutate
455
-a message.
456
-
457
-- method: (string) Changes the HTTP method.
458
-- set_headers: (array) Sets the given headers.
459
-- remove_headers: (array) Remove the given headers.
460
-- body: (mixed) Sets the given body.
461
-- uri: (UriInterface) Set the URI.
462
-- query: (string) Set the query string value of the URI.
463
-- version: (string) Set the protocol version.
464
-
465
-
466
-## `GuzzleHttp\Psr7\Utils::readLine`
467
-
468
-`public static function readLine(StreamInterface $stream, int $maxLength = null): string`
469
-
470
-Read a line from the stream up to the maximum allowed buffer length.
471
-
472
-
473
-## `GuzzleHttp\Psr7\Utils::streamFor`
474
-
475
-`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
476
-
477
-Create a new stream based on the input type.
478
-
479
-Options is an associative array that can contain the following keys:
480
-
481
-- metadata: Array of custom metadata.
482
-- size: Size of the stream.
483
-
484
-This method accepts the following `$resource` types:
485
-
486
-- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
487
-- `string`: Creates a stream object that uses the given string as the contents.
488
-- `resource`: Creates a stream object that wraps the given PHP stream resource.
489
-- `Iterator`: If the provided value implements `Iterator`, then a read-only
490
-  stream object will be created that wraps the given iterable. Each time the
491
-  stream is read from, data from the iterator will fill a buffer and will be
492
-  continuously called until the buffer is equal to the requested read size.
493
-  Subsequent read calls will first read from the buffer and then call `next`
494
-  on the underlying iterator until it is exhausted.
495
-- `object` with `__toString()`: If the object has the `__toString()` method,
496
-  the object will be cast to a string and then a stream will be returned that
497
-  uses the string value.
498
-- `NULL`: When `null` is passed, an empty stream object is returned.
499
-- `callable` When a callable is passed, a read-only stream object will be
500
-  created that invokes the given callable. The callable is invoked with the
501
-  number of suggested bytes to read. The callable can return any number of
502
-  bytes, but MUST return `false` when there is no more data to return. The
503
-  stream object that wraps the callable will invoke the callable until the
504
-  number of requested bytes are available. Any additional bytes will be
505
-  buffered and used in subsequent reads.
506
-
507
-```php
508
-$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
509
-$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
510
-
511
-$generator = function ($bytes) {
512
-    for ($i = 0; $i < $bytes; $i++) {
513
-        yield ' ';
514
-    }
515
-}
516
-
517
-$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
518
-```
519
-
520
-
521
-## `GuzzleHttp\Psr7\Utils::tryFopen`
522
-
523
-`public static function tryFopen(string $filename, string $mode): resource`
524
-
525
-Safely opens a PHP stream resource using a filename.
526
-
527
-When fopen fails, PHP normally raises a warning. This function adds an
528
-error handler that checks for errors and throws an exception instead.
529
-
530
-
531
-## `GuzzleHttp\Psr7\Utils::uriFor`
532
-
533
-`public static function uriFor(string|UriInterface $uri): UriInterface`
534
-
535
-Returns a UriInterface for the given value.
536
-
537
-This function accepts a string or UriInterface and returns a
538
-UriInterface for the given value. If the value is already a
539
-UriInterface, it is returned as-is.
540
-
541
-
542
-## `GuzzleHttp\Psr7\MimeType::fromFilename`
543
-
544
-`public static function fromFilename(string $filename): string|null`
545
-
546
-Determines the mimetype of a file by looking at its extension.
547
-
548
-
549
-## `GuzzleHttp\Psr7\MimeType::fromExtension`
550
-
551
-`public static function fromExtension(string $extension): string|null`
552
-
553
-Maps a file extensions to a mimetype.
554
-
555
-
556
-## Upgrading from Function API
557
-
558
-The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
559
-
560
-| Original Function | Replacement Method |
561
-|----------------|----------------|
562
-| `str` | `Message::toString` |
563
-| `uri_for` | `Utils::uriFor` |
564
-| `stream_for` | `Utils::streamFor` |
565
-| `parse_header` | `Header::parse` |
566
-| `normalize_header` | `Header::normalize` |
567
-| `modify_request` | `Utils::modifyRequest` |
568
-| `rewind_body` | `Message::rewindBody` |
569
-| `try_fopen` | `Utils::tryFopen` |
570
-| `copy_to_string` | `Utils::copyToString` |
571
-| `copy_to_stream` | `Utils::copyToStream` |
572
-| `hash` | `Utils::hash` |
573
-| `readline` | `Utils::readLine` |
574
-| `parse_request` | `Message::parseRequest` |
575
-| `parse_response` | `Message::parseResponse` |
576
-| `parse_query` | `Query::parse` |
577
-| `build_query` | `Query::build` |
578
-| `mimetype_from_filename` | `MimeType::fromFilename` |
579
-| `mimetype_from_extension` | `MimeType::fromExtension` |
580
-| `_parse_message` | `Message::parseMessage` |
581
-| `_parse_request_uri` | `Message::parseRequestUri` |
582
-| `get_message_body_summary` | `Message::bodySummary` |
583
-| `_caseless_remove` | `Utils::caselessRemove` |
584
-
585
-
586
-# Additional URI Methods
587
-
588
-Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
589
-this library also provides additional functionality when working with URIs as static methods.
590
-
591
-## URI Types
592
-
593
-An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
594
-An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
595
-the base URI. Relative references can be divided into several forms according to
596
-[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
597
-
598
-- network-path references, e.g. `//example.com/path`
599
-- absolute-path references, e.g. `/path`
600
-- relative-path references, e.g. `subpath`
601
-
602
-The following methods can be used to identify the type of the URI.
603
-
604
-### `GuzzleHttp\Psr7\Uri::isAbsolute`
605
-
606
-`public static function isAbsolute(UriInterface $uri): bool`
607
-
608
-Whether the URI is absolute, i.e. it has a scheme.
609
-
610
-### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
611
-
612
-`public static function isNetworkPathReference(UriInterface $uri): bool`
613
-
614
-Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
615
-termed an network-path reference.
616
-
617
-### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
618
-
619
-`public static function isAbsolutePathReference(UriInterface $uri): bool`
620
-
621
-Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
622
-termed an absolute-path reference.
623
-
624
-### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
625
-
626
-`public static function isRelativePathReference(UriInterface $uri): bool`
627
-
628
-Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
629
-termed a relative-path reference.
630
-
631
-### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
632
-
633
-`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
634
-
635
-Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
636
-fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
637
-(apart from its fragment) is considered a same-document reference.
638
-
639
-## URI Components
640
-
641
-Additional methods to work with URI components.
642
-
643
-### `GuzzleHttp\Psr7\Uri::isDefaultPort`
644
-
645
-`public static function isDefaultPort(UriInterface $uri): bool`
646
-
647
-Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
648
-or the standard port. This method can be used independently of the implementation.
649
-
650
-### `GuzzleHttp\Psr7\Uri::composeComponents`
651
-
652
-`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
653
-
654
-Composes a URI reference string from its various components according to
655
-[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
656
-manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
657
-
658
-### `GuzzleHttp\Psr7\Uri::fromParts`
659
-
660
-`public static function fromParts(array $parts): UriInterface`
661
-
662
-Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components.
663
-
664
-
665
-### `GuzzleHttp\Psr7\Uri::withQueryValue`
666
-
667
-`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
668
-
669
-Creates a new URI with a specific query string value. Any existing query string values that exactly match the
670
-provided key are removed and replaced with the given key value pair. A value of null will set the query string
671
-key without a value, e.g. "key" instead of "key=value".
672
-
673
-### `GuzzleHttp\Psr7\Uri::withQueryValues`
674
-
675
-`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
676
-
677
-Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
678
-associative array of key => value.
679
-
680
-### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
681
-
682
-`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
683
-
684
-Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
685
-provided key are removed.
686
-
687
-## Reference Resolution
688
-
689
-`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
690
-to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
691
-do when resolving a link in a website based on the current request URI.
692
-
693
-### `GuzzleHttp\Psr7\UriResolver::resolve`
694
-
695
-`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
696
-
697
-Converts the relative URI into a new URI that is resolved against the base URI.
698
-
699
-### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
700
-
701
-`public static function removeDotSegments(string $path): string`
702
-
703
-Removes dot segments from a path and returns the new path according to
704
-[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
705
-
706
-### `GuzzleHttp\Psr7\UriResolver::relativize`
707
-
708
-`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
709
-
710
-Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
711
-
712
-```php
713
-(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
714
-```
715
-
716
-One use-case is to use the current request URI as base URI and then generate relative links in your documents
717
-to reduce the document size or offer self-contained downloadable document archives.
718
-
719
-```php
720
-$base = new Uri('http://example.com/a/b/');
721
-echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
722
-echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
723
-echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
724
-echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
725
-```
726
-
727
-## Normalization and Comparison
728
-
729
-`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
730
-[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
731
-
732
-### `GuzzleHttp\Psr7\UriNormalizer::normalize`
733
-
734
-`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
735
-
736
-Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
737
-This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
738
-of normalizations to apply. The following normalizations are available:
739
-
740
-- `UriNormalizer::PRESERVING_NORMALIZATIONS`
741
-
742
-    Default normalizations which only include the ones that preserve semantics.
743
-
744
-- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
745
-
746
-    All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
747
-
748
-    Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
749
-
750
-- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
751
-
752
-    Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
753
-    ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
754
-    not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
755
-    characters by URI normalizers.
756
-
757
-    Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
758
-
759
-- `UriNormalizer::CONVERT_EMPTY_PATH`
760
-
761
-    Converts the empty path to "/" for http and https URIs.
762
-
763
-    Example: `http://example.org` → `http://example.org/`
764
-
765
-- `UriNormalizer::REMOVE_DEFAULT_HOST`
766
-
767
-    Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
768
-    "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
769
-    RFC 3986.
770
-
771
-    Example: `file://localhost/myfile` → `file:///myfile`
772
-
773
-- `UriNormalizer::REMOVE_DEFAULT_PORT`
774
-
775
-    Removes the default port of the given URI scheme from the URI.
776
-
777
-    Example: `http://example.org:80/` → `http://example.org/`
778
-
779
-- `UriNormalizer::REMOVE_DOT_SEGMENTS`
780
-
781
-    Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
782
-    change the semantics of the URI reference.
783
-
784
-    Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
785
-
786
-- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
787
-
788
-    Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
789
-    and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
790
-    may change the semantics. Encoded slashes (%2F) are not removed.
791
-
792
-    Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
793
-
794
-- `UriNormalizer::SORT_QUERY_PARAMETERS`
795
-
796
-    Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
797
-    significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
798
-    of the URI.
799
-
800
-    Example: `?lang=en&article=fred` → `?article=fred&lang=en`
801
-
802
-### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
803
-
804
-`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
805
-
806
-Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
807
-`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
808
-This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
809
-equivalence or difference of relative references does not mean anything.
Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,809 @@
1
+# PSR-7 Message Implementation
2
+
3
+This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/)
4
+message implementation, several stream decorators, and some helpful
5
+functionality like query string parsing.
6
+
7
+
8
+[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7)
9
+
10
+
11
+# Stream implementation
12
+
13
+This package comes with a number of stream implementations and stream
14
+decorators.
15
+
16
+
17
+## AppendStream
18
+
19
+`GuzzleHttp\Psr7\AppendStream`
20
+
21
+Reads from multiple streams, one after the other.
22
+
23
+```php
24
+use GuzzleHttp\Psr7;
25
+
26
+$a = Psr7\Utils::streamFor('abc, ');
27
+$b = Psr7\Utils::streamFor('123.');
28
+$composed = new Psr7\AppendStream([$a, $b]);
29
+
30
+$composed->addStream(Psr7\Utils::streamFor(' Above all listen to me'));
31
+
32
+echo $composed; // abc, 123. Above all listen to me.
33
+```
34
+
35
+
36
+## BufferStream
37
+
38
+`GuzzleHttp\Psr7\BufferStream`
39
+
40
+Provides a buffer stream that can be written to fill a buffer, and read
41
+from to remove bytes from the buffer.
42
+
43
+This stream returns a "hwm" metadata value that tells upstream consumers
44
+what the configured high water mark of the stream is, or the maximum
45
+preferred size of the buffer.
46
+
47
+```php
48
+use GuzzleHttp\Psr7;
49
+
50
+// When more than 1024 bytes are in the buffer, it will begin returning
51
+// false to writes. This is an indication that writers should slow down.
52
+$buffer = new Psr7\BufferStream(1024);
53
+```
54
+
55
+
56
+## CachingStream
57
+
58
+The CachingStream is used to allow seeking over previously read bytes on
59
+non-seekable streams. This can be useful when transferring a non-seekable
60
+entity body fails due to needing to rewind the stream (for example, resulting
61
+from a redirect). Data that is read from the remote stream will be buffered in
62
+a PHP temp stream so that previously read bytes are cached first in memory,
63
+then on disk.
64
+
65
+```php
66
+use GuzzleHttp\Psr7;
67
+
68
+$original = Psr7\Utils::streamFor(fopen('http://www.google.com', 'r'));
69
+$stream = new Psr7\CachingStream($original);
70
+
71
+$stream->read(1024);
72
+echo $stream->tell();
73
+// 1024
74
+
75
+$stream->seek(0);
76
+echo $stream->tell();
77
+// 0
78
+```
79
+
80
+
81
+## DroppingStream
82
+
83
+`GuzzleHttp\Psr7\DroppingStream`
84
+
85
+Stream decorator that begins dropping data once the size of the underlying
86
+stream becomes too full.
87
+
88
+```php
89
+use GuzzleHttp\Psr7;
90
+
91
+// Create an empty stream
92
+$stream = Psr7\Utils::streamFor();
93
+
94
+// Start dropping data when the stream has more than 10 bytes
95
+$dropping = new Psr7\DroppingStream($stream, 10);
96
+
97
+$dropping->write('01234567890123456789');
98
+echo $stream; // 0123456789
99
+```
100
+
101
+
102
+## FnStream
103
+
104
+`GuzzleHttp\Psr7\FnStream`
105
+
106
+Compose stream implementations based on a hash of functions.
107
+
108
+Allows for easy testing and extension of a provided stream without needing
109
+to create a concrete class for a simple extension point.
110
+
111
+```php
112
+
113
+use GuzzleHttp\Psr7;
114
+
115
+$stream = Psr7\Utils::streamFor('hi');
116
+$fnStream = Psr7\FnStream::decorate($stream, [
117
+    'rewind' => function () use ($stream) {
118
+        echo 'About to rewind - ';
119
+        $stream->rewind();
120
+        echo 'rewound!';
121
+    }
122
+]);
123
+
124
+$fnStream->rewind();
125
+// Outputs: About to rewind - rewound!
126
+```
127
+
128
+
129
+## InflateStream
130
+
131
+`GuzzleHttp\Psr7\InflateStream`
132
+
133
+Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
134
+
135
+This stream decorator skips the first 10 bytes of the given stream to remove
136
+the gzip header, converts the provided stream to a PHP stream resource,
137
+then appends the zlib.inflate filter. The stream is then converted back
138
+to a Guzzle stream resource to be used as a Guzzle stream.
139
+
140
+
141
+## LazyOpenStream
142
+
143
+`GuzzleHttp\Psr7\LazyOpenStream`
144
+
145
+Lazily reads or writes to a file that is opened only after an IO operation
146
+take place on the stream.
147
+
148
+```php
149
+use GuzzleHttp\Psr7;
150
+
151
+$stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
152
+// The file has not yet been opened...
153
+
154
+echo $stream->read(10);
155
+// The file is opened and read from only when needed.
156
+```
157
+
158
+
159
+## LimitStream
160
+
161
+`GuzzleHttp\Psr7\LimitStream`
162
+
163
+LimitStream can be used to read a subset or slice of an existing stream object.
164
+This can be useful for breaking a large file into smaller pieces to be sent in
165
+chunks (e.g. Amazon S3's multipart upload API).
166
+
167
+```php
168
+use GuzzleHttp\Psr7;
169
+
170
+$original = Psr7\Utils::streamFor(fopen('/tmp/test.txt', 'r+'));
171
+echo $original->getSize();
172
+// >>> 1048576
173
+
174
+// Limit the size of the body to 1024 bytes and start reading from byte 2048
175
+$stream = new Psr7\LimitStream($original, 1024, 2048);
176
+echo $stream->getSize();
177
+// >>> 1024
178
+echo $stream->tell();
179
+// >>> 0
180
+```
181
+
182
+
183
+## MultipartStream
184
+
185
+`GuzzleHttp\Psr7\MultipartStream`
186
+
187
+Stream that when read returns bytes for a streaming multipart or
188
+multipart/form-data stream.
189
+
190
+
191
+## NoSeekStream
192
+
193
+`GuzzleHttp\Psr7\NoSeekStream`
194
+
195
+NoSeekStream wraps a stream and does not allow seeking.
196
+
197
+```php
198
+use GuzzleHttp\Psr7;
199
+
200
+$original = Psr7\Utils::streamFor('foo');
201
+$noSeek = new Psr7\NoSeekStream($original);
202
+
203
+echo $noSeek->read(3);
204
+// foo
205
+var_export($noSeek->isSeekable());
206
+// false
207
+$noSeek->seek(0);
208
+var_export($noSeek->read(3));
209
+// NULL
210
+```
211
+
212
+
213
+## PumpStream
214
+
215
+`GuzzleHttp\Psr7\PumpStream`
216
+
217
+Provides a read only stream that pumps data from a PHP callable.
218
+
219
+When invoking the provided callable, the PumpStream will pass the amount of
220
+data requested to read to the callable. The callable can choose to ignore
221
+this value and return fewer or more bytes than requested. Any extra data
222
+returned by the provided callable is buffered internally until drained using
223
+the read() function of the PumpStream. The provided callable MUST return
224
+false when there is no more data to read.
225
+
226
+
227
+## Implementing stream decorators
228
+
229
+Creating a stream decorator is very easy thanks to the
230
+`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that
231
+implement `Psr\Http\Message\StreamInterface` by proxying to an underlying
232
+stream. Just `use` the `StreamDecoratorTrait` and implement your custom
233
+methods.
234
+
235
+For example, let's say we wanted to call a specific function each time the last
236
+byte is read from a stream. This could be implemented by overriding the
237
+`read()` method.
238
+
239
+```php
240
+use Psr\Http\Message\StreamInterface;
241
+use GuzzleHttp\Psr7\StreamDecoratorTrait;
242
+
243
+class EofCallbackStream implements StreamInterface
244
+{
245
+    use StreamDecoratorTrait;
246
+
247
+    private $callback;
248
+
249
+    public function __construct(StreamInterface $stream, callable $cb)
250
+    {
251
+        $this->stream = $stream;
252
+        $this->callback = $cb;
253
+    }
254
+
255
+    public function read($length)
256
+    {
257
+        $result = $this->stream->read($length);
258
+
259
+        // Invoke the callback when EOF is hit.
260
+        if ($this->eof()) {
261
+            call_user_func($this->callback);
262
+        }
263
+
264
+        return $result;
265
+    }
266
+}
267
+```
268
+
269
+This decorator could be added to any existing stream and used like so:
270
+
271
+```php
272
+use GuzzleHttp\Psr7;
273
+
274
+$original = Psr7\Utils::streamFor('foo');
275
+
276
+$eofStream = new EofCallbackStream($original, function () {
277
+    echo 'EOF!';
278
+});
279
+
280
+$eofStream->read(2);
281
+$eofStream->read(1);
282
+// echoes "EOF!"
283
+$eofStream->seek(0);
284
+$eofStream->read(3);
285
+// echoes "EOF!"
286
+```
287
+
288
+
289
+## PHP StreamWrapper
290
+
291
+You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a
292
+PSR-7 stream as a PHP stream resource.
293
+
294
+Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP
295
+stream from a PSR-7 stream.
296
+
297
+```php
298
+use GuzzleHttp\Psr7\StreamWrapper;
299
+
300
+$stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
301
+$resource = StreamWrapper::getResource($stream);
302
+echo fread($resource, 6); // outputs hello!
303
+```
304
+
305
+
306
+# Static API
307
+
308
+There are various static methods available under the `GuzzleHttp\Psr7` namespace.
309
+
310
+
311
+## `GuzzleHttp\Psr7\Message::toString`
312
+
313
+`public static function toString(MessageInterface $message): string`
314
+
315
+Returns the string representation of an HTTP message.
316
+
317
+```php
318
+$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com');
319
+echo GuzzleHttp\Psr7\Message::toString($request);
320
+```
321
+
322
+
323
+## `GuzzleHttp\Psr7\Message::bodySummary`
324
+
325
+`public static function bodySummary(MessageInterface $message, int $truncateAt = 120): string|null`
326
+
327
+Get a short summary of the message body.
328
+
329
+Will return `null` if the response is not printable.
330
+
331
+
332
+## `GuzzleHttp\Psr7\Message::rewindBody`
333
+
334
+`public static function rewindBody(MessageInterface $message): void`
335
+
336
+Attempts to rewind a message body and throws an exception on failure.
337
+
338
+The body of the message will only be rewound if a call to `tell()`
339
+returns a value other than `0`.
340
+
341
+
342
+## `GuzzleHttp\Psr7\Message::parseMessage`
343
+
344
+`public static function parseMessage(string $message): array`
345
+
346
+Parses an HTTP message into an associative array.
347
+
348
+The array contains the "start-line" key containing the start line of
349
+the message, "headers" key containing an associative array of header
350
+array values, and a "body" key containing the body of the message.
351
+
352
+
353
+## `GuzzleHttp\Psr7\Message::parseRequestUri`
354
+
355
+`public static function parseRequestUri(string $path, array $headers): string`
356
+
357
+Constructs a URI for an HTTP request message.
358
+
359
+
360
+## `GuzzleHttp\Psr7\Message::parseRequest`
361
+
362
+`public static function parseRequest(string $message): Request`
363
+
364
+Parses a request message string into a request object.
365
+
366
+
367
+## `GuzzleHttp\Psr7\Message::parseResponse`
368
+
369
+`public static function parseResponse(string $message): Response`
370
+
371
+Parses a response message string into a response object.
372
+
373
+
374
+## `GuzzleHttp\Psr7\Header::parse`
375
+
376
+`public static function parse(string|array $header): array`
377
+
378
+Parse an array of header values containing ";" separated data into an
379
+array of associative arrays representing the header key value pair data
380
+of the header. When a parameter does not contain a value, but just
381
+contains a key, this function will inject a key with a '' string value.
382
+
383
+
384
+## `GuzzleHttp\Psr7\Header::normalize`
385
+
386
+`public static function normalize(string|array $header): array`
387
+
388
+Converts an array of header values that may contain comma separated
389
+headers into an array of headers with no comma separated values.
390
+
391
+
392
+## `GuzzleHttp\Psr7\Query::parse`
393
+
394
+`public static function parse(string $str, int|bool $urlEncoding = true): array`
395
+
396
+Parse a query string into an associative array.
397
+
398
+If multiple values are found for the same key, the value of that key
399
+value pair will become an array. This function does not parse nested
400
+PHP style arrays into an associative array (e.g., `foo[a]=1&foo[b]=2`
401
+will be parsed into `['foo[a]' => '1', 'foo[b]' => '2'])`.
402
+
403
+
404
+## `GuzzleHttp\Psr7\Query::build`
405
+
406
+`public static function build(array $params, int|false $encoding = PHP_QUERY_RFC3986): string`
407
+
408
+Build a query string from an array of key value pairs.
409
+
410
+This function can use the return value of `parse()` to build a query
411
+string. This function does not modify the provided keys when an array is
412
+encountered (like `http_build_query()` would).
413
+
414
+
415
+## `GuzzleHttp\Psr7\Utils::caselessRemove`
416
+
417
+`public static function caselessRemove(iterable<string> $keys, $keys, array $data): array`
418
+
419
+Remove the items given by the keys, case insensitively from the data.
420
+
421
+
422
+## `GuzzleHttp\Psr7\Utils::copyToStream`
423
+
424
+`public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void`
425
+
426
+Copy the contents of a stream into another stream until the given number
427
+of bytes have been read.
428
+
429
+
430
+## `GuzzleHttp\Psr7\Utils::copyToString`
431
+
432
+`public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
433
+
434
+Copy the contents of a stream into a string until the given number of
435
+bytes have been read.
436
+
437
+
438
+## `GuzzleHttp\Psr7\Utils::hash`
439
+
440
+`public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string`
441
+
442
+Calculate a hash of a stream.
443
+
444
+This method reads the entire stream to calculate a rolling hash, based on
445
+PHP's `hash_init` functions.
446
+
447
+
448
+## `GuzzleHttp\Psr7\Utils::modifyRequest`
449
+
450
+`public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface`
451
+
452
+Clone and modify a request with the given changes.
453
+
454
+This method is useful for reducing the number of clones needed to mutate
455
+a message.
456
+
457
+- method: (string) Changes the HTTP method.
458
+- set_headers: (array) Sets the given headers.
459
+- remove_headers: (array) Remove the given headers.
460
+- body: (mixed) Sets the given body.
461
+- uri: (UriInterface) Set the URI.
462
+- query: (string) Set the query string value of the URI.
463
+- version: (string) Set the protocol version.
464
+
465
+
466
+## `GuzzleHttp\Psr7\Utils::readLine`
467
+
468
+`public static function readLine(StreamInterface $stream, int $maxLength = null): string`
469
+
470
+Read a line from the stream up to the maximum allowed buffer length.
471
+
472
+
473
+## `GuzzleHttp\Psr7\Utils::streamFor`
474
+
475
+`public static function streamFor(resource|string|null|int|float|bool|StreamInterface|callable|\Iterator $resource = '', array $options = []): StreamInterface`
476
+
477
+Create a new stream based on the input type.
478
+
479
+Options is an associative array that can contain the following keys:
480
+
481
+- metadata: Array of custom metadata.
482
+- size: Size of the stream.
483
+
484
+This method accepts the following `$resource` types:
485
+
486
+- `Psr\Http\Message\StreamInterface`: Returns the value as-is.
487
+- `string`: Creates a stream object that uses the given string as the contents.
488
+- `resource`: Creates a stream object that wraps the given PHP stream resource.
489
+- `Iterator`: If the provided value implements `Iterator`, then a read-only
490
+  stream object will be created that wraps the given iterable. Each time the
491
+  stream is read from, data from the iterator will fill a buffer and will be
492
+  continuously called until the buffer is equal to the requested read size.
493
+  Subsequent read calls will first read from the buffer and then call `next`
494
+  on the underlying iterator until it is exhausted.
495
+- `object` with `__toString()`: If the object has the `__toString()` method,
496
+  the object will be cast to a string and then a stream will be returned that
497
+  uses the string value.
498
+- `NULL`: When `null` is passed, an empty stream object is returned.
499
+- `callable` When a callable is passed, a read-only stream object will be
500
+  created that invokes the given callable. The callable is invoked with the
501
+  number of suggested bytes to read. The callable can return any number of
502
+  bytes, but MUST return `false` when there is no more data to return. The
503
+  stream object that wraps the callable will invoke the callable until the
504
+  number of requested bytes are available. Any additional bytes will be
505
+  buffered and used in subsequent reads.
506
+
507
+```php
508
+$stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
509
+$stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
510
+
511
+$generator = function ($bytes) {
512
+    for ($i = 0; $i < $bytes; $i++) {
513
+        yield ' ';
514
+    }
515
+}
516
+
517
+$stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
518
+```
519
+
520
+
521
+## `GuzzleHttp\Psr7\Utils::tryFopen`
522
+
523
+`public static function tryFopen(string $filename, string $mode): resource`
524
+
525
+Safely opens a PHP stream resource using a filename.
526
+
527
+When fopen fails, PHP normally raises a warning. This function adds an
528
+error handler that checks for errors and throws an exception instead.
529
+
530
+
531
+## `GuzzleHttp\Psr7\Utils::uriFor`
532
+
533
+`public static function uriFor(string|UriInterface $uri): UriInterface`
534
+
535
+Returns a UriInterface for the given value.
536
+
537
+This function accepts a string or UriInterface and returns a
538
+UriInterface for the given value. If the value is already a
539
+UriInterface, it is returned as-is.
540
+
541
+
542
+## `GuzzleHttp\Psr7\MimeType::fromFilename`
543
+
544
+`public static function fromFilename(string $filename): string|null`
545
+
546
+Determines the mimetype of a file by looking at its extension.
547
+
548
+
549
+## `GuzzleHttp\Psr7\MimeType::fromExtension`
550
+
551
+`public static function fromExtension(string $extension): string|null`
552
+
553
+Maps a file extensions to a mimetype.
554
+
555
+
556
+## Upgrading from Function API
557
+
558
+The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
559
+
560
+| Original Function | Replacement Method |
561
+|----------------|----------------|
562
+| `str` | `Message::toString` |
563
+| `uri_for` | `Utils::uriFor` |
564
+| `stream_for` | `Utils::streamFor` |
565
+| `parse_header` | `Header::parse` |
566
+| `normalize_header` | `Header::normalize` |
567
+| `modify_request` | `Utils::modifyRequest` |
568
+| `rewind_body` | `Message::rewindBody` |
569
+| `try_fopen` | `Utils::tryFopen` |
570
+| `copy_to_string` | `Utils::copyToString` |
571
+| `copy_to_stream` | `Utils::copyToStream` |
572
+| `hash` | `Utils::hash` |
573
+| `readline` | `Utils::readLine` |
574
+| `parse_request` | `Message::parseRequest` |
575
+| `parse_response` | `Message::parseResponse` |
576
+| `parse_query` | `Query::parse` |
577
+| `build_query` | `Query::build` |
578
+| `mimetype_from_filename` | `MimeType::fromFilename` |
579
+| `mimetype_from_extension` | `MimeType::fromExtension` |
580
+| `_parse_message` | `Message::parseMessage` |
581
+| `_parse_request_uri` | `Message::parseRequestUri` |
582
+| `get_message_body_summary` | `Message::bodySummary` |
583
+| `_caseless_remove` | `Utils::caselessRemove` |
584
+
585
+
586
+# Additional URI Methods
587
+
588
+Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class,
589
+this library also provides additional functionality when working with URIs as static methods.
590
+
591
+## URI Types
592
+
593
+An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
594
+An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
595
+the base URI. Relative references can be divided into several forms according to
596
+[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
597
+
598
+- network-path references, e.g. `//example.com/path`
599
+- absolute-path references, e.g. `/path`
600
+- relative-path references, e.g. `subpath`
601
+
602
+The following methods can be used to identify the type of the URI.
603
+
604
+### `GuzzleHttp\Psr7\Uri::isAbsolute`
605
+
606
+`public static function isAbsolute(UriInterface $uri): bool`
607
+
608
+Whether the URI is absolute, i.e. it has a scheme.
609
+
610
+### `GuzzleHttp\Psr7\Uri::isNetworkPathReference`
611
+
612
+`public static function isNetworkPathReference(UriInterface $uri): bool`
613
+
614
+Whether the URI is a network-path reference. A relative reference that begins with two slash characters is
615
+termed an network-path reference.
616
+
617
+### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference`
618
+
619
+`public static function isAbsolutePathReference(UriInterface $uri): bool`
620
+
621
+Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is
622
+termed an absolute-path reference.
623
+
624
+### `GuzzleHttp\Psr7\Uri::isRelativePathReference`
625
+
626
+`public static function isRelativePathReference(UriInterface $uri): bool`
627
+
628
+Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is
629
+termed a relative-path reference.
630
+
631
+### `GuzzleHttp\Psr7\Uri::isSameDocumentReference`
632
+
633
+`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool`
634
+
635
+Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its
636
+fragment component, identical to the base URI. When no base URI is given, only an empty URI reference
637
+(apart from its fragment) is considered a same-document reference.
638
+
639
+## URI Components
640
+
641
+Additional methods to work with URI components.
642
+
643
+### `GuzzleHttp\Psr7\Uri::isDefaultPort`
644
+
645
+`public static function isDefaultPort(UriInterface $uri): bool`
646
+
647
+Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null
648
+or the standard port. This method can be used independently of the implementation.
649
+
650
+### `GuzzleHttp\Psr7\Uri::composeComponents`
651
+
652
+`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
653
+
654
+Composes a URI reference string from its various components according to
655
+[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
656
+manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
657
+
658
+### `GuzzleHttp\Psr7\Uri::fromParts`
659
+
660
+`public static function fromParts(array $parts): UriInterface`
661
+
662
+Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components.
663
+
664
+
665
+### `GuzzleHttp\Psr7\Uri::withQueryValue`
666
+
667
+`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface`
668
+
669
+Creates a new URI with a specific query string value. Any existing query string values that exactly match the
670
+provided key are removed and replaced with the given key value pair. A value of null will set the query string
671
+key without a value, e.g. "key" instead of "key=value".
672
+
673
+### `GuzzleHttp\Psr7\Uri::withQueryValues`
674
+
675
+`public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface`
676
+
677
+Creates a new URI with multiple query string values. It has the same behavior as `withQueryValue()` but for an
678
+associative array of key => value.
679
+
680
+### `GuzzleHttp\Psr7\Uri::withoutQueryValue`
681
+
682
+`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface`
683
+
684
+Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the
685
+provided key are removed.
686
+
687
+## Reference Resolution
688
+
689
+`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
690
+to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
691
+do when resolving a link in a website based on the current request URI.
692
+
693
+### `GuzzleHttp\Psr7\UriResolver::resolve`
694
+
695
+`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface`
696
+
697
+Converts the relative URI into a new URI that is resolved against the base URI.
698
+
699
+### `GuzzleHttp\Psr7\UriResolver::removeDotSegments`
700
+
701
+`public static function removeDotSegments(string $path): string`
702
+
703
+Removes dot segments from a path and returns the new path according to
704
+[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
705
+
706
+### `GuzzleHttp\Psr7\UriResolver::relativize`
707
+
708
+`public static function relativize(UriInterface $base, UriInterface $target): UriInterface`
709
+
710
+Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve():
711
+
712
+```php
713
+(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
714
+```
715
+
716
+One use-case is to use the current request URI as base URI and then generate relative links in your documents
717
+to reduce the document size or offer self-contained downloadable document archives.
718
+
719
+```php
720
+$base = new Uri('http://example.com/a/b/');
721
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
722
+echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
723
+echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
724
+echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
725
+```
726
+
727
+## Normalization and Comparison
728
+
729
+`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
730
+[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
731
+
732
+### `GuzzleHttp\Psr7\UriNormalizer::normalize`
733
+
734
+`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface`
735
+
736
+Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
737
+This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask
738
+of normalizations to apply. The following normalizations are available:
739
+
740
+- `UriNormalizer::PRESERVING_NORMALIZATIONS`
741
+
742
+    Default normalizations which only include the ones that preserve semantics.
743
+
744
+- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING`
745
+
746
+    All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
747
+
748
+    Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b`
749
+
750
+- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS`
751
+
752
+    Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of
753
+    ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should
754
+    not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved
755
+    characters by URI normalizers.
756
+
757
+    Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/`
758
+
759
+- `UriNormalizer::CONVERT_EMPTY_PATH`
760
+
761
+    Converts the empty path to "/" for http and https URIs.
762
+
763
+    Example: `http://example.org` → `http://example.org/`
764
+
765
+- `UriNormalizer::REMOVE_DEFAULT_HOST`
766
+
767
+    Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host
768
+    "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to
769
+    RFC 3986.
770
+
771
+    Example: `file://localhost/myfile` → `file:///myfile`
772
+
773
+- `UriNormalizer::REMOVE_DEFAULT_PORT`
774
+
775
+    Removes the default port of the given URI scheme from the URI.
776
+
777
+    Example: `http://example.org:80/` → `http://example.org/`
778
+
779
+- `UriNormalizer::REMOVE_DOT_SEGMENTS`
780
+
781
+    Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would
782
+    change the semantics of the URI reference.
783
+
784
+    Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html`
785
+
786
+- `UriNormalizer::REMOVE_DUPLICATE_SLASHES`
787
+
788
+    Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes
789
+    and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization
790
+    may change the semantics. Encoded slashes (%2F) are not removed.
791
+
792
+    Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html`
793
+
794
+- `UriNormalizer::SORT_QUERY_PARAMETERS`
795
+
796
+    Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be
797
+    significant (this is not defined by the standard). So this normalization is not safe and may change the semantics
798
+    of the URI.
799
+
800
+    Example: `?lang=en&article=fred` → `?article=fred&lang=en`
801
+
802
+### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent`
803
+
804
+`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool`
805
+
806
+Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given
807
+`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent.
808
+This of course assumes they will be resolved against the same base URI. If this is not the case, determination of
809
+equivalence or difference of relative references does not mean anything.