@@ -17,17 +17,17 @@ |
||
17 | 17 | */ |
18 | 18 | final class InflateStream implements StreamInterface |
19 | 19 | { |
20 | - use StreamDecoratorTrait; |
|
21 | - /** @var StreamInterface */ |
|
22 | - private $stream; |
|
23 | - public function __construct(StreamInterface $stream) |
|
24 | - { |
|
25 | - $resource = StreamWrapper::getResource($stream); |
|
26 | - // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data |
|
27 | - // See https://www.zlib.net/manual.html#Advanced definition of inflateInit2 |
|
28 | - // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection" |
|
29 | - // Default window size is 15. |
|
30 | - \stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 15 + 32]); |
|
31 | - $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); |
|
32 | - } |
|
20 | + use StreamDecoratorTrait; |
|
21 | + /** @var StreamInterface */ |
|
22 | + private $stream; |
|
23 | + public function __construct(StreamInterface $stream) |
|
24 | + { |
|
25 | + $resource = StreamWrapper::getResource($stream); |
|
26 | + // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data |
|
27 | + // See https://www.zlib.net/manual.html#Advanced definition of inflateInit2 |
|
28 | + // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection" |
|
29 | + // Default window size is 15. |
|
30 | + \stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 15 + 32]); |
|
31 | + $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); |
|
32 | + } |
|
33 | 33 | } |
@@ -15,8 +15,7 @@ |
||
15 | 15 | * @see https://datatracker.ietf.org/doc/html/rfc1952 |
16 | 16 | * @see https://www.php.net/manual/en/filters.compression.php |
17 | 17 | */ |
18 | -final class InflateStream implements StreamInterface |
|
19 | -{ |
|
18 | +final class InflateStream implements StreamInterface { |
|
20 | 19 | use StreamDecoratorTrait; |
21 | 20 | /** @var StreamInterface */ |
22 | 21 | private $stream; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
@@ -9,120 +9,120 @@ |
||
9 | 9 | */ |
10 | 10 | final class LimitStream implements StreamInterface |
11 | 11 | { |
12 | - use StreamDecoratorTrait; |
|
13 | - /** @var int Offset to start reading from */ |
|
14 | - private $offset; |
|
15 | - /** @var int Limit the number of bytes that can be read */ |
|
16 | - private $limit; |
|
17 | - /** @var StreamInterface */ |
|
18 | - private $stream; |
|
19 | - /** |
|
20 | - * @param StreamInterface $stream Stream to wrap |
|
21 | - * @param int $limit Total number of bytes to allow to be read |
|
22 | - * from the stream. Pass -1 for no limit. |
|
23 | - * @param int $offset Position to seek to before reading (only |
|
24 | - * works on seekable streams). |
|
25 | - */ |
|
26 | - public function __construct(StreamInterface $stream, int $limit = -1, int $offset = 0) |
|
27 | - { |
|
28 | - $this->stream = $stream; |
|
29 | - $this->setLimit($limit); |
|
30 | - $this->setOffset($offset); |
|
31 | - } |
|
32 | - public function eof() : bool |
|
33 | - { |
|
34 | - // Always return true if the underlying stream is EOF |
|
35 | - if ($this->stream->eof()) { |
|
36 | - return \true; |
|
37 | - } |
|
38 | - // No limit and the underlying stream is not at EOF |
|
39 | - if ($this->limit === -1) { |
|
40 | - return \false; |
|
41 | - } |
|
42 | - return $this->stream->tell() >= $this->offset + $this->limit; |
|
43 | - } |
|
44 | - /** |
|
45 | - * Returns the size of the limited subset of data |
|
46 | - */ |
|
47 | - public function getSize() : ?int |
|
48 | - { |
|
49 | - if (null === ($length = $this->stream->getSize())) { |
|
50 | - return null; |
|
51 | - } elseif ($this->limit === -1) { |
|
52 | - return $length - $this->offset; |
|
53 | - } else { |
|
54 | - return \min($this->limit, $length - $this->offset); |
|
55 | - } |
|
56 | - } |
|
57 | - /** |
|
58 | - * Allow for a bounded seek on the read limited stream |
|
59 | - */ |
|
60 | - public function seek($offset, $whence = \SEEK_SET) : void |
|
61 | - { |
|
62 | - if ($whence !== \SEEK_SET || $offset < 0) { |
|
63 | - throw new \RuntimeException(\sprintf('Cannot seek to offset %s with whence %s', $offset, $whence)); |
|
64 | - } |
|
65 | - $offset += $this->offset; |
|
66 | - if ($this->limit !== -1) { |
|
67 | - if ($offset > $this->offset + $this->limit) { |
|
68 | - $offset = $this->offset + $this->limit; |
|
69 | - } |
|
70 | - } |
|
71 | - $this->stream->seek($offset); |
|
72 | - } |
|
73 | - /** |
|
74 | - * Give a relative tell() |
|
75 | - */ |
|
76 | - public function tell() : int |
|
77 | - { |
|
78 | - return $this->stream->tell() - $this->offset; |
|
79 | - } |
|
80 | - /** |
|
81 | - * Set the offset to start limiting from |
|
82 | - * |
|
83 | - * @param int $offset Offset to seek to and begin byte limiting from |
|
84 | - * |
|
85 | - * @throws \RuntimeException if the stream cannot be seeked. |
|
86 | - */ |
|
87 | - public function setOffset(int $offset) : void |
|
88 | - { |
|
89 | - $current = $this->stream->tell(); |
|
90 | - if ($current !== $offset) { |
|
91 | - // If the stream cannot seek to the offset position, then read to it |
|
92 | - if ($this->stream->isSeekable()) { |
|
93 | - $this->stream->seek($offset); |
|
94 | - } elseif ($current > $offset) { |
|
95 | - throw new \RuntimeException("Could not seek to stream offset {$offset}"); |
|
96 | - } else { |
|
97 | - $this->stream->read($offset - $current); |
|
98 | - } |
|
99 | - } |
|
100 | - $this->offset = $offset; |
|
101 | - } |
|
102 | - /** |
|
103 | - * Set the limit of bytes that the decorator allows to be read from the |
|
104 | - * stream. |
|
105 | - * |
|
106 | - * @param int $limit Number of bytes to allow to be read from the stream. |
|
107 | - * Use -1 for no limit. |
|
108 | - */ |
|
109 | - public function setLimit(int $limit) : void |
|
110 | - { |
|
111 | - $this->limit = $limit; |
|
112 | - } |
|
113 | - public function read($length) : string |
|
114 | - { |
|
115 | - if ($this->limit === -1) { |
|
116 | - return $this->stream->read($length); |
|
117 | - } |
|
118 | - // Check if the current position is less than the total allowed |
|
119 | - // bytes + original offset |
|
120 | - $remaining = $this->offset + $this->limit - $this->stream->tell(); |
|
121 | - if ($remaining > 0) { |
|
122 | - // Only return the amount of requested data, ensuring that the byte |
|
123 | - // limit is not exceeded |
|
124 | - return $this->stream->read(\min($remaining, $length)); |
|
125 | - } |
|
126 | - return ''; |
|
127 | - } |
|
12 | + use StreamDecoratorTrait; |
|
13 | + /** @var int Offset to start reading from */ |
|
14 | + private $offset; |
|
15 | + /** @var int Limit the number of bytes that can be read */ |
|
16 | + private $limit; |
|
17 | + /** @var StreamInterface */ |
|
18 | + private $stream; |
|
19 | + /** |
|
20 | + * @param StreamInterface $stream Stream to wrap |
|
21 | + * @param int $limit Total number of bytes to allow to be read |
|
22 | + * from the stream. Pass -1 for no limit. |
|
23 | + * @param int $offset Position to seek to before reading (only |
|
24 | + * works on seekable streams). |
|
25 | + */ |
|
26 | + public function __construct(StreamInterface $stream, int $limit = -1, int $offset = 0) |
|
27 | + { |
|
28 | + $this->stream = $stream; |
|
29 | + $this->setLimit($limit); |
|
30 | + $this->setOffset($offset); |
|
31 | + } |
|
32 | + public function eof() : bool |
|
33 | + { |
|
34 | + // Always return true if the underlying stream is EOF |
|
35 | + if ($this->stream->eof()) { |
|
36 | + return \true; |
|
37 | + } |
|
38 | + // No limit and the underlying stream is not at EOF |
|
39 | + if ($this->limit === -1) { |
|
40 | + return \false; |
|
41 | + } |
|
42 | + return $this->stream->tell() >= $this->offset + $this->limit; |
|
43 | + } |
|
44 | + /** |
|
45 | + * Returns the size of the limited subset of data |
|
46 | + */ |
|
47 | + public function getSize() : ?int |
|
48 | + { |
|
49 | + if (null === ($length = $this->stream->getSize())) { |
|
50 | + return null; |
|
51 | + } elseif ($this->limit === -1) { |
|
52 | + return $length - $this->offset; |
|
53 | + } else { |
|
54 | + return \min($this->limit, $length - $this->offset); |
|
55 | + } |
|
56 | + } |
|
57 | + /** |
|
58 | + * Allow for a bounded seek on the read limited stream |
|
59 | + */ |
|
60 | + public function seek($offset, $whence = \SEEK_SET) : void |
|
61 | + { |
|
62 | + if ($whence !== \SEEK_SET || $offset < 0) { |
|
63 | + throw new \RuntimeException(\sprintf('Cannot seek to offset %s with whence %s', $offset, $whence)); |
|
64 | + } |
|
65 | + $offset += $this->offset; |
|
66 | + if ($this->limit !== -1) { |
|
67 | + if ($offset > $this->offset + $this->limit) { |
|
68 | + $offset = $this->offset + $this->limit; |
|
69 | + } |
|
70 | + } |
|
71 | + $this->stream->seek($offset); |
|
72 | + } |
|
73 | + /** |
|
74 | + * Give a relative tell() |
|
75 | + */ |
|
76 | + public function tell() : int |
|
77 | + { |
|
78 | + return $this->stream->tell() - $this->offset; |
|
79 | + } |
|
80 | + /** |
|
81 | + * Set the offset to start limiting from |
|
82 | + * |
|
83 | + * @param int $offset Offset to seek to and begin byte limiting from |
|
84 | + * |
|
85 | + * @throws \RuntimeException if the stream cannot be seeked. |
|
86 | + */ |
|
87 | + public function setOffset(int $offset) : void |
|
88 | + { |
|
89 | + $current = $this->stream->tell(); |
|
90 | + if ($current !== $offset) { |
|
91 | + // If the stream cannot seek to the offset position, then read to it |
|
92 | + if ($this->stream->isSeekable()) { |
|
93 | + $this->stream->seek($offset); |
|
94 | + } elseif ($current > $offset) { |
|
95 | + throw new \RuntimeException("Could not seek to stream offset {$offset}"); |
|
96 | + } else { |
|
97 | + $this->stream->read($offset - $current); |
|
98 | + } |
|
99 | + } |
|
100 | + $this->offset = $offset; |
|
101 | + } |
|
102 | + /** |
|
103 | + * Set the limit of bytes that the decorator allows to be read from the |
|
104 | + * stream. |
|
105 | + * |
|
106 | + * @param int $limit Number of bytes to allow to be read from the stream. |
|
107 | + * Use -1 for no limit. |
|
108 | + */ |
|
109 | + public function setLimit(int $limit) : void |
|
110 | + { |
|
111 | + $this->limit = $limit; |
|
112 | + } |
|
113 | + public function read($length) : string |
|
114 | + { |
|
115 | + if ($this->limit === -1) { |
|
116 | + return $this->stream->read($length); |
|
117 | + } |
|
118 | + // Check if the current position is less than the total allowed |
|
119 | + // bytes + original offset |
|
120 | + $remaining = $this->offset + $this->limit - $this->stream->tell(); |
|
121 | + if ($remaining > 0) { |
|
122 | + // Only return the amount of requested data, ensuring that the byte |
|
123 | + // limit is not exceeded |
|
124 | + return $this->stream->read(\min($remaining, $length)); |
|
125 | + } |
|
126 | + return ''; |
|
127 | + } |
|
128 | 128 | } |
@@ -7,8 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * Decorator used to return only a subset of a stream. |
9 | 9 | */ |
10 | -final class LimitStream implements StreamInterface |
|
11 | -{ |
|
10 | +final class LimitStream implements StreamInterface { |
|
12 | 11 | use StreamDecoratorTrait; |
13 | 12 | /** @var int Offset to start reading from */ |
14 | 13 | private $offset; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * Stream decorator that can cache previously read bytes from a sequentially |
9 | 9 | * read stream. |
10 | 10 | */ |
11 | -final class CachingStream implements StreamInterface |
|
12 | -{ |
|
11 | +final class CachingStream implements StreamInterface { |
|
13 | 12 | use StreamDecoratorTrait; |
14 | 13 | /** @var StreamInterface Stream being wrapped */ |
15 | 14 | private $remoteStream; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
@@ -10,116 +10,116 @@ |
||
10 | 10 | */ |
11 | 11 | final class CachingStream implements StreamInterface |
12 | 12 | { |
13 | - use StreamDecoratorTrait; |
|
14 | - /** @var StreamInterface Stream being wrapped */ |
|
15 | - private $remoteStream; |
|
16 | - /** @var int Number of bytes to skip reading due to a write on the buffer */ |
|
17 | - private $skipReadBytes = 0; |
|
18 | - /** |
|
19 | - * @var StreamInterface |
|
20 | - */ |
|
21 | - private $stream; |
|
22 | - /** |
|
23 | - * We will treat the buffer object as the body of the stream |
|
24 | - * |
|
25 | - * @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream. |
|
26 | - * @param StreamInterface $target Optionally specify where data is cached |
|
27 | - */ |
|
28 | - public function __construct(StreamInterface $stream, ?StreamInterface $target = null) |
|
29 | - { |
|
30 | - $this->remoteStream = $stream; |
|
31 | - $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); |
|
32 | - } |
|
33 | - public function getSize() : ?int |
|
34 | - { |
|
35 | - $remoteSize = $this->remoteStream->getSize(); |
|
36 | - if (null === $remoteSize) { |
|
37 | - return null; |
|
38 | - } |
|
39 | - return \max($this->stream->getSize(), $remoteSize); |
|
40 | - } |
|
41 | - public function rewind() : void |
|
42 | - { |
|
43 | - $this->seek(0); |
|
44 | - } |
|
45 | - public function seek($offset, $whence = \SEEK_SET) : void |
|
46 | - { |
|
47 | - if ($whence === \SEEK_SET) { |
|
48 | - $byte = $offset; |
|
49 | - } elseif ($whence === \SEEK_CUR) { |
|
50 | - $byte = $offset + $this->tell(); |
|
51 | - } elseif ($whence === \SEEK_END) { |
|
52 | - $size = $this->remoteStream->getSize(); |
|
53 | - if ($size === null) { |
|
54 | - $size = $this->cacheEntireStream(); |
|
55 | - } |
|
56 | - $byte = $size + $offset; |
|
57 | - } else { |
|
58 | - throw new \InvalidArgumentException('Invalid whence'); |
|
59 | - } |
|
60 | - $diff = $byte - $this->stream->getSize(); |
|
61 | - if ($diff > 0) { |
|
62 | - // Read the remoteStream until we have read in at least the amount |
|
63 | - // of bytes requested, or we reach the end of the file. |
|
64 | - while ($diff > 0 && !$this->remoteStream->eof()) { |
|
65 | - $this->read($diff); |
|
66 | - $diff = $byte - $this->stream->getSize(); |
|
67 | - } |
|
68 | - } else { |
|
69 | - // We can just do a normal seek since we've already seen this byte. |
|
70 | - $this->stream->seek($byte); |
|
71 | - } |
|
72 | - } |
|
73 | - public function read($length) : string |
|
74 | - { |
|
75 | - // Perform a regular read on any previously read data from the buffer |
|
76 | - $data = $this->stream->read($length); |
|
77 | - $remaining = $length - \strlen($data); |
|
78 | - // More data was requested so read from the remote stream |
|
79 | - if ($remaining) { |
|
80 | - // If data was written to the buffer in a position that would have |
|
81 | - // been filled from the remote stream, then we must skip bytes on |
|
82 | - // the remote stream to emulate overwriting bytes from that |
|
83 | - // position. This mimics the behavior of other PHP stream wrappers. |
|
84 | - $remoteData = $this->remoteStream->read($remaining + $this->skipReadBytes); |
|
85 | - if ($this->skipReadBytes) { |
|
86 | - $len = \strlen($remoteData); |
|
87 | - $remoteData = \substr($remoteData, $this->skipReadBytes); |
|
88 | - $this->skipReadBytes = \max(0, $this->skipReadBytes - $len); |
|
89 | - } |
|
90 | - $data .= $remoteData; |
|
91 | - $this->stream->write($remoteData); |
|
92 | - } |
|
93 | - return $data; |
|
94 | - } |
|
95 | - public function write($string) : int |
|
96 | - { |
|
97 | - // When appending to the end of the currently read stream, you'll want |
|
98 | - // to skip bytes from being read from the remote stream to emulate |
|
99 | - // other stream wrappers. Basically replacing bytes of data of a fixed |
|
100 | - // length. |
|
101 | - $overflow = \strlen($string) + $this->tell() - $this->remoteStream->tell(); |
|
102 | - if ($overflow > 0) { |
|
103 | - $this->skipReadBytes += $overflow; |
|
104 | - } |
|
105 | - return $this->stream->write($string); |
|
106 | - } |
|
107 | - public function eof() : bool |
|
108 | - { |
|
109 | - return $this->stream->eof() && $this->remoteStream->eof(); |
|
110 | - } |
|
111 | - /** |
|
112 | - * Close both the remote stream and buffer stream |
|
113 | - */ |
|
114 | - public function close() : void |
|
115 | - { |
|
116 | - $this->remoteStream->close(); |
|
117 | - $this->stream->close(); |
|
118 | - } |
|
119 | - private function cacheEntireStream() : int |
|
120 | - { |
|
121 | - $target = new FnStream(['write' => 'strlen']); |
|
122 | - Utils::copyToStream($this, $target); |
|
123 | - return $this->tell(); |
|
124 | - } |
|
13 | + use StreamDecoratorTrait; |
|
14 | + /** @var StreamInterface Stream being wrapped */ |
|
15 | + private $remoteStream; |
|
16 | + /** @var int Number of bytes to skip reading due to a write on the buffer */ |
|
17 | + private $skipReadBytes = 0; |
|
18 | + /** |
|
19 | + * @var StreamInterface |
|
20 | + */ |
|
21 | + private $stream; |
|
22 | + /** |
|
23 | + * We will treat the buffer object as the body of the stream |
|
24 | + * |
|
25 | + * @param StreamInterface $stream Stream to cache. The cursor is assumed to be at the beginning of the stream. |
|
26 | + * @param StreamInterface $target Optionally specify where data is cached |
|
27 | + */ |
|
28 | + public function __construct(StreamInterface $stream, ?StreamInterface $target = null) |
|
29 | + { |
|
30 | + $this->remoteStream = $stream; |
|
31 | + $this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); |
|
32 | + } |
|
33 | + public function getSize() : ?int |
|
34 | + { |
|
35 | + $remoteSize = $this->remoteStream->getSize(); |
|
36 | + if (null === $remoteSize) { |
|
37 | + return null; |
|
38 | + } |
|
39 | + return \max($this->stream->getSize(), $remoteSize); |
|
40 | + } |
|
41 | + public function rewind() : void |
|
42 | + { |
|
43 | + $this->seek(0); |
|
44 | + } |
|
45 | + public function seek($offset, $whence = \SEEK_SET) : void |
|
46 | + { |
|
47 | + if ($whence === \SEEK_SET) { |
|
48 | + $byte = $offset; |
|
49 | + } elseif ($whence === \SEEK_CUR) { |
|
50 | + $byte = $offset + $this->tell(); |
|
51 | + } elseif ($whence === \SEEK_END) { |
|
52 | + $size = $this->remoteStream->getSize(); |
|
53 | + if ($size === null) { |
|
54 | + $size = $this->cacheEntireStream(); |
|
55 | + } |
|
56 | + $byte = $size + $offset; |
|
57 | + } else { |
|
58 | + throw new \InvalidArgumentException('Invalid whence'); |
|
59 | + } |
|
60 | + $diff = $byte - $this->stream->getSize(); |
|
61 | + if ($diff > 0) { |
|
62 | + // Read the remoteStream until we have read in at least the amount |
|
63 | + // of bytes requested, or we reach the end of the file. |
|
64 | + while ($diff > 0 && !$this->remoteStream->eof()) { |
|
65 | + $this->read($diff); |
|
66 | + $diff = $byte - $this->stream->getSize(); |
|
67 | + } |
|
68 | + } else { |
|
69 | + // We can just do a normal seek since we've already seen this byte. |
|
70 | + $this->stream->seek($byte); |
|
71 | + } |
|
72 | + } |
|
73 | + public function read($length) : string |
|
74 | + { |
|
75 | + // Perform a regular read on any previously read data from the buffer |
|
76 | + $data = $this->stream->read($length); |
|
77 | + $remaining = $length - \strlen($data); |
|
78 | + // More data was requested so read from the remote stream |
|
79 | + if ($remaining) { |
|
80 | + // If data was written to the buffer in a position that would have |
|
81 | + // been filled from the remote stream, then we must skip bytes on |
|
82 | + // the remote stream to emulate overwriting bytes from that |
|
83 | + // position. This mimics the behavior of other PHP stream wrappers. |
|
84 | + $remoteData = $this->remoteStream->read($remaining + $this->skipReadBytes); |
|
85 | + if ($this->skipReadBytes) { |
|
86 | + $len = \strlen($remoteData); |
|
87 | + $remoteData = \substr($remoteData, $this->skipReadBytes); |
|
88 | + $this->skipReadBytes = \max(0, $this->skipReadBytes - $len); |
|
89 | + } |
|
90 | + $data .= $remoteData; |
|
91 | + $this->stream->write($remoteData); |
|
92 | + } |
|
93 | + return $data; |
|
94 | + } |
|
95 | + public function write($string) : int |
|
96 | + { |
|
97 | + // When appending to the end of the currently read stream, you'll want |
|
98 | + // to skip bytes from being read from the remote stream to emulate |
|
99 | + // other stream wrappers. Basically replacing bytes of data of a fixed |
|
100 | + // length. |
|
101 | + $overflow = \strlen($string) + $this->tell() - $this->remoteStream->tell(); |
|
102 | + if ($overflow > 0) { |
|
103 | + $this->skipReadBytes += $overflow; |
|
104 | + } |
|
105 | + return $this->stream->write($string); |
|
106 | + } |
|
107 | + public function eof() : bool |
|
108 | + { |
|
109 | + return $this->stream->eof() && $this->remoteStream->eof(); |
|
110 | + } |
|
111 | + /** |
|
112 | + * Close both the remote stream and buffer stream |
|
113 | + */ |
|
114 | + public function close() : void |
|
115 | + { |
|
116 | + $this->remoteStream->close(); |
|
117 | + $this->stream->close(); |
|
118 | + } |
|
119 | + private function cacheEntireStream() : int |
|
120 | + { |
|
121 | + $target = new FnStream(['write' => 'strlen']); |
|
122 | + Utils::copyToStream($this, $target); |
|
123 | + return $this->tell(); |
|
124 | + } |
|
125 | 125 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7\Exception\MalformedUriException; |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $url = $matches[2]; |
87 | 87 | } |
88 | 88 | /** @var string */ |
89 | - $encodedUrl = \preg_replace_callback('%[^:/@?&=#]+%usD', static function ($matches) { |
|
89 | + $encodedUrl = \preg_replace_callback('%[^:/@?&=#]+%usD', static function($matches) { |
|
90 | 90 | return \urlencode($matches[0]); |
91 | 91 | }, $url); |
92 | - $result = \parse_url($prefix . $encodedUrl); |
|
92 | + $result = \parse_url($prefix.$encodedUrl); |
|
93 | 93 | if ($result === \false) { |
94 | 94 | return \false; |
95 | 95 | } |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | $uri = ''; |
126 | 126 | // weak type checks to also accept null until we can add scalar type hints |
127 | 127 | if ($scheme != '') { |
128 | - $uri .= $scheme . ':'; |
|
128 | + $uri .= $scheme.':'; |
|
129 | 129 | } |
130 | 130 | if ($authority != '' || $scheme === 'file') { |
131 | - $uri .= '//' . $authority; |
|
131 | + $uri .= '//'.$authority; |
|
132 | 132 | } |
133 | 133 | if ($authority != '' && $path != '' && $path[0] != '/') { |
134 | - $path = '/' . $path; |
|
134 | + $path = '/'.$path; |
|
135 | 135 | } |
136 | 136 | $uri .= $path; |
137 | 137 | if ($query != '') { |
138 | - $uri .= '?' . $query; |
|
138 | + $uri .= '?'.$query; |
|
139 | 139 | } |
140 | 140 | if ($fragment != '') { |
141 | - $uri .= '#' . $fragment; |
|
141 | + $uri .= '#'.$fragment; |
|
142 | 142 | } |
143 | 143 | return $uri; |
144 | 144 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | { |
270 | 270 | $result = self::getFilteredQueryString($uri, \array_keys($keyValueArray)); |
271 | 271 | foreach ($keyValueArray as $key => $value) { |
272 | - $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); |
|
272 | + $result[] = self::generateQueryString((string)$key, $value !== null ? (string)$value : null); |
|
273 | 273 | } |
274 | 274 | return $uri->withQuery(\implode('&', $result)); |
275 | 275 | } |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | { |
296 | 296 | $authority = $this->host; |
297 | 297 | if ($this->userInfo !== '') { |
298 | - $authority = $this->userInfo . '@' . $authority; |
|
298 | + $authority = $this->userInfo.'@'.$authority; |
|
299 | 299 | } |
300 | 300 | if ($this->port !== null) { |
301 | - $authority .= ':' . $this->port; |
|
301 | + $authority .= ':'.$this->port; |
|
302 | 302 | } |
303 | 303 | return $authority; |
304 | 304 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | { |
344 | 344 | $info = $this->filterUserInfoComponent($user); |
345 | 345 | if ($password !== null) { |
346 | - $info .= ':' . $this->filterUserInfoComponent($password); |
|
346 | + $info .= ':'.$this->filterUserInfoComponent($password); |
|
347 | 347 | } |
348 | 348 | if ($this->userInfo === $info) { |
349 | 349 | return $this; |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : ''; |
433 | 433 | $this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : ''; |
434 | 434 | if (isset($parts['pass'])) { |
435 | - $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']); |
|
435 | + $this->userInfo .= ':'.$this->filterUserInfoComponent($parts['pass']); |
|
436 | 436 | } |
437 | 437 | $this->removeDefaultPort(); |
438 | 438 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | if (!\is_string($component)) { |
459 | 459 | throw new \InvalidArgumentException('User info must be a string'); |
460 | 460 | } |
461 | - return \preg_replace_callback('/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component); |
|
461 | + return \preg_replace_callback('/(?:[^%'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component); |
|
462 | 462 | } |
463 | 463 | /** |
464 | 464 | * @param mixed $host |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | if ($port === null) { |
483 | 483 | return null; |
484 | 484 | } |
485 | - $port = (int) $port; |
|
485 | + $port = (int)$port; |
|
486 | 486 | if (0 > $port || 0xffff < $port) { |
487 | 487 | throw new \InvalidArgumentException(\sprintf('Invalid port: %d. Must be between 0 and 65535', $port)); |
488 | 488 | } |
@@ -499,10 +499,10 @@ discard block |
||
499 | 499 | if ($current === '') { |
500 | 500 | return []; |
501 | 501 | } |
502 | - $decodedKeys = \array_map(function ($k) : string { |
|
503 | - return \rawurldecode((string) $k); |
|
502 | + $decodedKeys = \array_map(function($k) : string { |
|
503 | + return \rawurldecode((string)$k); |
|
504 | 504 | }, $keys); |
505 | - return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) { |
|
505 | + return \array_filter(\explode('&', $current), function($part) use($decodedKeys) { |
|
506 | 506 | return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true); |
507 | 507 | }); |
508 | 508 | } |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | // chars that need percent-encoding will be encoded by withQuery(). |
514 | 514 | $queryString = \strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); |
515 | 515 | if ($value !== null) { |
516 | - $queryString .= '=' . \strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
516 | + $queryString .= '='.\strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
517 | 517 | } |
518 | 518 | return $queryString; |
519 | 519 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | if (!\is_string($path)) { |
536 | 536 | throw new \InvalidArgumentException('Path must be a string'); |
537 | 537 | } |
538 | - return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path); |
|
538 | + return \preg_replace_callback('/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path); |
|
539 | 539 | } |
540 | 540 | /** |
541 | 541 | * Filters the query string or fragment of a URI. |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | if (!\is_string($str)) { |
550 | 550 | throw new \InvalidArgumentException('Query and fragment must be a string'); |
551 | 551 | } |
552 | - return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str); |
|
552 | + return \preg_replace_callback('/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str); |
|
553 | 553 | } |
554 | 554 | private function rawurlencodeMatchZero(array $match) : string |
555 | 555 | { |
@@ -14,559 +14,559 @@ |
||
14 | 14 | */ |
15 | 15 | class Uri implements UriInterface, \JsonSerializable |
16 | 16 | { |
17 | - /** |
|
18 | - * Absolute http and https URIs require a host per RFC 7230 Section 2.7 |
|
19 | - * but in generic URIs the host can be empty. So for http(s) URIs |
|
20 | - * we apply this default host when no host is given yet to form a |
|
21 | - * valid URI. |
|
22 | - */ |
|
23 | - private const HTTP_DEFAULT_HOST = 'localhost'; |
|
24 | - private const DEFAULT_PORTS = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389]; |
|
25 | - /** |
|
26 | - * Unreserved characters for use in a regex. |
|
27 | - * |
|
28 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 |
|
29 | - */ |
|
30 | - private const CHAR_UNRESERVED = 'a-zA-Z0-9_\\-\\.~'; |
|
31 | - /** |
|
32 | - * Sub-delims for use in a regex. |
|
33 | - * |
|
34 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 |
|
35 | - */ |
|
36 | - private const CHAR_SUB_DELIMS = '!\\$&\'\\(\\)\\*\\+,;='; |
|
37 | - private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; |
|
38 | - /** @var string Uri scheme. */ |
|
39 | - private $scheme = ''; |
|
40 | - /** @var string Uri user info. */ |
|
41 | - private $userInfo = ''; |
|
42 | - /** @var string Uri host. */ |
|
43 | - private $host = ''; |
|
44 | - /** @var int|null Uri port. */ |
|
45 | - private $port; |
|
46 | - /** @var string Uri path. */ |
|
47 | - private $path = ''; |
|
48 | - /** @var string Uri query string. */ |
|
49 | - private $query = ''; |
|
50 | - /** @var string Uri fragment. */ |
|
51 | - private $fragment = ''; |
|
52 | - /** @var string|null String representation */ |
|
53 | - private $composedComponents; |
|
54 | - public function __construct(string $uri = '') |
|
55 | - { |
|
56 | - if ($uri !== '') { |
|
57 | - $parts = self::parse($uri); |
|
58 | - if ($parts === \false) { |
|
59 | - throw new MalformedUriException("Unable to parse URI: {$uri}"); |
|
60 | - } |
|
61 | - $this->applyParts($parts); |
|
62 | - } |
|
63 | - } |
|
64 | - /** |
|
65 | - * UTF-8 aware \parse_url() replacement. |
|
66 | - * |
|
67 | - * The internal function produces broken output for non ASCII domain names |
|
68 | - * (IDN) when used with locales other than "C". |
|
69 | - * |
|
70 | - * On the other hand, cURL understands IDN correctly only when UTF-8 locale |
|
71 | - * is configured ("C.UTF-8", "en_US.UTF-8", etc.). |
|
72 | - * |
|
73 | - * @see https://bugs.php.net/bug.php?id=52923 |
|
74 | - * @see https://www.php.net/manual/en/function.parse-url.php#114817 |
|
75 | - * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING |
|
76 | - * |
|
77 | - * @return array|false |
|
78 | - */ |
|
79 | - private static function parse(string $url) |
|
80 | - { |
|
81 | - // If IPv6 |
|
82 | - $prefix = ''; |
|
83 | - if (\preg_match('%^(.*://\\[[0-9:a-f]+\\])(.*?)$%', $url, $matches)) { |
|
84 | - /** @var array{0:string, 1:string, 2:string} $matches */ |
|
85 | - $prefix = $matches[1]; |
|
86 | - $url = $matches[2]; |
|
87 | - } |
|
88 | - /** @var string */ |
|
89 | - $encodedUrl = \preg_replace_callback('%[^:/@?&=#]+%usD', static function ($matches) { |
|
90 | - return \urlencode($matches[0]); |
|
91 | - }, $url); |
|
92 | - $result = \parse_url($prefix . $encodedUrl); |
|
93 | - if ($result === \false) { |
|
94 | - return \false; |
|
95 | - } |
|
96 | - return \array_map('urldecode', $result); |
|
97 | - } |
|
98 | - public function __toString() : string |
|
99 | - { |
|
100 | - if ($this->composedComponents === null) { |
|
101 | - $this->composedComponents = self::composeComponents($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment); |
|
102 | - } |
|
103 | - return $this->composedComponents; |
|
104 | - } |
|
105 | - /** |
|
106 | - * Composes a URI reference string from its various components. |
|
107 | - * |
|
108 | - * Usually this method does not need to be called manually but instead is used indirectly via |
|
109 | - * `Psr\Http\Message\UriInterface::__toString`. |
|
110 | - * |
|
111 | - * PSR-7 UriInterface treats an empty component the same as a missing component as |
|
112 | - * getQuery(), getFragment() etc. always return a string. This explains the slight |
|
113 | - * difference to RFC 3986 Section 5.3. |
|
114 | - * |
|
115 | - * Another adjustment is that the authority separator is added even when the authority is missing/empty |
|
116 | - * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with |
|
117 | - * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But |
|
118 | - * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to |
|
119 | - * that format). |
|
120 | - * |
|
121 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3 |
|
122 | - */ |
|
123 | - public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string |
|
124 | - { |
|
125 | - $uri = ''; |
|
126 | - // weak type checks to also accept null until we can add scalar type hints |
|
127 | - if ($scheme != '') { |
|
128 | - $uri .= $scheme . ':'; |
|
129 | - } |
|
130 | - if ($authority != '' || $scheme === 'file') { |
|
131 | - $uri .= '//' . $authority; |
|
132 | - } |
|
133 | - if ($authority != '' && $path != '' && $path[0] != '/') { |
|
134 | - $path = '/' . $path; |
|
135 | - } |
|
136 | - $uri .= $path; |
|
137 | - if ($query != '') { |
|
138 | - $uri .= '?' . $query; |
|
139 | - } |
|
140 | - if ($fragment != '') { |
|
141 | - $uri .= '#' . $fragment; |
|
142 | - } |
|
143 | - return $uri; |
|
144 | - } |
|
145 | - /** |
|
146 | - * Whether the URI has the default port of the current scheme. |
|
147 | - * |
|
148 | - * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used |
|
149 | - * independently of the implementation. |
|
150 | - */ |
|
151 | - public static function isDefaultPort(UriInterface $uri) : bool |
|
152 | - { |
|
153 | - return $uri->getPort() === null || isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]; |
|
154 | - } |
|
155 | - /** |
|
156 | - * Whether the URI is absolute, i.e. it has a scheme. |
|
157 | - * |
|
158 | - * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true |
|
159 | - * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative |
|
160 | - * to another URI, the base URI. Relative references can be divided into several forms: |
|
161 | - * - network-path references, e.g. '//example.com/path' |
|
162 | - * - absolute-path references, e.g. '/path' |
|
163 | - * - relative-path references, e.g. 'subpath' |
|
164 | - * |
|
165 | - * @see Uri::isNetworkPathReference |
|
166 | - * @see Uri::isAbsolutePathReference |
|
167 | - * @see Uri::isRelativePathReference |
|
168 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4 |
|
169 | - */ |
|
170 | - public static function isAbsolute(UriInterface $uri) : bool |
|
171 | - { |
|
172 | - return $uri->getScheme() !== ''; |
|
173 | - } |
|
174 | - /** |
|
175 | - * Whether the URI is a network-path reference. |
|
176 | - * |
|
177 | - * A relative reference that begins with two slash characters is termed an network-path reference. |
|
178 | - * |
|
179 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
180 | - */ |
|
181 | - public static function isNetworkPathReference(UriInterface $uri) : bool |
|
182 | - { |
|
183 | - return $uri->getScheme() === '' && $uri->getAuthority() !== ''; |
|
184 | - } |
|
185 | - /** |
|
186 | - * Whether the URI is a absolute-path reference. |
|
187 | - * |
|
188 | - * A relative reference that begins with a single slash character is termed an absolute-path reference. |
|
189 | - * |
|
190 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
191 | - */ |
|
192 | - public static function isAbsolutePathReference(UriInterface $uri) : bool |
|
193 | - { |
|
194 | - return $uri->getScheme() === '' && $uri->getAuthority() === '' && isset($uri->getPath()[0]) && $uri->getPath()[0] === '/'; |
|
195 | - } |
|
196 | - /** |
|
197 | - * Whether the URI is a relative-path reference. |
|
198 | - * |
|
199 | - * A relative reference that does not begin with a slash character is termed a relative-path reference. |
|
200 | - * |
|
201 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
202 | - */ |
|
203 | - public static function isRelativePathReference(UriInterface $uri) : bool |
|
204 | - { |
|
205 | - return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); |
|
206 | - } |
|
207 | - /** |
|
208 | - * Whether the URI is a same-document reference. |
|
209 | - * |
|
210 | - * A same-document reference refers to a URI that is, aside from its fragment |
|
211 | - * component, identical to the base URI. When no base URI is given, only an empty |
|
212 | - * URI reference (apart from its fragment) is considered a same-document reference. |
|
213 | - * |
|
214 | - * @param UriInterface $uri The URI to check |
|
215 | - * @param UriInterface|null $base An optional base URI to compare against |
|
216 | - * |
|
217 | - * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4 |
|
218 | - */ |
|
219 | - public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null) : bool |
|
220 | - { |
|
221 | - if ($base !== null) { |
|
222 | - $uri = UriResolver::resolve($base, $uri); |
|
223 | - return $uri->getScheme() === $base->getScheme() && $uri->getAuthority() === $base->getAuthority() && $uri->getPath() === $base->getPath() && $uri->getQuery() === $base->getQuery(); |
|
224 | - } |
|
225 | - return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; |
|
226 | - } |
|
227 | - /** |
|
228 | - * Creates a new URI with a specific query string value removed. |
|
229 | - * |
|
230 | - * Any existing query string values that exactly match the provided key are |
|
231 | - * removed. |
|
232 | - * |
|
233 | - * @param UriInterface $uri URI to use as a base. |
|
234 | - * @param string $key Query string key to remove. |
|
235 | - */ |
|
236 | - public static function withoutQueryValue(UriInterface $uri, string $key) : UriInterface |
|
237 | - { |
|
238 | - $result = self::getFilteredQueryString($uri, [$key]); |
|
239 | - return $uri->withQuery(\implode('&', $result)); |
|
240 | - } |
|
241 | - /** |
|
242 | - * Creates a new URI with a specific query string value. |
|
243 | - * |
|
244 | - * Any existing query string values that exactly match the provided key are |
|
245 | - * removed and replaced with the given key value pair. |
|
246 | - * |
|
247 | - * A value of null will set the query string key without a value, e.g. "key" |
|
248 | - * instead of "key=value". |
|
249 | - * |
|
250 | - * @param UriInterface $uri URI to use as a base. |
|
251 | - * @param string $key Key to set. |
|
252 | - * @param string|null $value Value to set |
|
253 | - */ |
|
254 | - public static function withQueryValue(UriInterface $uri, string $key, ?string $value) : UriInterface |
|
255 | - { |
|
256 | - $result = self::getFilteredQueryString($uri, [$key]); |
|
257 | - $result[] = self::generateQueryString($key, $value); |
|
258 | - return $uri->withQuery(\implode('&', $result)); |
|
259 | - } |
|
260 | - /** |
|
261 | - * Creates a new URI with multiple specific query string values. |
|
262 | - * |
|
263 | - * It has the same behavior as withQueryValue() but for an associative array of key => value. |
|
264 | - * |
|
265 | - * @param UriInterface $uri URI to use as a base. |
|
266 | - * @param (string|null)[] $keyValueArray Associative array of key and values |
|
267 | - */ |
|
268 | - public static function withQueryValues(UriInterface $uri, array $keyValueArray) : UriInterface |
|
269 | - { |
|
270 | - $result = self::getFilteredQueryString($uri, \array_keys($keyValueArray)); |
|
271 | - foreach ($keyValueArray as $key => $value) { |
|
272 | - $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); |
|
273 | - } |
|
274 | - return $uri->withQuery(\implode('&', $result)); |
|
275 | - } |
|
276 | - /** |
|
277 | - * Creates a URI from a hash of `parse_url` components. |
|
278 | - * |
|
279 | - * @see https://www.php.net/manual/en/function.parse-url.php |
|
280 | - * |
|
281 | - * @throws MalformedUriException If the components do not form a valid URI. |
|
282 | - */ |
|
283 | - public static function fromParts(array $parts) : UriInterface |
|
284 | - { |
|
285 | - $uri = new self(); |
|
286 | - $uri->applyParts($parts); |
|
287 | - $uri->validateState(); |
|
288 | - return $uri; |
|
289 | - } |
|
290 | - public function getScheme() : string |
|
291 | - { |
|
292 | - return $this->scheme; |
|
293 | - } |
|
294 | - public function getAuthority() : string |
|
295 | - { |
|
296 | - $authority = $this->host; |
|
297 | - if ($this->userInfo !== '') { |
|
298 | - $authority = $this->userInfo . '@' . $authority; |
|
299 | - } |
|
300 | - if ($this->port !== null) { |
|
301 | - $authority .= ':' . $this->port; |
|
302 | - } |
|
303 | - return $authority; |
|
304 | - } |
|
305 | - public function getUserInfo() : string |
|
306 | - { |
|
307 | - return $this->userInfo; |
|
308 | - } |
|
309 | - public function getHost() : string |
|
310 | - { |
|
311 | - return $this->host; |
|
312 | - } |
|
313 | - public function getPort() : ?int |
|
314 | - { |
|
315 | - return $this->port; |
|
316 | - } |
|
317 | - public function getPath() : string |
|
318 | - { |
|
319 | - return $this->path; |
|
320 | - } |
|
321 | - public function getQuery() : string |
|
322 | - { |
|
323 | - return $this->query; |
|
324 | - } |
|
325 | - public function getFragment() : string |
|
326 | - { |
|
327 | - return $this->fragment; |
|
328 | - } |
|
329 | - public function withScheme($scheme) : UriInterface |
|
330 | - { |
|
331 | - $scheme = $this->filterScheme($scheme); |
|
332 | - if ($this->scheme === $scheme) { |
|
333 | - return $this; |
|
334 | - } |
|
335 | - $new = clone $this; |
|
336 | - $new->scheme = $scheme; |
|
337 | - $new->composedComponents = null; |
|
338 | - $new->removeDefaultPort(); |
|
339 | - $new->validateState(); |
|
340 | - return $new; |
|
341 | - } |
|
342 | - public function withUserInfo($user, $password = null) : UriInterface |
|
343 | - { |
|
344 | - $info = $this->filterUserInfoComponent($user); |
|
345 | - if ($password !== null) { |
|
346 | - $info .= ':' . $this->filterUserInfoComponent($password); |
|
347 | - } |
|
348 | - if ($this->userInfo === $info) { |
|
349 | - return $this; |
|
350 | - } |
|
351 | - $new = clone $this; |
|
352 | - $new->userInfo = $info; |
|
353 | - $new->composedComponents = null; |
|
354 | - $new->validateState(); |
|
355 | - return $new; |
|
356 | - } |
|
357 | - public function withHost($host) : UriInterface |
|
358 | - { |
|
359 | - $host = $this->filterHost($host); |
|
360 | - if ($this->host === $host) { |
|
361 | - return $this; |
|
362 | - } |
|
363 | - $new = clone $this; |
|
364 | - $new->host = $host; |
|
365 | - $new->composedComponents = null; |
|
366 | - $new->validateState(); |
|
367 | - return $new; |
|
368 | - } |
|
369 | - public function withPort($port) : UriInterface |
|
370 | - { |
|
371 | - $port = $this->filterPort($port); |
|
372 | - if ($this->port === $port) { |
|
373 | - return $this; |
|
374 | - } |
|
375 | - $new = clone $this; |
|
376 | - $new->port = $port; |
|
377 | - $new->composedComponents = null; |
|
378 | - $new->removeDefaultPort(); |
|
379 | - $new->validateState(); |
|
380 | - return $new; |
|
381 | - } |
|
382 | - public function withPath($path) : UriInterface |
|
383 | - { |
|
384 | - $path = $this->filterPath($path); |
|
385 | - if ($this->path === $path) { |
|
386 | - return $this; |
|
387 | - } |
|
388 | - $new = clone $this; |
|
389 | - $new->path = $path; |
|
390 | - $new->composedComponents = null; |
|
391 | - $new->validateState(); |
|
392 | - return $new; |
|
393 | - } |
|
394 | - public function withQuery($query) : UriInterface |
|
395 | - { |
|
396 | - $query = $this->filterQueryAndFragment($query); |
|
397 | - if ($this->query === $query) { |
|
398 | - return $this; |
|
399 | - } |
|
400 | - $new = clone $this; |
|
401 | - $new->query = $query; |
|
402 | - $new->composedComponents = null; |
|
403 | - return $new; |
|
404 | - } |
|
405 | - public function withFragment($fragment) : UriInterface |
|
406 | - { |
|
407 | - $fragment = $this->filterQueryAndFragment($fragment); |
|
408 | - if ($this->fragment === $fragment) { |
|
409 | - return $this; |
|
410 | - } |
|
411 | - $new = clone $this; |
|
412 | - $new->fragment = $fragment; |
|
413 | - $new->composedComponents = null; |
|
414 | - return $new; |
|
415 | - } |
|
416 | - public function jsonSerialize() : string |
|
417 | - { |
|
418 | - return $this->__toString(); |
|
419 | - } |
|
420 | - /** |
|
421 | - * Apply parse_url parts to a URI. |
|
422 | - * |
|
423 | - * @param array $parts Array of parse_url parts to apply. |
|
424 | - */ |
|
425 | - private function applyParts(array $parts) : void |
|
426 | - { |
|
427 | - $this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : ''; |
|
428 | - $this->userInfo = isset($parts['user']) ? $this->filterUserInfoComponent($parts['user']) : ''; |
|
429 | - $this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : ''; |
|
430 | - $this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null; |
|
431 | - $this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : ''; |
|
432 | - $this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : ''; |
|
433 | - $this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : ''; |
|
434 | - if (isset($parts['pass'])) { |
|
435 | - $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']); |
|
436 | - } |
|
437 | - $this->removeDefaultPort(); |
|
438 | - } |
|
439 | - /** |
|
440 | - * @param mixed $scheme |
|
441 | - * |
|
442 | - * @throws \InvalidArgumentException If the scheme is invalid. |
|
443 | - */ |
|
444 | - private function filterScheme($scheme) : string |
|
445 | - { |
|
446 | - if (!\is_string($scheme)) { |
|
447 | - throw new \InvalidArgumentException('Scheme must be a string'); |
|
448 | - } |
|
449 | - return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); |
|
450 | - } |
|
451 | - /** |
|
452 | - * @param mixed $component |
|
453 | - * |
|
454 | - * @throws \InvalidArgumentException If the user info is invalid. |
|
455 | - */ |
|
456 | - private function filterUserInfoComponent($component) : string |
|
457 | - { |
|
458 | - if (!\is_string($component)) { |
|
459 | - throw new \InvalidArgumentException('User info must be a string'); |
|
460 | - } |
|
461 | - return \preg_replace_callback('/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component); |
|
462 | - } |
|
463 | - /** |
|
464 | - * @param mixed $host |
|
465 | - * |
|
466 | - * @throws \InvalidArgumentException If the host is invalid. |
|
467 | - */ |
|
468 | - private function filterHost($host) : string |
|
469 | - { |
|
470 | - if (!\is_string($host)) { |
|
471 | - throw new \InvalidArgumentException('Host must be a string'); |
|
472 | - } |
|
473 | - return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); |
|
474 | - } |
|
475 | - /** |
|
476 | - * @param mixed $port |
|
477 | - * |
|
478 | - * @throws \InvalidArgumentException If the port is invalid. |
|
479 | - */ |
|
480 | - private function filterPort($port) : ?int |
|
481 | - { |
|
482 | - if ($port === null) { |
|
483 | - return null; |
|
484 | - } |
|
485 | - $port = (int) $port; |
|
486 | - if (0 > $port || 0xffff < $port) { |
|
487 | - throw new \InvalidArgumentException(\sprintf('Invalid port: %d. Must be between 0 and 65535', $port)); |
|
488 | - } |
|
489 | - return $port; |
|
490 | - } |
|
491 | - /** |
|
492 | - * @param (string|int)[] $keys |
|
493 | - * |
|
494 | - * @return string[] |
|
495 | - */ |
|
496 | - private static function getFilteredQueryString(UriInterface $uri, array $keys) : array |
|
497 | - { |
|
498 | - $current = $uri->getQuery(); |
|
499 | - if ($current === '') { |
|
500 | - return []; |
|
501 | - } |
|
502 | - $decodedKeys = \array_map(function ($k) : string { |
|
503 | - return \rawurldecode((string) $k); |
|
504 | - }, $keys); |
|
505 | - return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) { |
|
506 | - return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true); |
|
507 | - }); |
|
508 | - } |
|
509 | - private static function generateQueryString(string $key, ?string $value) : string |
|
510 | - { |
|
511 | - // Query string separators ("=", "&") within the key or value need to be encoded |
|
512 | - // (while preventing double-encoding) before setting the query string. All other |
|
513 | - // chars that need percent-encoding will be encoded by withQuery(). |
|
514 | - $queryString = \strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); |
|
515 | - if ($value !== null) { |
|
516 | - $queryString .= '=' . \strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
517 | - } |
|
518 | - return $queryString; |
|
519 | - } |
|
520 | - private function removeDefaultPort() : void |
|
521 | - { |
|
522 | - if ($this->port !== null && self::isDefaultPort($this)) { |
|
523 | - $this->port = null; |
|
524 | - } |
|
525 | - } |
|
526 | - /** |
|
527 | - * Filters the path of a URI |
|
528 | - * |
|
529 | - * @param mixed $path |
|
530 | - * |
|
531 | - * @throws \InvalidArgumentException If the path is invalid. |
|
532 | - */ |
|
533 | - private function filterPath($path) : string |
|
534 | - { |
|
535 | - if (!\is_string($path)) { |
|
536 | - throw new \InvalidArgumentException('Path must be a string'); |
|
537 | - } |
|
538 | - return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path); |
|
539 | - } |
|
540 | - /** |
|
541 | - * Filters the query string or fragment of a URI. |
|
542 | - * |
|
543 | - * @param mixed $str |
|
544 | - * |
|
545 | - * @throws \InvalidArgumentException If the query or fragment is invalid. |
|
546 | - */ |
|
547 | - private function filterQueryAndFragment($str) : string |
|
548 | - { |
|
549 | - if (!\is_string($str)) { |
|
550 | - throw new \InvalidArgumentException('Query and fragment must be a string'); |
|
551 | - } |
|
552 | - return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str); |
|
553 | - } |
|
554 | - private function rawurlencodeMatchZero(array $match) : string |
|
555 | - { |
|
556 | - return \rawurlencode($match[0]); |
|
557 | - } |
|
558 | - private function validateState() : void |
|
559 | - { |
|
560 | - if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { |
|
561 | - $this->host = self::HTTP_DEFAULT_HOST; |
|
562 | - } |
|
563 | - if ($this->getAuthority() === '') { |
|
564 | - if (0 === \strpos($this->path, '//')) { |
|
565 | - throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); |
|
566 | - } |
|
567 | - if ($this->scheme === '' && \false !== \strpos(\explode('/', $this->path, 2)[0], ':')) { |
|
568 | - throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); |
|
569 | - } |
|
570 | - } |
|
571 | - } |
|
17 | + /** |
|
18 | + * Absolute http and https URIs require a host per RFC 7230 Section 2.7 |
|
19 | + * but in generic URIs the host can be empty. So for http(s) URIs |
|
20 | + * we apply this default host when no host is given yet to form a |
|
21 | + * valid URI. |
|
22 | + */ |
|
23 | + private const HTTP_DEFAULT_HOST = 'localhost'; |
|
24 | + private const DEFAULT_PORTS = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389]; |
|
25 | + /** |
|
26 | + * Unreserved characters for use in a regex. |
|
27 | + * |
|
28 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3 |
|
29 | + */ |
|
30 | + private const CHAR_UNRESERVED = 'a-zA-Z0-9_\\-\\.~'; |
|
31 | + /** |
|
32 | + * Sub-delims for use in a regex. |
|
33 | + * |
|
34 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 |
|
35 | + */ |
|
36 | + private const CHAR_SUB_DELIMS = '!\\$&\'\\(\\)\\*\\+,;='; |
|
37 | + private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; |
|
38 | + /** @var string Uri scheme. */ |
|
39 | + private $scheme = ''; |
|
40 | + /** @var string Uri user info. */ |
|
41 | + private $userInfo = ''; |
|
42 | + /** @var string Uri host. */ |
|
43 | + private $host = ''; |
|
44 | + /** @var int|null Uri port. */ |
|
45 | + private $port; |
|
46 | + /** @var string Uri path. */ |
|
47 | + private $path = ''; |
|
48 | + /** @var string Uri query string. */ |
|
49 | + private $query = ''; |
|
50 | + /** @var string Uri fragment. */ |
|
51 | + private $fragment = ''; |
|
52 | + /** @var string|null String representation */ |
|
53 | + private $composedComponents; |
|
54 | + public function __construct(string $uri = '') |
|
55 | + { |
|
56 | + if ($uri !== '') { |
|
57 | + $parts = self::parse($uri); |
|
58 | + if ($parts === \false) { |
|
59 | + throw new MalformedUriException("Unable to parse URI: {$uri}"); |
|
60 | + } |
|
61 | + $this->applyParts($parts); |
|
62 | + } |
|
63 | + } |
|
64 | + /** |
|
65 | + * UTF-8 aware \parse_url() replacement. |
|
66 | + * |
|
67 | + * The internal function produces broken output for non ASCII domain names |
|
68 | + * (IDN) when used with locales other than "C". |
|
69 | + * |
|
70 | + * On the other hand, cURL understands IDN correctly only when UTF-8 locale |
|
71 | + * is configured ("C.UTF-8", "en_US.UTF-8", etc.). |
|
72 | + * |
|
73 | + * @see https://bugs.php.net/bug.php?id=52923 |
|
74 | + * @see https://www.php.net/manual/en/function.parse-url.php#114817 |
|
75 | + * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING |
|
76 | + * |
|
77 | + * @return array|false |
|
78 | + */ |
|
79 | + private static function parse(string $url) |
|
80 | + { |
|
81 | + // If IPv6 |
|
82 | + $prefix = ''; |
|
83 | + if (\preg_match('%^(.*://\\[[0-9:a-f]+\\])(.*?)$%', $url, $matches)) { |
|
84 | + /** @var array{0:string, 1:string, 2:string} $matches */ |
|
85 | + $prefix = $matches[1]; |
|
86 | + $url = $matches[2]; |
|
87 | + } |
|
88 | + /** @var string */ |
|
89 | + $encodedUrl = \preg_replace_callback('%[^:/@?&=#]+%usD', static function ($matches) { |
|
90 | + return \urlencode($matches[0]); |
|
91 | + }, $url); |
|
92 | + $result = \parse_url($prefix . $encodedUrl); |
|
93 | + if ($result === \false) { |
|
94 | + return \false; |
|
95 | + } |
|
96 | + return \array_map('urldecode', $result); |
|
97 | + } |
|
98 | + public function __toString() : string |
|
99 | + { |
|
100 | + if ($this->composedComponents === null) { |
|
101 | + $this->composedComponents = self::composeComponents($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment); |
|
102 | + } |
|
103 | + return $this->composedComponents; |
|
104 | + } |
|
105 | + /** |
|
106 | + * Composes a URI reference string from its various components. |
|
107 | + * |
|
108 | + * Usually this method does not need to be called manually but instead is used indirectly via |
|
109 | + * `Psr\Http\Message\UriInterface::__toString`. |
|
110 | + * |
|
111 | + * PSR-7 UriInterface treats an empty component the same as a missing component as |
|
112 | + * getQuery(), getFragment() etc. always return a string. This explains the slight |
|
113 | + * difference to RFC 3986 Section 5.3. |
|
114 | + * |
|
115 | + * Another adjustment is that the authority separator is added even when the authority is missing/empty |
|
116 | + * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with |
|
117 | + * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But |
|
118 | + * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to |
|
119 | + * that format). |
|
120 | + * |
|
121 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3 |
|
122 | + */ |
|
123 | + public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string |
|
124 | + { |
|
125 | + $uri = ''; |
|
126 | + // weak type checks to also accept null until we can add scalar type hints |
|
127 | + if ($scheme != '') { |
|
128 | + $uri .= $scheme . ':'; |
|
129 | + } |
|
130 | + if ($authority != '' || $scheme === 'file') { |
|
131 | + $uri .= '//' . $authority; |
|
132 | + } |
|
133 | + if ($authority != '' && $path != '' && $path[0] != '/') { |
|
134 | + $path = '/' . $path; |
|
135 | + } |
|
136 | + $uri .= $path; |
|
137 | + if ($query != '') { |
|
138 | + $uri .= '?' . $query; |
|
139 | + } |
|
140 | + if ($fragment != '') { |
|
141 | + $uri .= '#' . $fragment; |
|
142 | + } |
|
143 | + return $uri; |
|
144 | + } |
|
145 | + /** |
|
146 | + * Whether the URI has the default port of the current scheme. |
|
147 | + * |
|
148 | + * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used |
|
149 | + * independently of the implementation. |
|
150 | + */ |
|
151 | + public static function isDefaultPort(UriInterface $uri) : bool |
|
152 | + { |
|
153 | + return $uri->getPort() === null || isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]; |
|
154 | + } |
|
155 | + /** |
|
156 | + * Whether the URI is absolute, i.e. it has a scheme. |
|
157 | + * |
|
158 | + * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true |
|
159 | + * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative |
|
160 | + * to another URI, the base URI. Relative references can be divided into several forms: |
|
161 | + * - network-path references, e.g. '//example.com/path' |
|
162 | + * - absolute-path references, e.g. '/path' |
|
163 | + * - relative-path references, e.g. 'subpath' |
|
164 | + * |
|
165 | + * @see Uri::isNetworkPathReference |
|
166 | + * @see Uri::isAbsolutePathReference |
|
167 | + * @see Uri::isRelativePathReference |
|
168 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4 |
|
169 | + */ |
|
170 | + public static function isAbsolute(UriInterface $uri) : bool |
|
171 | + { |
|
172 | + return $uri->getScheme() !== ''; |
|
173 | + } |
|
174 | + /** |
|
175 | + * Whether the URI is a network-path reference. |
|
176 | + * |
|
177 | + * A relative reference that begins with two slash characters is termed an network-path reference. |
|
178 | + * |
|
179 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
180 | + */ |
|
181 | + public static function isNetworkPathReference(UriInterface $uri) : bool |
|
182 | + { |
|
183 | + return $uri->getScheme() === '' && $uri->getAuthority() !== ''; |
|
184 | + } |
|
185 | + /** |
|
186 | + * Whether the URI is a absolute-path reference. |
|
187 | + * |
|
188 | + * A relative reference that begins with a single slash character is termed an absolute-path reference. |
|
189 | + * |
|
190 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
191 | + */ |
|
192 | + public static function isAbsolutePathReference(UriInterface $uri) : bool |
|
193 | + { |
|
194 | + return $uri->getScheme() === '' && $uri->getAuthority() === '' && isset($uri->getPath()[0]) && $uri->getPath()[0] === '/'; |
|
195 | + } |
|
196 | + /** |
|
197 | + * Whether the URI is a relative-path reference. |
|
198 | + * |
|
199 | + * A relative reference that does not begin with a slash character is termed a relative-path reference. |
|
200 | + * |
|
201 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2 |
|
202 | + */ |
|
203 | + public static function isRelativePathReference(UriInterface $uri) : bool |
|
204 | + { |
|
205 | + return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); |
|
206 | + } |
|
207 | + /** |
|
208 | + * Whether the URI is a same-document reference. |
|
209 | + * |
|
210 | + * A same-document reference refers to a URI that is, aside from its fragment |
|
211 | + * component, identical to the base URI. When no base URI is given, only an empty |
|
212 | + * URI reference (apart from its fragment) is considered a same-document reference. |
|
213 | + * |
|
214 | + * @param UriInterface $uri The URI to check |
|
215 | + * @param UriInterface|null $base An optional base URI to compare against |
|
216 | + * |
|
217 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4 |
|
218 | + */ |
|
219 | + public static function isSameDocumentReference(UriInterface $uri, ?UriInterface $base = null) : bool |
|
220 | + { |
|
221 | + if ($base !== null) { |
|
222 | + $uri = UriResolver::resolve($base, $uri); |
|
223 | + return $uri->getScheme() === $base->getScheme() && $uri->getAuthority() === $base->getAuthority() && $uri->getPath() === $base->getPath() && $uri->getQuery() === $base->getQuery(); |
|
224 | + } |
|
225 | + return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; |
|
226 | + } |
|
227 | + /** |
|
228 | + * Creates a new URI with a specific query string value removed. |
|
229 | + * |
|
230 | + * Any existing query string values that exactly match the provided key are |
|
231 | + * removed. |
|
232 | + * |
|
233 | + * @param UriInterface $uri URI to use as a base. |
|
234 | + * @param string $key Query string key to remove. |
|
235 | + */ |
|
236 | + public static function withoutQueryValue(UriInterface $uri, string $key) : UriInterface |
|
237 | + { |
|
238 | + $result = self::getFilteredQueryString($uri, [$key]); |
|
239 | + return $uri->withQuery(\implode('&', $result)); |
|
240 | + } |
|
241 | + /** |
|
242 | + * Creates a new URI with a specific query string value. |
|
243 | + * |
|
244 | + * Any existing query string values that exactly match the provided key are |
|
245 | + * removed and replaced with the given key value pair. |
|
246 | + * |
|
247 | + * A value of null will set the query string key without a value, e.g. "key" |
|
248 | + * instead of "key=value". |
|
249 | + * |
|
250 | + * @param UriInterface $uri URI to use as a base. |
|
251 | + * @param string $key Key to set. |
|
252 | + * @param string|null $value Value to set |
|
253 | + */ |
|
254 | + public static function withQueryValue(UriInterface $uri, string $key, ?string $value) : UriInterface |
|
255 | + { |
|
256 | + $result = self::getFilteredQueryString($uri, [$key]); |
|
257 | + $result[] = self::generateQueryString($key, $value); |
|
258 | + return $uri->withQuery(\implode('&', $result)); |
|
259 | + } |
|
260 | + /** |
|
261 | + * Creates a new URI with multiple specific query string values. |
|
262 | + * |
|
263 | + * It has the same behavior as withQueryValue() but for an associative array of key => value. |
|
264 | + * |
|
265 | + * @param UriInterface $uri URI to use as a base. |
|
266 | + * @param (string|null)[] $keyValueArray Associative array of key and values |
|
267 | + */ |
|
268 | + public static function withQueryValues(UriInterface $uri, array $keyValueArray) : UriInterface |
|
269 | + { |
|
270 | + $result = self::getFilteredQueryString($uri, \array_keys($keyValueArray)); |
|
271 | + foreach ($keyValueArray as $key => $value) { |
|
272 | + $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); |
|
273 | + } |
|
274 | + return $uri->withQuery(\implode('&', $result)); |
|
275 | + } |
|
276 | + /** |
|
277 | + * Creates a URI from a hash of `parse_url` components. |
|
278 | + * |
|
279 | + * @see https://www.php.net/manual/en/function.parse-url.php |
|
280 | + * |
|
281 | + * @throws MalformedUriException If the components do not form a valid URI. |
|
282 | + */ |
|
283 | + public static function fromParts(array $parts) : UriInterface |
|
284 | + { |
|
285 | + $uri = new self(); |
|
286 | + $uri->applyParts($parts); |
|
287 | + $uri->validateState(); |
|
288 | + return $uri; |
|
289 | + } |
|
290 | + public function getScheme() : string |
|
291 | + { |
|
292 | + return $this->scheme; |
|
293 | + } |
|
294 | + public function getAuthority() : string |
|
295 | + { |
|
296 | + $authority = $this->host; |
|
297 | + if ($this->userInfo !== '') { |
|
298 | + $authority = $this->userInfo . '@' . $authority; |
|
299 | + } |
|
300 | + if ($this->port !== null) { |
|
301 | + $authority .= ':' . $this->port; |
|
302 | + } |
|
303 | + return $authority; |
|
304 | + } |
|
305 | + public function getUserInfo() : string |
|
306 | + { |
|
307 | + return $this->userInfo; |
|
308 | + } |
|
309 | + public function getHost() : string |
|
310 | + { |
|
311 | + return $this->host; |
|
312 | + } |
|
313 | + public function getPort() : ?int |
|
314 | + { |
|
315 | + return $this->port; |
|
316 | + } |
|
317 | + public function getPath() : string |
|
318 | + { |
|
319 | + return $this->path; |
|
320 | + } |
|
321 | + public function getQuery() : string |
|
322 | + { |
|
323 | + return $this->query; |
|
324 | + } |
|
325 | + public function getFragment() : string |
|
326 | + { |
|
327 | + return $this->fragment; |
|
328 | + } |
|
329 | + public function withScheme($scheme) : UriInterface |
|
330 | + { |
|
331 | + $scheme = $this->filterScheme($scheme); |
|
332 | + if ($this->scheme === $scheme) { |
|
333 | + return $this; |
|
334 | + } |
|
335 | + $new = clone $this; |
|
336 | + $new->scheme = $scheme; |
|
337 | + $new->composedComponents = null; |
|
338 | + $new->removeDefaultPort(); |
|
339 | + $new->validateState(); |
|
340 | + return $new; |
|
341 | + } |
|
342 | + public function withUserInfo($user, $password = null) : UriInterface |
|
343 | + { |
|
344 | + $info = $this->filterUserInfoComponent($user); |
|
345 | + if ($password !== null) { |
|
346 | + $info .= ':' . $this->filterUserInfoComponent($password); |
|
347 | + } |
|
348 | + if ($this->userInfo === $info) { |
|
349 | + return $this; |
|
350 | + } |
|
351 | + $new = clone $this; |
|
352 | + $new->userInfo = $info; |
|
353 | + $new->composedComponents = null; |
|
354 | + $new->validateState(); |
|
355 | + return $new; |
|
356 | + } |
|
357 | + public function withHost($host) : UriInterface |
|
358 | + { |
|
359 | + $host = $this->filterHost($host); |
|
360 | + if ($this->host === $host) { |
|
361 | + return $this; |
|
362 | + } |
|
363 | + $new = clone $this; |
|
364 | + $new->host = $host; |
|
365 | + $new->composedComponents = null; |
|
366 | + $new->validateState(); |
|
367 | + return $new; |
|
368 | + } |
|
369 | + public function withPort($port) : UriInterface |
|
370 | + { |
|
371 | + $port = $this->filterPort($port); |
|
372 | + if ($this->port === $port) { |
|
373 | + return $this; |
|
374 | + } |
|
375 | + $new = clone $this; |
|
376 | + $new->port = $port; |
|
377 | + $new->composedComponents = null; |
|
378 | + $new->removeDefaultPort(); |
|
379 | + $new->validateState(); |
|
380 | + return $new; |
|
381 | + } |
|
382 | + public function withPath($path) : UriInterface |
|
383 | + { |
|
384 | + $path = $this->filterPath($path); |
|
385 | + if ($this->path === $path) { |
|
386 | + return $this; |
|
387 | + } |
|
388 | + $new = clone $this; |
|
389 | + $new->path = $path; |
|
390 | + $new->composedComponents = null; |
|
391 | + $new->validateState(); |
|
392 | + return $new; |
|
393 | + } |
|
394 | + public function withQuery($query) : UriInterface |
|
395 | + { |
|
396 | + $query = $this->filterQueryAndFragment($query); |
|
397 | + if ($this->query === $query) { |
|
398 | + return $this; |
|
399 | + } |
|
400 | + $new = clone $this; |
|
401 | + $new->query = $query; |
|
402 | + $new->composedComponents = null; |
|
403 | + return $new; |
|
404 | + } |
|
405 | + public function withFragment($fragment) : UriInterface |
|
406 | + { |
|
407 | + $fragment = $this->filterQueryAndFragment($fragment); |
|
408 | + if ($this->fragment === $fragment) { |
|
409 | + return $this; |
|
410 | + } |
|
411 | + $new = clone $this; |
|
412 | + $new->fragment = $fragment; |
|
413 | + $new->composedComponents = null; |
|
414 | + return $new; |
|
415 | + } |
|
416 | + public function jsonSerialize() : string |
|
417 | + { |
|
418 | + return $this->__toString(); |
|
419 | + } |
|
420 | + /** |
|
421 | + * Apply parse_url parts to a URI. |
|
422 | + * |
|
423 | + * @param array $parts Array of parse_url parts to apply. |
|
424 | + */ |
|
425 | + private function applyParts(array $parts) : void |
|
426 | + { |
|
427 | + $this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : ''; |
|
428 | + $this->userInfo = isset($parts['user']) ? $this->filterUserInfoComponent($parts['user']) : ''; |
|
429 | + $this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : ''; |
|
430 | + $this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null; |
|
431 | + $this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : ''; |
|
432 | + $this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : ''; |
|
433 | + $this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : ''; |
|
434 | + if (isset($parts['pass'])) { |
|
435 | + $this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']); |
|
436 | + } |
|
437 | + $this->removeDefaultPort(); |
|
438 | + } |
|
439 | + /** |
|
440 | + * @param mixed $scheme |
|
441 | + * |
|
442 | + * @throws \InvalidArgumentException If the scheme is invalid. |
|
443 | + */ |
|
444 | + private function filterScheme($scheme) : string |
|
445 | + { |
|
446 | + if (!\is_string($scheme)) { |
|
447 | + throw new \InvalidArgumentException('Scheme must be a string'); |
|
448 | + } |
|
449 | + return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); |
|
450 | + } |
|
451 | + /** |
|
452 | + * @param mixed $component |
|
453 | + * |
|
454 | + * @throws \InvalidArgumentException If the user info is invalid. |
|
455 | + */ |
|
456 | + private function filterUserInfoComponent($component) : string |
|
457 | + { |
|
458 | + if (!\is_string($component)) { |
|
459 | + throw new \InvalidArgumentException('User info must be a string'); |
|
460 | + } |
|
461 | + return \preg_replace_callback('/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component); |
|
462 | + } |
|
463 | + /** |
|
464 | + * @param mixed $host |
|
465 | + * |
|
466 | + * @throws \InvalidArgumentException If the host is invalid. |
|
467 | + */ |
|
468 | + private function filterHost($host) : string |
|
469 | + { |
|
470 | + if (!\is_string($host)) { |
|
471 | + throw new \InvalidArgumentException('Host must be a string'); |
|
472 | + } |
|
473 | + return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); |
|
474 | + } |
|
475 | + /** |
|
476 | + * @param mixed $port |
|
477 | + * |
|
478 | + * @throws \InvalidArgumentException If the port is invalid. |
|
479 | + */ |
|
480 | + private function filterPort($port) : ?int |
|
481 | + { |
|
482 | + if ($port === null) { |
|
483 | + return null; |
|
484 | + } |
|
485 | + $port = (int) $port; |
|
486 | + if (0 > $port || 0xffff < $port) { |
|
487 | + throw new \InvalidArgumentException(\sprintf('Invalid port: %d. Must be between 0 and 65535', $port)); |
|
488 | + } |
|
489 | + return $port; |
|
490 | + } |
|
491 | + /** |
|
492 | + * @param (string|int)[] $keys |
|
493 | + * |
|
494 | + * @return string[] |
|
495 | + */ |
|
496 | + private static function getFilteredQueryString(UriInterface $uri, array $keys) : array |
|
497 | + { |
|
498 | + $current = $uri->getQuery(); |
|
499 | + if ($current === '') { |
|
500 | + return []; |
|
501 | + } |
|
502 | + $decodedKeys = \array_map(function ($k) : string { |
|
503 | + return \rawurldecode((string) $k); |
|
504 | + }, $keys); |
|
505 | + return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) { |
|
506 | + return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true); |
|
507 | + }); |
|
508 | + } |
|
509 | + private static function generateQueryString(string $key, ?string $value) : string |
|
510 | + { |
|
511 | + // Query string separators ("=", "&") within the key or value need to be encoded |
|
512 | + // (while preventing double-encoding) before setting the query string. All other |
|
513 | + // chars that need percent-encoding will be encoded by withQuery(). |
|
514 | + $queryString = \strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); |
|
515 | + if ($value !== null) { |
|
516 | + $queryString .= '=' . \strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); |
|
517 | + } |
|
518 | + return $queryString; |
|
519 | + } |
|
520 | + private function removeDefaultPort() : void |
|
521 | + { |
|
522 | + if ($this->port !== null && self::isDefaultPort($this)) { |
|
523 | + $this->port = null; |
|
524 | + } |
|
525 | + } |
|
526 | + /** |
|
527 | + * Filters the path of a URI |
|
528 | + * |
|
529 | + * @param mixed $path |
|
530 | + * |
|
531 | + * @throws \InvalidArgumentException If the path is invalid. |
|
532 | + */ |
|
533 | + private function filterPath($path) : string |
|
534 | + { |
|
535 | + if (!\is_string($path)) { |
|
536 | + throw new \InvalidArgumentException('Path must be a string'); |
|
537 | + } |
|
538 | + return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path); |
|
539 | + } |
|
540 | + /** |
|
541 | + * Filters the query string or fragment of a URI. |
|
542 | + * |
|
543 | + * @param mixed $str |
|
544 | + * |
|
545 | + * @throws \InvalidArgumentException If the query or fragment is invalid. |
|
546 | + */ |
|
547 | + private function filterQueryAndFragment($str) : string |
|
548 | + { |
|
549 | + if (!\is_string($str)) { |
|
550 | + throw new \InvalidArgumentException('Query and fragment must be a string'); |
|
551 | + } |
|
552 | + return \preg_replace_callback('/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\\/\\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str); |
|
553 | + } |
|
554 | + private function rawurlencodeMatchZero(array $match) : string |
|
555 | + { |
|
556 | + return \rawurlencode($match[0]); |
|
557 | + } |
|
558 | + private function validateState() : void |
|
559 | + { |
|
560 | + if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { |
|
561 | + $this->host = self::HTTP_DEFAULT_HOST; |
|
562 | + } |
|
563 | + if ($this->getAuthority() === '') { |
|
564 | + if (0 === \strpos($this->path, '//')) { |
|
565 | + throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); |
|
566 | + } |
|
567 | + if ($this->scheme === '' && \false !== \strpos(\explode('/', $this->path, 2)[0], ':')) { |
|
568 | + throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); |
|
569 | + } |
|
570 | + } |
|
571 | + } |
|
572 | 572 | } |
@@ -14,108 +14,108 @@ |
||
14 | 14 | */ |
15 | 15 | final class BufferStream implements StreamInterface |
16 | 16 | { |
17 | - /** @var int */ |
|
18 | - private $hwm; |
|
19 | - /** @var string */ |
|
20 | - private $buffer = ''; |
|
21 | - /** |
|
22 | - * @param int $hwm High water mark, representing the preferred maximum |
|
23 | - * buffer size. If the size of the buffer exceeds the high |
|
24 | - * water mark, then calls to write will continue to succeed |
|
25 | - * but will return 0 to inform writers to slow down |
|
26 | - * until the buffer has been drained by reading from it. |
|
27 | - */ |
|
28 | - public function __construct(int $hwm = 16384) |
|
29 | - { |
|
30 | - $this->hwm = $hwm; |
|
31 | - } |
|
32 | - public function __toString() : string |
|
33 | - { |
|
34 | - return $this->getContents(); |
|
35 | - } |
|
36 | - public function getContents() : string |
|
37 | - { |
|
38 | - $buffer = $this->buffer; |
|
39 | - $this->buffer = ''; |
|
40 | - return $buffer; |
|
41 | - } |
|
42 | - public function close() : void |
|
43 | - { |
|
44 | - $this->buffer = ''; |
|
45 | - } |
|
46 | - public function detach() |
|
47 | - { |
|
48 | - $this->close(); |
|
49 | - return null; |
|
50 | - } |
|
51 | - public function getSize() : ?int |
|
52 | - { |
|
53 | - return \strlen($this->buffer); |
|
54 | - } |
|
55 | - public function isReadable() : bool |
|
56 | - { |
|
57 | - return \true; |
|
58 | - } |
|
59 | - public function isWritable() : bool |
|
60 | - { |
|
61 | - return \true; |
|
62 | - } |
|
63 | - public function isSeekable() : bool |
|
64 | - { |
|
65 | - return \false; |
|
66 | - } |
|
67 | - public function rewind() : void |
|
68 | - { |
|
69 | - $this->seek(0); |
|
70 | - } |
|
71 | - public function seek($offset, $whence = \SEEK_SET) : void |
|
72 | - { |
|
73 | - throw new \RuntimeException('Cannot seek a BufferStream'); |
|
74 | - } |
|
75 | - public function eof() : bool |
|
76 | - { |
|
77 | - return \strlen($this->buffer) === 0; |
|
78 | - } |
|
79 | - public function tell() : int |
|
80 | - { |
|
81 | - throw new \RuntimeException('Cannot determine the position of a BufferStream'); |
|
82 | - } |
|
83 | - /** |
|
84 | - * Reads data from the buffer. |
|
85 | - */ |
|
86 | - public function read($length) : string |
|
87 | - { |
|
88 | - $currentLength = \strlen($this->buffer); |
|
89 | - if ($length >= $currentLength) { |
|
90 | - // No need to slice the buffer because we don't have enough data. |
|
91 | - $result = $this->buffer; |
|
92 | - $this->buffer = ''; |
|
93 | - } else { |
|
94 | - // Slice up the result to provide a subset of the buffer. |
|
95 | - $result = \substr($this->buffer, 0, $length); |
|
96 | - $this->buffer = \substr($this->buffer, $length); |
|
97 | - } |
|
98 | - return $result; |
|
99 | - } |
|
100 | - /** |
|
101 | - * Writes data to the buffer. |
|
102 | - */ |
|
103 | - public function write($string) : int |
|
104 | - { |
|
105 | - $this->buffer .= $string; |
|
106 | - if (\strlen($this->buffer) >= $this->hwm) { |
|
107 | - return 0; |
|
108 | - } |
|
109 | - return \strlen($string); |
|
110 | - } |
|
111 | - /** |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public function getMetadata($key = null) |
|
115 | - { |
|
116 | - if ($key === 'hwm') { |
|
117 | - return $this->hwm; |
|
118 | - } |
|
119 | - return $key ? null : []; |
|
120 | - } |
|
17 | + /** @var int */ |
|
18 | + private $hwm; |
|
19 | + /** @var string */ |
|
20 | + private $buffer = ''; |
|
21 | + /** |
|
22 | + * @param int $hwm High water mark, representing the preferred maximum |
|
23 | + * buffer size. If the size of the buffer exceeds the high |
|
24 | + * water mark, then calls to write will continue to succeed |
|
25 | + * but will return 0 to inform writers to slow down |
|
26 | + * until the buffer has been drained by reading from it. |
|
27 | + */ |
|
28 | + public function __construct(int $hwm = 16384) |
|
29 | + { |
|
30 | + $this->hwm = $hwm; |
|
31 | + } |
|
32 | + public function __toString() : string |
|
33 | + { |
|
34 | + return $this->getContents(); |
|
35 | + } |
|
36 | + public function getContents() : string |
|
37 | + { |
|
38 | + $buffer = $this->buffer; |
|
39 | + $this->buffer = ''; |
|
40 | + return $buffer; |
|
41 | + } |
|
42 | + public function close() : void |
|
43 | + { |
|
44 | + $this->buffer = ''; |
|
45 | + } |
|
46 | + public function detach() |
|
47 | + { |
|
48 | + $this->close(); |
|
49 | + return null; |
|
50 | + } |
|
51 | + public function getSize() : ?int |
|
52 | + { |
|
53 | + return \strlen($this->buffer); |
|
54 | + } |
|
55 | + public function isReadable() : bool |
|
56 | + { |
|
57 | + return \true; |
|
58 | + } |
|
59 | + public function isWritable() : bool |
|
60 | + { |
|
61 | + return \true; |
|
62 | + } |
|
63 | + public function isSeekable() : bool |
|
64 | + { |
|
65 | + return \false; |
|
66 | + } |
|
67 | + public function rewind() : void |
|
68 | + { |
|
69 | + $this->seek(0); |
|
70 | + } |
|
71 | + public function seek($offset, $whence = \SEEK_SET) : void |
|
72 | + { |
|
73 | + throw new \RuntimeException('Cannot seek a BufferStream'); |
|
74 | + } |
|
75 | + public function eof() : bool |
|
76 | + { |
|
77 | + return \strlen($this->buffer) === 0; |
|
78 | + } |
|
79 | + public function tell() : int |
|
80 | + { |
|
81 | + throw new \RuntimeException('Cannot determine the position of a BufferStream'); |
|
82 | + } |
|
83 | + /** |
|
84 | + * Reads data from the buffer. |
|
85 | + */ |
|
86 | + public function read($length) : string |
|
87 | + { |
|
88 | + $currentLength = \strlen($this->buffer); |
|
89 | + if ($length >= $currentLength) { |
|
90 | + // No need to slice the buffer because we don't have enough data. |
|
91 | + $result = $this->buffer; |
|
92 | + $this->buffer = ''; |
|
93 | + } else { |
|
94 | + // Slice up the result to provide a subset of the buffer. |
|
95 | + $result = \substr($this->buffer, 0, $length); |
|
96 | + $this->buffer = \substr($this->buffer, $length); |
|
97 | + } |
|
98 | + return $result; |
|
99 | + } |
|
100 | + /** |
|
101 | + * Writes data to the buffer. |
|
102 | + */ |
|
103 | + public function write($string) : int |
|
104 | + { |
|
105 | + $this->buffer .= $string; |
|
106 | + if (\strlen($this->buffer) >= $this->hwm) { |
|
107 | + return 0; |
|
108 | + } |
|
109 | + return \strlen($string); |
|
110 | + } |
|
111 | + /** |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public function getMetadata($key = null) |
|
115 | + { |
|
116 | + if ($key === 'hwm') { |
|
117 | + return $this->hwm; |
|
118 | + } |
|
119 | + return $key ? null : []; |
|
120 | + } |
|
121 | 121 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * what the configured high water mark of the stream is, or the maximum |
13 | 13 | * preferred size of the buffer. |
14 | 14 | */ |
15 | -final class BufferStream implements StreamInterface |
|
16 | -{ |
|
15 | +final class BufferStream implements StreamInterface { |
|
17 | 16 | /** @var int */ |
18 | 17 | private $hwm; |
19 | 18 | /** @var string */ |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use InvalidArgumentException; |
@@ -7,8 +7,7 @@ |
||
7 | 7 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
8 | 8 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UploadedFileInterface; |
9 | 9 | use RuntimeException; |
10 | -class UploadedFile implements UploadedFileInterface |
|
11 | -{ |
|
10 | +class UploadedFile implements UploadedFileInterface { |
|
12 | 11 | private const ERRORS = [\UPLOAD_ERR_OK, \UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION]; |
13 | 12 | /** |
14 | 13 | * @var string|null |
@@ -9,144 +9,144 @@ |
||
9 | 9 | use RuntimeException; |
10 | 10 | class UploadedFile implements UploadedFileInterface |
11 | 11 | { |
12 | - private const ERRORS = [\UPLOAD_ERR_OK, \UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION]; |
|
13 | - /** |
|
14 | - * @var string|null |
|
15 | - */ |
|
16 | - private $clientFilename; |
|
17 | - /** |
|
18 | - * @var string|null |
|
19 | - */ |
|
20 | - private $clientMediaType; |
|
21 | - /** |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - private $error; |
|
25 | - /** |
|
26 | - * @var string|null |
|
27 | - */ |
|
28 | - private $file; |
|
29 | - /** |
|
30 | - * @var bool |
|
31 | - */ |
|
32 | - private $moved = \false; |
|
33 | - /** |
|
34 | - * @var int|null |
|
35 | - */ |
|
36 | - private $size; |
|
37 | - /** |
|
38 | - * @var StreamInterface|null |
|
39 | - */ |
|
40 | - private $stream; |
|
41 | - /** |
|
42 | - * @param StreamInterface|string|resource $streamOrFile |
|
43 | - */ |
|
44 | - public function __construct($streamOrFile, ?int $size, int $errorStatus, ?string $clientFilename = null, ?string $clientMediaType = null) |
|
45 | - { |
|
46 | - $this->setError($errorStatus); |
|
47 | - $this->size = $size; |
|
48 | - $this->clientFilename = $clientFilename; |
|
49 | - $this->clientMediaType = $clientMediaType; |
|
50 | - if ($this->isOk()) { |
|
51 | - $this->setStreamOrFile($streamOrFile); |
|
52 | - } |
|
53 | - } |
|
54 | - /** |
|
55 | - * Depending on the value set file or stream variable |
|
56 | - * |
|
57 | - * @param StreamInterface|string|resource $streamOrFile |
|
58 | - * |
|
59 | - * @throws InvalidArgumentException |
|
60 | - */ |
|
61 | - private function setStreamOrFile($streamOrFile) : void |
|
62 | - { |
|
63 | - if (\is_string($streamOrFile)) { |
|
64 | - $this->file = $streamOrFile; |
|
65 | - } elseif (\is_resource($streamOrFile)) { |
|
66 | - $this->stream = new Stream($streamOrFile); |
|
67 | - } elseif ($streamOrFile instanceof StreamInterface) { |
|
68 | - $this->stream = $streamOrFile; |
|
69 | - } else { |
|
70 | - throw new InvalidArgumentException('Invalid stream or file provided for UploadedFile'); |
|
71 | - } |
|
72 | - } |
|
73 | - /** |
|
74 | - * @throws InvalidArgumentException |
|
75 | - */ |
|
76 | - private function setError(int $error) : void |
|
77 | - { |
|
78 | - if (\false === \in_array($error, UploadedFile::ERRORS, \true)) { |
|
79 | - throw new InvalidArgumentException('Invalid error status for UploadedFile'); |
|
80 | - } |
|
81 | - $this->error = $error; |
|
82 | - } |
|
83 | - private static function isStringNotEmpty($param) : bool |
|
84 | - { |
|
85 | - return \is_string($param) && \false === empty($param); |
|
86 | - } |
|
87 | - /** |
|
88 | - * Return true if there is no upload error |
|
89 | - */ |
|
90 | - private function isOk() : bool |
|
91 | - { |
|
92 | - return $this->error === \UPLOAD_ERR_OK; |
|
93 | - } |
|
94 | - public function isMoved() : bool |
|
95 | - { |
|
96 | - return $this->moved; |
|
97 | - } |
|
98 | - /** |
|
99 | - * @throws RuntimeException if is moved or not ok |
|
100 | - */ |
|
101 | - private function validateActive() : void |
|
102 | - { |
|
103 | - if (\false === $this->isOk()) { |
|
104 | - throw new RuntimeException('Cannot retrieve stream due to upload error'); |
|
105 | - } |
|
106 | - if ($this->isMoved()) { |
|
107 | - throw new RuntimeException('Cannot retrieve stream after it has already been moved'); |
|
108 | - } |
|
109 | - } |
|
110 | - public function getStream() : StreamInterface |
|
111 | - { |
|
112 | - $this->validateActive(); |
|
113 | - if ($this->stream instanceof StreamInterface) { |
|
114 | - return $this->stream; |
|
115 | - } |
|
116 | - /** @var string $file */ |
|
117 | - $file = $this->file; |
|
118 | - return new LazyOpenStream($file, 'r+'); |
|
119 | - } |
|
120 | - public function moveTo($targetPath) : void |
|
121 | - { |
|
122 | - $this->validateActive(); |
|
123 | - if (\false === self::isStringNotEmpty($targetPath)) { |
|
124 | - throw new InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string'); |
|
125 | - } |
|
126 | - if ($this->file) { |
|
127 | - $this->moved = \PHP_SAPI === 'cli' ? \rename($this->file, $targetPath) : \move_uploaded_file($this->file, $targetPath); |
|
128 | - } else { |
|
129 | - Utils::copyToStream($this->getStream(), new LazyOpenStream($targetPath, 'w')); |
|
130 | - $this->moved = \true; |
|
131 | - } |
|
132 | - if (\false === $this->moved) { |
|
133 | - throw new RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath)); |
|
134 | - } |
|
135 | - } |
|
136 | - public function getSize() : ?int |
|
137 | - { |
|
138 | - return $this->size; |
|
139 | - } |
|
140 | - public function getError() : int |
|
141 | - { |
|
142 | - return $this->error; |
|
143 | - } |
|
144 | - public function getClientFilename() : ?string |
|
145 | - { |
|
146 | - return $this->clientFilename; |
|
147 | - } |
|
148 | - public function getClientMediaType() : ?string |
|
149 | - { |
|
150 | - return $this->clientMediaType; |
|
151 | - } |
|
12 | + private const ERRORS = [\UPLOAD_ERR_OK, \UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_EXTENSION]; |
|
13 | + /** |
|
14 | + * @var string|null |
|
15 | + */ |
|
16 | + private $clientFilename; |
|
17 | + /** |
|
18 | + * @var string|null |
|
19 | + */ |
|
20 | + private $clientMediaType; |
|
21 | + /** |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + private $error; |
|
25 | + /** |
|
26 | + * @var string|null |
|
27 | + */ |
|
28 | + private $file; |
|
29 | + /** |
|
30 | + * @var bool |
|
31 | + */ |
|
32 | + private $moved = \false; |
|
33 | + /** |
|
34 | + * @var int|null |
|
35 | + */ |
|
36 | + private $size; |
|
37 | + /** |
|
38 | + * @var StreamInterface|null |
|
39 | + */ |
|
40 | + private $stream; |
|
41 | + /** |
|
42 | + * @param StreamInterface|string|resource $streamOrFile |
|
43 | + */ |
|
44 | + public function __construct($streamOrFile, ?int $size, int $errorStatus, ?string $clientFilename = null, ?string $clientMediaType = null) |
|
45 | + { |
|
46 | + $this->setError($errorStatus); |
|
47 | + $this->size = $size; |
|
48 | + $this->clientFilename = $clientFilename; |
|
49 | + $this->clientMediaType = $clientMediaType; |
|
50 | + if ($this->isOk()) { |
|
51 | + $this->setStreamOrFile($streamOrFile); |
|
52 | + } |
|
53 | + } |
|
54 | + /** |
|
55 | + * Depending on the value set file or stream variable |
|
56 | + * |
|
57 | + * @param StreamInterface|string|resource $streamOrFile |
|
58 | + * |
|
59 | + * @throws InvalidArgumentException |
|
60 | + */ |
|
61 | + private function setStreamOrFile($streamOrFile) : void |
|
62 | + { |
|
63 | + if (\is_string($streamOrFile)) { |
|
64 | + $this->file = $streamOrFile; |
|
65 | + } elseif (\is_resource($streamOrFile)) { |
|
66 | + $this->stream = new Stream($streamOrFile); |
|
67 | + } elseif ($streamOrFile instanceof StreamInterface) { |
|
68 | + $this->stream = $streamOrFile; |
|
69 | + } else { |
|
70 | + throw new InvalidArgumentException('Invalid stream or file provided for UploadedFile'); |
|
71 | + } |
|
72 | + } |
|
73 | + /** |
|
74 | + * @throws InvalidArgumentException |
|
75 | + */ |
|
76 | + private function setError(int $error) : void |
|
77 | + { |
|
78 | + if (\false === \in_array($error, UploadedFile::ERRORS, \true)) { |
|
79 | + throw new InvalidArgumentException('Invalid error status for UploadedFile'); |
|
80 | + } |
|
81 | + $this->error = $error; |
|
82 | + } |
|
83 | + private static function isStringNotEmpty($param) : bool |
|
84 | + { |
|
85 | + return \is_string($param) && \false === empty($param); |
|
86 | + } |
|
87 | + /** |
|
88 | + * Return true if there is no upload error |
|
89 | + */ |
|
90 | + private function isOk() : bool |
|
91 | + { |
|
92 | + return $this->error === \UPLOAD_ERR_OK; |
|
93 | + } |
|
94 | + public function isMoved() : bool |
|
95 | + { |
|
96 | + return $this->moved; |
|
97 | + } |
|
98 | + /** |
|
99 | + * @throws RuntimeException if is moved or not ok |
|
100 | + */ |
|
101 | + private function validateActive() : void |
|
102 | + { |
|
103 | + if (\false === $this->isOk()) { |
|
104 | + throw new RuntimeException('Cannot retrieve stream due to upload error'); |
|
105 | + } |
|
106 | + if ($this->isMoved()) { |
|
107 | + throw new RuntimeException('Cannot retrieve stream after it has already been moved'); |
|
108 | + } |
|
109 | + } |
|
110 | + public function getStream() : StreamInterface |
|
111 | + { |
|
112 | + $this->validateActive(); |
|
113 | + if ($this->stream instanceof StreamInterface) { |
|
114 | + return $this->stream; |
|
115 | + } |
|
116 | + /** @var string $file */ |
|
117 | + $file = $this->file; |
|
118 | + return new LazyOpenStream($file, 'r+'); |
|
119 | + } |
|
120 | + public function moveTo($targetPath) : void |
|
121 | + { |
|
122 | + $this->validateActive(); |
|
123 | + if (\false === self::isStringNotEmpty($targetPath)) { |
|
124 | + throw new InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string'); |
|
125 | + } |
|
126 | + if ($this->file) { |
|
127 | + $this->moved = \PHP_SAPI === 'cli' ? \rename($this->file, $targetPath) : \move_uploaded_file($this->file, $targetPath); |
|
128 | + } else { |
|
129 | + Utils::copyToStream($this->getStream(), new LazyOpenStream($targetPath, 'w')); |
|
130 | + $this->moved = \true; |
|
131 | + } |
|
132 | + if (\false === $this->moved) { |
|
133 | + throw new RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath)); |
|
134 | + } |
|
135 | + } |
|
136 | + public function getSize() : ?int |
|
137 | + { |
|
138 | + return $this->size; |
|
139 | + } |
|
140 | + public function getError() : int |
|
141 | + { |
|
142 | + return $this->error; |
|
143 | + } |
|
144 | + public function getClientFilename() : ?string |
|
145 | + { |
|
146 | + return $this->clientFilename; |
|
147 | + } |
|
148 | + public function getClientMediaType() : ?string |
|
149 | + { |
|
150 | + return $this->clientMediaType; |
|
151 | + } |
|
152 | 152 | } |
@@ -10,203 +10,203 @@ |
||
10 | 10 | */ |
11 | 11 | trait MessageTrait |
12 | 12 | { |
13 | - /** @var string[][] Map of all registered headers, as original name => array of values */ |
|
14 | - private $headers = []; |
|
15 | - /** @var string[] Map of lowercase header name => original name at registration */ |
|
16 | - private $headerNames = []; |
|
17 | - /** @var string */ |
|
18 | - private $protocol = '1.1'; |
|
19 | - /** @var StreamInterface|null */ |
|
20 | - private $stream; |
|
21 | - public function getProtocolVersion() : string |
|
22 | - { |
|
23 | - return $this->protocol; |
|
24 | - } |
|
25 | - public function withProtocolVersion($version) : MessageInterface |
|
26 | - { |
|
27 | - if ($this->protocol === $version) { |
|
28 | - return $this; |
|
29 | - } |
|
30 | - $new = clone $this; |
|
31 | - $new->protocol = $version; |
|
32 | - return $new; |
|
33 | - } |
|
34 | - public function getHeaders() : array |
|
35 | - { |
|
36 | - return $this->headers; |
|
37 | - } |
|
38 | - public function hasHeader($header) : bool |
|
39 | - { |
|
40 | - return isset($this->headerNames[\strtolower($header)]); |
|
41 | - } |
|
42 | - public function getHeader($header) : array |
|
43 | - { |
|
44 | - $header = \strtolower($header); |
|
45 | - if (!isset($this->headerNames[$header])) { |
|
46 | - return []; |
|
47 | - } |
|
48 | - $header = $this->headerNames[$header]; |
|
49 | - return $this->headers[$header]; |
|
50 | - } |
|
51 | - public function getHeaderLine($header) : string |
|
52 | - { |
|
53 | - return \implode(', ', $this->getHeader($header)); |
|
54 | - } |
|
55 | - public function withHeader($header, $value) : MessageInterface |
|
56 | - { |
|
57 | - $this->assertHeader($header); |
|
58 | - $value = $this->normalizeHeaderValue($value); |
|
59 | - $normalized = \strtolower($header); |
|
60 | - $new = clone $this; |
|
61 | - if (isset($new->headerNames[$normalized])) { |
|
62 | - unset($new->headers[$new->headerNames[$normalized]]); |
|
63 | - } |
|
64 | - $new->headerNames[$normalized] = $header; |
|
65 | - $new->headers[$header] = $value; |
|
66 | - return $new; |
|
67 | - } |
|
68 | - public function withAddedHeader($header, $value) : MessageInterface |
|
69 | - { |
|
70 | - $this->assertHeader($header); |
|
71 | - $value = $this->normalizeHeaderValue($value); |
|
72 | - $normalized = \strtolower($header); |
|
73 | - $new = clone $this; |
|
74 | - if (isset($new->headerNames[$normalized])) { |
|
75 | - $header = $this->headerNames[$normalized]; |
|
76 | - $new->headers[$header] = \array_merge($this->headers[$header], $value); |
|
77 | - } else { |
|
78 | - $new->headerNames[$normalized] = $header; |
|
79 | - $new->headers[$header] = $value; |
|
80 | - } |
|
81 | - return $new; |
|
82 | - } |
|
83 | - public function withoutHeader($header) : MessageInterface |
|
84 | - { |
|
85 | - $normalized = \strtolower($header); |
|
86 | - if (!isset($this->headerNames[$normalized])) { |
|
87 | - return $this; |
|
88 | - } |
|
89 | - $header = $this->headerNames[$normalized]; |
|
90 | - $new = clone $this; |
|
91 | - unset($new->headers[$header], $new->headerNames[$normalized]); |
|
92 | - return $new; |
|
93 | - } |
|
94 | - public function getBody() : StreamInterface |
|
95 | - { |
|
96 | - if (!$this->stream) { |
|
97 | - $this->stream = Utils::streamFor(''); |
|
98 | - } |
|
99 | - return $this->stream; |
|
100 | - } |
|
101 | - public function withBody(StreamInterface $body) : MessageInterface |
|
102 | - { |
|
103 | - if ($body === $this->stream) { |
|
104 | - return $this; |
|
105 | - } |
|
106 | - $new = clone $this; |
|
107 | - $new->stream = $body; |
|
108 | - return $new; |
|
109 | - } |
|
110 | - /** |
|
111 | - * @param (string|string[])[] $headers |
|
112 | - */ |
|
113 | - private function setHeaders(array $headers) : void |
|
114 | - { |
|
115 | - $this->headerNames = $this->headers = []; |
|
116 | - foreach ($headers as $header => $value) { |
|
117 | - // Numeric array keys are converted to int by PHP. |
|
118 | - $header = (string) $header; |
|
119 | - $this->assertHeader($header); |
|
120 | - $value = $this->normalizeHeaderValue($value); |
|
121 | - $normalized = \strtolower($header); |
|
122 | - if (isset($this->headerNames[$normalized])) { |
|
123 | - $header = $this->headerNames[$normalized]; |
|
124 | - $this->headers[$header] = \array_merge($this->headers[$header], $value); |
|
125 | - } else { |
|
126 | - $this->headerNames[$normalized] = $header; |
|
127 | - $this->headers[$header] = $value; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - /** |
|
132 | - * @param mixed $value |
|
133 | - * |
|
134 | - * @return string[] |
|
135 | - */ |
|
136 | - private function normalizeHeaderValue($value) : array |
|
137 | - { |
|
138 | - if (!\is_array($value)) { |
|
139 | - return $this->trimAndValidateHeaderValues([$value]); |
|
140 | - } |
|
141 | - if (\count($value) === 0) { |
|
142 | - throw new \InvalidArgumentException('Header value can not be an empty array.'); |
|
143 | - } |
|
144 | - return $this->trimAndValidateHeaderValues($value); |
|
145 | - } |
|
146 | - /** |
|
147 | - * Trims whitespace from the header values. |
|
148 | - * |
|
149 | - * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. |
|
150 | - * |
|
151 | - * header-field = field-name ":" OWS field-value OWS |
|
152 | - * OWS = *( SP / HTAB ) |
|
153 | - * |
|
154 | - * @param mixed[] $values Header values |
|
155 | - * |
|
156 | - * @return string[] Trimmed header values |
|
157 | - * |
|
158 | - * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 |
|
159 | - */ |
|
160 | - private function trimAndValidateHeaderValues(array $values) : array |
|
161 | - { |
|
162 | - return \array_map(function ($value) { |
|
163 | - if (!\is_scalar($value) && null !== $value) { |
|
164 | - throw new \InvalidArgumentException(\sprintf('Header value must be scalar or null but %s provided.', \is_object($value) ? \get_class($value) : \gettype($value))); |
|
165 | - } |
|
166 | - $trimmed = \trim((string) $value, " \t"); |
|
167 | - $this->assertValue($trimmed); |
|
168 | - return $trimmed; |
|
169 | - }, \array_values($values)); |
|
170 | - } |
|
171 | - /** |
|
172 | - * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 |
|
173 | - * |
|
174 | - * @param mixed $header |
|
175 | - */ |
|
176 | - private function assertHeader($header) : void |
|
177 | - { |
|
178 | - if (!\is_string($header)) { |
|
179 | - throw new \InvalidArgumentException(\sprintf('Header name must be a string but %s provided.', \is_object($header) ? \get_class($header) : \gettype($header))); |
|
180 | - } |
|
181 | - if (!\preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { |
|
182 | - throw new \InvalidArgumentException(\sprintf('"%s" is not valid header name.', $header)); |
|
183 | - } |
|
184 | - } |
|
185 | - /** |
|
186 | - * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 |
|
187 | - * |
|
188 | - * field-value = *( field-content / obs-fold ) |
|
189 | - * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] |
|
190 | - * field-vchar = VCHAR / obs-text |
|
191 | - * VCHAR = %x21-7E |
|
192 | - * obs-text = %x80-FF |
|
193 | - * obs-fold = CRLF 1*( SP / HTAB ) |
|
194 | - */ |
|
195 | - private function assertValue(string $value) : void |
|
196 | - { |
|
197 | - // The regular expression intentionally does not support the obs-fold production, because as |
|
198 | - // per RFC 7230#3.2.4: |
|
199 | - // |
|
200 | - // A sender MUST NOT generate a message that includes |
|
201 | - // line folding (i.e., that has any field-value that contains a match to |
|
202 | - // the obs-fold rule) unless the message is intended for packaging |
|
203 | - // within the message/http media type. |
|
204 | - // |
|
205 | - // Clients must not send a request with line folding and a server sending folded headers is |
|
206 | - // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting |
|
207 | - // folding is not likely to break any legitimate use case. |
|
208 | - if (!\preg_match('/^[\\x20\\x09\\x21-\\x7E\\x80-\\xFF]*$/D', $value)) { |
|
209 | - throw new \InvalidArgumentException(\sprintf('"%s" is not valid header value.', $value)); |
|
210 | - } |
|
211 | - } |
|
13 | + /** @var string[][] Map of all registered headers, as original name => array of values */ |
|
14 | + private $headers = []; |
|
15 | + /** @var string[] Map of lowercase header name => original name at registration */ |
|
16 | + private $headerNames = []; |
|
17 | + /** @var string */ |
|
18 | + private $protocol = '1.1'; |
|
19 | + /** @var StreamInterface|null */ |
|
20 | + private $stream; |
|
21 | + public function getProtocolVersion() : string |
|
22 | + { |
|
23 | + return $this->protocol; |
|
24 | + } |
|
25 | + public function withProtocolVersion($version) : MessageInterface |
|
26 | + { |
|
27 | + if ($this->protocol === $version) { |
|
28 | + return $this; |
|
29 | + } |
|
30 | + $new = clone $this; |
|
31 | + $new->protocol = $version; |
|
32 | + return $new; |
|
33 | + } |
|
34 | + public function getHeaders() : array |
|
35 | + { |
|
36 | + return $this->headers; |
|
37 | + } |
|
38 | + public function hasHeader($header) : bool |
|
39 | + { |
|
40 | + return isset($this->headerNames[\strtolower($header)]); |
|
41 | + } |
|
42 | + public function getHeader($header) : array |
|
43 | + { |
|
44 | + $header = \strtolower($header); |
|
45 | + if (!isset($this->headerNames[$header])) { |
|
46 | + return []; |
|
47 | + } |
|
48 | + $header = $this->headerNames[$header]; |
|
49 | + return $this->headers[$header]; |
|
50 | + } |
|
51 | + public function getHeaderLine($header) : string |
|
52 | + { |
|
53 | + return \implode(', ', $this->getHeader($header)); |
|
54 | + } |
|
55 | + public function withHeader($header, $value) : MessageInterface |
|
56 | + { |
|
57 | + $this->assertHeader($header); |
|
58 | + $value = $this->normalizeHeaderValue($value); |
|
59 | + $normalized = \strtolower($header); |
|
60 | + $new = clone $this; |
|
61 | + if (isset($new->headerNames[$normalized])) { |
|
62 | + unset($new->headers[$new->headerNames[$normalized]]); |
|
63 | + } |
|
64 | + $new->headerNames[$normalized] = $header; |
|
65 | + $new->headers[$header] = $value; |
|
66 | + return $new; |
|
67 | + } |
|
68 | + public function withAddedHeader($header, $value) : MessageInterface |
|
69 | + { |
|
70 | + $this->assertHeader($header); |
|
71 | + $value = $this->normalizeHeaderValue($value); |
|
72 | + $normalized = \strtolower($header); |
|
73 | + $new = clone $this; |
|
74 | + if (isset($new->headerNames[$normalized])) { |
|
75 | + $header = $this->headerNames[$normalized]; |
|
76 | + $new->headers[$header] = \array_merge($this->headers[$header], $value); |
|
77 | + } else { |
|
78 | + $new->headerNames[$normalized] = $header; |
|
79 | + $new->headers[$header] = $value; |
|
80 | + } |
|
81 | + return $new; |
|
82 | + } |
|
83 | + public function withoutHeader($header) : MessageInterface |
|
84 | + { |
|
85 | + $normalized = \strtolower($header); |
|
86 | + if (!isset($this->headerNames[$normalized])) { |
|
87 | + return $this; |
|
88 | + } |
|
89 | + $header = $this->headerNames[$normalized]; |
|
90 | + $new = clone $this; |
|
91 | + unset($new->headers[$header], $new->headerNames[$normalized]); |
|
92 | + return $new; |
|
93 | + } |
|
94 | + public function getBody() : StreamInterface |
|
95 | + { |
|
96 | + if (!$this->stream) { |
|
97 | + $this->stream = Utils::streamFor(''); |
|
98 | + } |
|
99 | + return $this->stream; |
|
100 | + } |
|
101 | + public function withBody(StreamInterface $body) : MessageInterface |
|
102 | + { |
|
103 | + if ($body === $this->stream) { |
|
104 | + return $this; |
|
105 | + } |
|
106 | + $new = clone $this; |
|
107 | + $new->stream = $body; |
|
108 | + return $new; |
|
109 | + } |
|
110 | + /** |
|
111 | + * @param (string|string[])[] $headers |
|
112 | + */ |
|
113 | + private function setHeaders(array $headers) : void |
|
114 | + { |
|
115 | + $this->headerNames = $this->headers = []; |
|
116 | + foreach ($headers as $header => $value) { |
|
117 | + // Numeric array keys are converted to int by PHP. |
|
118 | + $header = (string) $header; |
|
119 | + $this->assertHeader($header); |
|
120 | + $value = $this->normalizeHeaderValue($value); |
|
121 | + $normalized = \strtolower($header); |
|
122 | + if (isset($this->headerNames[$normalized])) { |
|
123 | + $header = $this->headerNames[$normalized]; |
|
124 | + $this->headers[$header] = \array_merge($this->headers[$header], $value); |
|
125 | + } else { |
|
126 | + $this->headerNames[$normalized] = $header; |
|
127 | + $this->headers[$header] = $value; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + /** |
|
132 | + * @param mixed $value |
|
133 | + * |
|
134 | + * @return string[] |
|
135 | + */ |
|
136 | + private function normalizeHeaderValue($value) : array |
|
137 | + { |
|
138 | + if (!\is_array($value)) { |
|
139 | + return $this->trimAndValidateHeaderValues([$value]); |
|
140 | + } |
|
141 | + if (\count($value) === 0) { |
|
142 | + throw new \InvalidArgumentException('Header value can not be an empty array.'); |
|
143 | + } |
|
144 | + return $this->trimAndValidateHeaderValues($value); |
|
145 | + } |
|
146 | + /** |
|
147 | + * Trims whitespace from the header values. |
|
148 | + * |
|
149 | + * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. |
|
150 | + * |
|
151 | + * header-field = field-name ":" OWS field-value OWS |
|
152 | + * OWS = *( SP / HTAB ) |
|
153 | + * |
|
154 | + * @param mixed[] $values Header values |
|
155 | + * |
|
156 | + * @return string[] Trimmed header values |
|
157 | + * |
|
158 | + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4 |
|
159 | + */ |
|
160 | + private function trimAndValidateHeaderValues(array $values) : array |
|
161 | + { |
|
162 | + return \array_map(function ($value) { |
|
163 | + if (!\is_scalar($value) && null !== $value) { |
|
164 | + throw new \InvalidArgumentException(\sprintf('Header value must be scalar or null but %s provided.', \is_object($value) ? \get_class($value) : \gettype($value))); |
|
165 | + } |
|
166 | + $trimmed = \trim((string) $value, " \t"); |
|
167 | + $this->assertValue($trimmed); |
|
168 | + return $trimmed; |
|
169 | + }, \array_values($values)); |
|
170 | + } |
|
171 | + /** |
|
172 | + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 |
|
173 | + * |
|
174 | + * @param mixed $header |
|
175 | + */ |
|
176 | + private function assertHeader($header) : void |
|
177 | + { |
|
178 | + if (!\is_string($header)) { |
|
179 | + throw new \InvalidArgumentException(\sprintf('Header name must be a string but %s provided.', \is_object($header) ? \get_class($header) : \gettype($header))); |
|
180 | + } |
|
181 | + if (!\preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { |
|
182 | + throw new \InvalidArgumentException(\sprintf('"%s" is not valid header name.', $header)); |
|
183 | + } |
|
184 | + } |
|
185 | + /** |
|
186 | + * @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2 |
|
187 | + * |
|
188 | + * field-value = *( field-content / obs-fold ) |
|
189 | + * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] |
|
190 | + * field-vchar = VCHAR / obs-text |
|
191 | + * VCHAR = %x21-7E |
|
192 | + * obs-text = %x80-FF |
|
193 | + * obs-fold = CRLF 1*( SP / HTAB ) |
|
194 | + */ |
|
195 | + private function assertValue(string $value) : void |
|
196 | + { |
|
197 | + // The regular expression intentionally does not support the obs-fold production, because as |
|
198 | + // per RFC 7230#3.2.4: |
|
199 | + // |
|
200 | + // A sender MUST NOT generate a message that includes |
|
201 | + // line folding (i.e., that has any field-value that contains a match to |
|
202 | + // the obs-fold rule) unless the message is intended for packaging |
|
203 | + // within the message/http media type. |
|
204 | + // |
|
205 | + // Clients must not send a request with line folding and a server sending folded headers is |
|
206 | + // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting |
|
207 | + // folding is not likely to break any legitimate use case. |
|
208 | + if (!\preg_match('/^[\\x20\\x09\\x21-\\x7E\\x80-\\xFF]*$/D', $value)) { |
|
209 | + throw new \InvalidArgumentException(\sprintf('"%s" is not valid header value.', $value)); |
|
210 | + } |
|
211 | + } |
|
212 | 212 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\MessageInterface; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->headerNames = $this->headers = []; |
116 | 116 | foreach ($headers as $header => $value) { |
117 | 117 | // Numeric array keys are converted to int by PHP. |
118 | - $header = (string) $header; |
|
118 | + $header = (string)$header; |
|
119 | 119 | $this->assertHeader($header); |
120 | 120 | $value = $this->normalizeHeaderValue($value); |
121 | 121 | $normalized = \strtolower($header); |
@@ -159,11 +159,11 @@ discard block |
||
159 | 159 | */ |
160 | 160 | private function trimAndValidateHeaderValues(array $values) : array |
161 | 161 | { |
162 | - return \array_map(function ($value) { |
|
162 | + return \array_map(function($value) { |
|
163 | 163 | if (!\is_scalar($value) && null !== $value) { |
164 | 164 | throw new \InvalidArgumentException(\sprintf('Header value must be scalar or null but %s provided.', \is_object($value) ? \get_class($value) : \gettype($value))); |
165 | 165 | } |
166 | - $trimmed = \trim((string) $value, " \t"); |
|
166 | + $trimmed = \trim((string)$value, " \t"); |
|
167 | 167 | $this->assertValue($trimmed); |
168 | 168 | return $trimmed; |
169 | 169 | }, \array_values($values)); |
@@ -8,8 +8,7 @@ |
||
8 | 8 | /** |
9 | 9 | * Trait implementing functionality common to requests and responses. |
10 | 10 | */ |
11 | -trait MessageTrait |
|
12 | -{ |
|
11 | +trait MessageTrait { |
|
13 | 12 | /** @var string[][] Map of all registered headers, as original name => array of values */ |
14 | 13 | private $headers = []; |
15 | 14 | /** @var string[] Map of lowercase header name => original name at registration */ |
@@ -5,23 +5,23 @@ |
||
5 | 5 | |
6 | 6 | final class MimeType |
7 | 7 | { |
8 | - private const MIME_TYPES = ['1km' => 'application/vnd.1000minds.decision-model+xml', '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', '3g2' => 'video/3gpp2', '3gp' => 'video/3gp', '3gpp' => 'video/3gpp', '3mf' => 'model/3mf', '7z' => 'application/x-7z-compressed', '7zip' => 'application/x-7z-compressed', '123' => 'application/vnd.lotus-1-2-3', 'aab' => 'application/x-authorware-bin', 'aac' => 'audio/aac', 'aam' => 'application/x-authorware-map', 'aas' => 'application/x-authorware-seg', 'abw' => 'application/x-abiword', 'ac' => 'application/vnd.nokia.n-gage.ac+xml', 'ac3' => 'audio/ac3', 'acc' => 'application/vnd.americandynamics.acc', 'ace' => 'application/x-ace-compressed', 'acu' => 'application/vnd.acucobol', 'acutc' => 'application/vnd.acucorp', 'adp' => 'audio/adpcm', 'adts' => 'audio/aac', 'aep' => 'application/vnd.audiograph', 'afm' => 'application/x-font-type1', 'afp' => 'application/vnd.ibm.modcap', 'age' => 'application/vnd.age', 'ahead' => 'application/vnd.ahead.space', 'ai' => 'application/pdf', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'air' => 'application/vnd.adobe.air-application-installer-package+zip', 'ait' => 'application/vnd.dvb.ait', 'ami' => 'application/vnd.amiga.ami', 'aml' => 'application/automationml-aml+xml', 'amlx' => 'application/automationml-amlx+zip', 'amr' => 'audio/amr', 'apk' => 'application/vnd.android.package-archive', 'apng' => 'image/apng', 'appcache' => 'text/cache-manifest', 'appinstaller' => 'application/appinstaller', 'application' => 'application/x-ms-application', 'appx' => 'application/appx', 'appxbundle' => 'application/appxbundle', 'apr' => 'application/vnd.lotus-approach', 'arc' => 'application/x-freearc', 'arj' => 'application/x-arj', 'asc' => 'application/pgp-signature', 'asf' => 'video/x-ms-asf', 'asm' => 'text/x-asm', 'aso' => 'application/vnd.accpac.simply.aso', 'asx' => 'video/x-ms-asf', 'atc' => 'application/vnd.acucorp', 'atom' => 'application/atom+xml', 'atomcat' => 'application/atomcat+xml', 'atomdeleted' => 'application/atomdeleted+xml', 'atomsvc' => 'application/atomsvc+xml', 'atx' => 'application/vnd.antix.game-component', 'au' => 'audio/x-au', 'avci' => 'image/avci', 'avcs' => 'image/avcs', 'avi' => 'video/x-msvideo', 'avif' => 'image/avif', 'aw' => 'application/applixware', 'azf' => 'application/vnd.airzip.filesecure.azf', 'azs' => 'application/vnd.airzip.filesecure.azs', 'azv' => 'image/vnd.airzip.accelerator.azv', 'azw' => 'application/vnd.amazon.ebook', 'b16' => 'image/vnd.pco.b16', 'bat' => 'application/x-msdownload', 'bcpio' => 'application/x-bcpio', 'bdf' => 'application/x-font-bdf', 'bdm' => 'application/vnd.syncml.dm+wbxml', 'bdoc' => 'application/x-bdoc', 'bed' => 'application/vnd.realvnc.bed', 'bh2' => 'application/vnd.fujitsu.oasysprs', 'bin' => 'application/octet-stream', 'blb' => 'application/x-blorb', 'blorb' => 'application/x-blorb', 'bmi' => 'application/vnd.bmi', 'bmml' => 'application/vnd.balsamiq.bmml+xml', 'bmp' => 'image/bmp', 'book' => 'application/vnd.framemaker', 'box' => 'application/vnd.previewsystems.box', 'boz' => 'application/x-bzip2', 'bpk' => 'application/octet-stream', 'bpmn' => 'application/octet-stream', 'bsp' => 'model/vnd.valve.source.compiled-map', 'btf' => 'image/prs.btif', 'btif' => 'image/prs.btif', 'buffer' => 'application/octet-stream', 'bz' => 'application/x-bzip', 'bz2' => 'application/x-bzip2', 'c' => 'text/x-c', 'c4d' => 'application/vnd.clonk.c4group', 'c4f' => 'application/vnd.clonk.c4group', 'c4g' => 'application/vnd.clonk.c4group', 'c4p' => 'application/vnd.clonk.c4group', 'c4u' => 'application/vnd.clonk.c4group', 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', 'cab' => 'application/vnd.ms-cab-compressed', 'caf' => 'audio/x-caf', 'cap' => 'application/vnd.tcpdump.pcap', 'car' => 'application/vnd.curl.car', 'cat' => 'application/vnd.ms-pki.seccat', 'cb7' => 'application/x-cbr', 'cba' => 'application/x-cbr', 'cbr' => 'application/x-cbr', 'cbt' => 'application/x-cbr', 'cbz' => 'application/x-cbr', 'cc' => 'text/x-c', 'cco' => 'application/x-cocoa', 'cct' => 'application/x-director', 'ccxml' => 'application/ccxml+xml', 'cdbcmsg' => 'application/vnd.contact.cmsg', 'cdf' => 'application/x-netcdf', 'cdfx' => 'application/cdfx+xml', 'cdkey' => 'application/vnd.mediastation.cdkey', 'cdmia' => 'application/cdmi-capability', 'cdmic' => 'application/cdmi-container', 'cdmid' => 'application/cdmi-domain', 'cdmio' => 'application/cdmi-object', 'cdmiq' => 'application/cdmi-queue', 'cdr' => 'application/cdr', 'cdx' => 'chemical/x-cdx', 'cdxml' => 'application/vnd.chemdraw+xml', 'cdy' => 'application/vnd.cinderella', 'cer' => 'application/pkix-cert', 'cfs' => 'application/x-cfs-compressed', 'cgm' => 'image/cgm', 'chat' => 'application/x-chat', 'chm' => 'application/vnd.ms-htmlhelp', 'chrt' => 'application/vnd.kde.kchart', 'cif' => 'chemical/x-cif', 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', 'cil' => 'application/vnd.ms-artgalry', 'cjs' => 'application/node', 'cla' => 'application/vnd.claymore', 'class' => 'application/octet-stream', 'cld' => 'model/vnd.cld', 'clkk' => 'application/vnd.crick.clicker.keyboard', 'clkp' => 'application/vnd.crick.clicker.palette', 'clkt' => 'application/vnd.crick.clicker.template', 'clkw' => 'application/vnd.crick.clicker.wordbank', 'clkx' => 'application/vnd.crick.clicker', 'clp' => 'application/x-msclip', 'cmc' => 'application/vnd.cosmocaller', 'cmdf' => 'chemical/x-cmdf', 'cml' => 'chemical/x-cml', 'cmp' => 'application/vnd.yellowriver-custom-menu', 'cmx' => 'image/x-cmx', 'cod' => 'application/vnd.rim.cod', 'coffee' => 'text/coffeescript', 'com' => 'application/x-msdownload', 'conf' => 'text/plain', 'cpio' => 'application/x-cpio', 'cpl' => 'application/cpl+xml', 'cpp' => 'text/x-c', 'cpt' => 'application/mac-compactpro', 'crd' => 'application/x-mscardfile', 'crl' => 'application/pkix-crl', 'crt' => 'application/x-x509-ca-cert', 'crx' => 'application/x-chrome-extension', 'cryptonote' => 'application/vnd.rig.cryptonote', 'csh' => 'application/x-csh', 'csl' => 'application/vnd.citationstyles.style+xml', 'csml' => 'chemical/x-csml', 'csp' => 'application/vnd.commonspace', 'csr' => 'application/octet-stream', 'css' => 'text/css', 'cst' => 'application/x-director', 'csv' => 'text/csv', 'cu' => 'application/cu-seeme', 'curl' => 'text/vnd.curl', 'cwl' => 'application/cwl', 'cww' => 'application/prs.cww', 'cxt' => 'application/x-director', 'cxx' => 'text/x-c', 'dae' => 'model/vnd.collada+xml', 'daf' => 'application/vnd.mobius.daf', 'dart' => 'application/vnd.dart', 'dataless' => 'application/vnd.fdsn.seed', 'davmount' => 'application/davmount+xml', 'dbf' => 'application/vnd.dbf', 'dbk' => 'application/docbook+xml', 'dcr' => 'application/x-director', 'dcurl' => 'text/vnd.curl.dcurl', 'dd2' => 'application/vnd.oma.dd2+xml', 'ddd' => 'application/vnd.fujixerox.ddd', 'ddf' => 'application/vnd.syncml.dmddf+xml', 'dds' => 'image/vnd.ms-dds', 'deb' => 'application/x-debian-package', 'def' => 'text/plain', 'deploy' => 'application/octet-stream', 'der' => 'application/x-x509-ca-cert', 'dfac' => 'application/vnd.dreamfactory', 'dgc' => 'application/x-dgc-compressed', 'dib' => 'image/bmp', 'dic' => 'text/x-c', 'dir' => 'application/x-director', 'dis' => 'application/vnd.mobius.dis', 'disposition-notification' => 'message/disposition-notification', 'dist' => 'application/octet-stream', 'distz' => 'application/octet-stream', 'djv' => 'image/vnd.djvu', 'djvu' => 'image/vnd.djvu', 'dll' => 'application/octet-stream', 'dmg' => 'application/x-apple-diskimage', 'dmn' => 'application/octet-stream', 'dmp' => 'application/vnd.tcpdump.pcap', 'dms' => 'application/octet-stream', 'dna' => 'application/vnd.dna', 'doc' => 'application/msword', 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dot' => 'application/msword', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dp' => 'application/vnd.osgi.dp', 'dpg' => 'application/vnd.dpgraph', 'dpx' => 'image/dpx', 'dra' => 'audio/vnd.dra', 'drle' => 'image/dicom-rle', 'dsc' => 'text/prs.lines.tag', 'dssc' => 'application/dssc+der', 'dtb' => 'application/x-dtbook+xml', 'dtd' => 'application/xml-dtd', 'dts' => 'audio/vnd.dts', 'dtshd' => 'audio/vnd.dts.hd', 'dump' => 'application/octet-stream', 'dvb' => 'video/vnd.dvb.file', 'dvi' => 'application/x-dvi', 'dwd' => 'application/atsc-dwd+xml', 'dwf' => 'model/vnd.dwf', 'dwg' => 'image/vnd.dwg', 'dxf' => 'image/vnd.dxf', 'dxp' => 'application/vnd.spotfire.dxp', 'dxr' => 'application/x-director', 'ear' => 'application/java-archive', 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', 'ecma' => 'application/ecmascript', 'edm' => 'application/vnd.novadigm.edm', 'edx' => 'application/vnd.novadigm.edx', 'efif' => 'application/vnd.picsel', 'ei6' => 'application/vnd.pg.osasli', 'elc' => 'application/octet-stream', 'emf' => 'image/emf', 'eml' => 'message/rfc822', 'emma' => 'application/emma+xml', 'emotionml' => 'application/emotionml+xml', 'emz' => 'application/x-msmetafile', 'eol' => 'audio/vnd.digital-winds', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript', 'epub' => 'application/epub+zip', 'es3' => 'application/vnd.eszigno3+xml', 'esa' => 'application/vnd.osgi.subsystem', 'esf' => 'application/vnd.epson.esf', 'et3' => 'application/vnd.eszigno3+xml', 'etx' => 'text/x-setext', 'eva' => 'application/x-eva', 'evy' => 'application/x-envoy', 'exe' => 'application/octet-stream', 'exi' => 'application/exi', 'exp' => 'application/express', 'exr' => 'image/aces', 'ext' => 'application/vnd.novadigm.ext', 'ez' => 'application/andrew-inset', 'ez2' => 'application/vnd.ezpix-album', 'ez3' => 'application/vnd.ezpix-package', 'f' => 'text/x-fortran', 'f4v' => 'video/mp4', 'f77' => 'text/x-fortran', 'f90' => 'text/x-fortran', 'fbs' => 'image/vnd.fastbidsheet', 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', 'fcs' => 'application/vnd.isac.fcs', 'fdf' => 'application/vnd.fdf', 'fdt' => 'application/fdt+xml', 'fe_launch' => 'application/vnd.denovo.fcselayout-link', 'fg5' => 'application/vnd.fujitsu.oasysgp', 'fgd' => 'application/x-director', 'fh' => 'image/x-freehand', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fh7' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'fig' => 'application/x-xfig', 'fits' => 'image/fits', 'flac' => 'audio/x-flac', 'fli' => 'video/x-fli', 'flo' => 'application/vnd.micrografx.flo', 'flv' => 'video/x-flv', 'flw' => 'application/vnd.kde.kivio', 'flx' => 'text/vnd.fmi.flexstor', 'fly' => 'text/vnd.fly', 'fm' => 'application/vnd.framemaker', 'fnc' => 'application/vnd.frogans.fnc', 'fo' => 'application/vnd.software602.filler.form+xml', 'for' => 'text/x-fortran', 'fpx' => 'image/vnd.fpx', 'frame' => 'application/vnd.framemaker', 'fsc' => 'application/vnd.fsc.weblaunch', 'fst' => 'image/vnd.fst', 'ftc' => 'application/vnd.fluxtime.clip', 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', 'fvt' => 'video/vnd.fvt', 'fxp' => 'application/vnd.adobe.fxp', 'fxpl' => 'application/vnd.adobe.fxp', 'fzs' => 'application/vnd.fuzzysheet', 'g2w' => 'application/vnd.geoplan', 'g3' => 'image/g3fax', 'g3w' => 'application/vnd.geospace', 'gac' => 'application/vnd.groove-account', 'gam' => 'application/x-tads', 'gbr' => 'application/rpki-ghostbusters', 'gca' => 'application/x-gca-compressed', 'gdl' => 'model/vnd.gdl', 'gdoc' => 'application/vnd.google-apps.document', 'ged' => 'text/vnd.familysearch.gedcom', 'geo' => 'application/vnd.dynageo', 'geojson' => 'application/geo+json', 'gex' => 'application/vnd.geometry-explorer', 'ggb' => 'application/vnd.geogebra.file', 'ggt' => 'application/vnd.geogebra.tool', 'ghf' => 'application/vnd.groove-help', 'gif' => 'image/gif', 'gim' => 'application/vnd.groove-identity-message', 'glb' => 'model/gltf-binary', 'gltf' => 'model/gltf+json', 'gml' => 'application/gml+xml', 'gmx' => 'application/vnd.gmx', 'gnumeric' => 'application/x-gnumeric', 'gpg' => 'application/gpg-keys', 'gph' => 'application/vnd.flographit', 'gpx' => 'application/gpx+xml', 'gqf' => 'application/vnd.grafeq', 'gqs' => 'application/vnd.grafeq', 'gram' => 'application/srgs', 'gramps' => 'application/x-gramps-xml', 'gre' => 'application/vnd.geometry-explorer', 'grv' => 'application/vnd.groove-injector', 'grxml' => 'application/srgs+xml', 'gsf' => 'application/x-font-ghostscript', 'gsheet' => 'application/vnd.google-apps.spreadsheet', 'gslides' => 'application/vnd.google-apps.presentation', 'gtar' => 'application/x-gtar', 'gtm' => 'application/vnd.groove-tool-message', 'gtw' => 'model/vnd.gtw', 'gv' => 'text/vnd.graphviz', 'gxf' => 'application/gxf', 'gxt' => 'application/vnd.geonext', 'gz' => 'application/gzip', 'gzip' => 'application/gzip', 'h' => 'text/x-c', 'h261' => 'video/h261', 'h263' => 'video/h263', 'h264' => 'video/h264', 'hal' => 'application/vnd.hal+xml', 'hbci' => 'application/vnd.hbci', 'hbs' => 'text/x-handlebars-template', 'hdd' => 'application/x-virtualbox-hdd', 'hdf' => 'application/x-hdf', 'heic' => 'image/heic', 'heics' => 'image/heic-sequence', 'heif' => 'image/heif', 'heifs' => 'image/heif-sequence', 'hej2' => 'image/hej2k', 'held' => 'application/atsc-held+xml', 'hh' => 'text/x-c', 'hjson' => 'application/hjson', 'hlp' => 'application/winhlp', 'hpgl' => 'application/vnd.hp-hpgl', 'hpid' => 'application/vnd.hp-hpid', 'hps' => 'application/vnd.hp-hps', 'hqx' => 'application/mac-binhex40', 'hsj2' => 'image/hsj2', 'htc' => 'text/x-component', 'htke' => 'application/vnd.kenameaapp', 'htm' => 'text/html', 'html' => 'text/html', 'hvd' => 'application/vnd.yamaha.hv-dic', 'hvp' => 'application/vnd.yamaha.hv-voice', 'hvs' => 'application/vnd.yamaha.hv-script', 'i2g' => 'application/vnd.intergeo', 'icc' => 'application/vnd.iccprofile', 'ice' => 'x-conference/x-cooltalk', 'icm' => 'application/vnd.iccprofile', 'ico' => 'image/x-icon', 'ics' => 'text/calendar', 'ief' => 'image/ief', 'ifb' => 'text/calendar', 'ifm' => 'application/vnd.shana.informed.formdata', 'iges' => 'model/iges', 'igl' => 'application/vnd.igloader', 'igm' => 'application/vnd.insors.igm', 'igs' => 'model/iges', 'igx' => 'application/vnd.micrografx.igx', 'iif' => 'application/vnd.shana.informed.interchange', 'img' => 'application/octet-stream', 'imp' => 'application/vnd.accpac.simply.imp', 'ims' => 'application/vnd.ms-ims', 'in' => 'text/plain', 'ini' => 'text/plain', 'ink' => 'application/inkml+xml', 'inkml' => 'application/inkml+xml', 'install' => 'application/x-install-instructions', 'iota' => 'application/vnd.astraea-software.iota', 'ipfix' => 'application/ipfix', 'ipk' => 'application/vnd.shana.informed.package', 'irm' => 'application/vnd.ibm.rights-management', 'irp' => 'application/vnd.irepository.package+xml', 'iso' => 'application/x-iso9660-image', 'itp' => 'application/vnd.shana.informed.formtemplate', 'its' => 'application/its+xml', 'ivp' => 'application/vnd.immervision-ivp', 'ivu' => 'application/vnd.immervision-ivu', 'jad' => 'text/vnd.sun.j2me.app-descriptor', 'jade' => 'text/jade', 'jam' => 'application/vnd.jam', 'jar' => 'application/java-archive', 'jardiff' => 'application/x-java-archive-diff', 'java' => 'text/x-java-source', 'jhc' => 'image/jphc', 'jisp' => 'application/vnd.jisp', 'jls' => 'image/jls', 'jlt' => 'application/vnd.hp-jlyt', 'jng' => 'image/x-jng', 'jnlp' => 'application/x-java-jnlp-file', 'joda' => 'application/vnd.joost.joda-archive', 'jp2' => 'image/jp2', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpf' => 'image/jpx', 'jpg' => 'image/jpeg', 'jpg2' => 'image/jp2', 'jpgm' => 'video/jpm', 'jpgv' => 'video/jpeg', 'jph' => 'image/jph', 'jpm' => 'video/jpm', 'jpx' => 'image/jpx', 'js' => 'application/javascript', 'json' => 'application/json', 'json5' => 'application/json5', 'jsonld' => 'application/ld+json', 'jsonml' => 'application/jsonml+json', 'jsx' => 'text/jsx', 'jt' => 'model/jt', 'jxr' => 'image/jxr', 'jxra' => 'image/jxra', 'jxrs' => 'image/jxrs', 'jxs' => 'image/jxs', 'jxsc' => 'image/jxsc', 'jxsi' => 'image/jxsi', 'jxss' => 'image/jxss', 'kar' => 'audio/midi', 'karbon' => 'application/vnd.kde.karbon', 'kdb' => 'application/octet-stream', 'kdbx' => 'application/x-keepass2', 'key' => 'application/x-iwork-keynote-sffkey', 'kfo' => 'application/vnd.kde.kformula', 'kia' => 'application/vnd.kidspiration', 'kml' => 'application/vnd.google-earth.kml+xml', 'kmz' => 'application/vnd.google-earth.kmz', 'kne' => 'application/vnd.kinar', 'knp' => 'application/vnd.kinar', 'kon' => 'application/vnd.kde.kontour', 'kpr' => 'application/vnd.kde.kpresenter', 'kpt' => 'application/vnd.kde.kpresenter', 'kpxx' => 'application/vnd.ds-keypoint', 'ksp' => 'application/vnd.kde.kspread', 'ktr' => 'application/vnd.kahootz', 'ktx' => 'image/ktx', 'ktx2' => 'image/ktx2', 'ktz' => 'application/vnd.kahootz', 'kwd' => 'application/vnd.kde.kword', 'kwt' => 'application/vnd.kde.kword', 'lasxml' => 'application/vnd.las.las+xml', 'latex' => 'application/x-latex', 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', 'les' => 'application/vnd.hhe.lesson-player', 'less' => 'text/less', 'lgr' => 'application/lgr+xml', 'lha' => 'application/octet-stream', 'link66' => 'application/vnd.route66.link66+xml', 'list' => 'text/plain', 'list3820' => 'application/vnd.ibm.modcap', 'listafp' => 'application/vnd.ibm.modcap', 'litcoffee' => 'text/coffeescript', 'lnk' => 'application/x-ms-shortcut', 'log' => 'text/plain', 'lostxml' => 'application/lost+xml', 'lrf' => 'application/octet-stream', 'lrm' => 'application/vnd.ms-lrm', 'ltf' => 'application/vnd.frogans.ltf', 'lua' => 'text/x-lua', 'luac' => 'application/x-lua-bytecode', 'lvp' => 'audio/vnd.lucent.voice', 'lwp' => 'application/vnd.lotus-wordpro', 'lzh' => 'application/octet-stream', 'm1v' => 'video/mpeg', 'm2a' => 'audio/mpeg', 'm2v' => 'video/mpeg', 'm3a' => 'audio/mpeg', 'm3u' => 'text/plain', 'm3u8' => 'application/vnd.apple.mpegurl', 'm4a' => 'audio/x-m4a', 'm4p' => 'application/mp4', 'm4s' => 'video/iso.segment', 'm4u' => 'application/vnd.mpegurl', 'm4v' => 'video/x-m4v', 'm13' => 'application/x-msmediaview', 'm14' => 'application/x-msmediaview', 'm21' => 'application/mp21', 'ma' => 'application/mathematica', 'mads' => 'application/mads+xml', 'maei' => 'application/mmt-aei+xml', 'mag' => 'application/vnd.ecowin.chart', 'maker' => 'application/vnd.framemaker', 'man' => 'text/troff', 'manifest' => 'text/cache-manifest', 'map' => 'application/json', 'mar' => 'application/octet-stream', 'markdown' => 'text/markdown', 'mathml' => 'application/mathml+xml', 'mb' => 'application/mathematica', 'mbk' => 'application/vnd.mobius.mbk', 'mbox' => 'application/mbox', 'mc1' => 'application/vnd.medcalcdata', 'mcd' => 'application/vnd.mcd', 'mcurl' => 'text/vnd.curl.mcurl', 'md' => 'text/markdown', 'mdb' => 'application/x-msaccess', 'mdi' => 'image/vnd.ms-modi', 'mdx' => 'text/mdx', 'me' => 'text/troff', 'mesh' => 'model/mesh', 'meta4' => 'application/metalink4+xml', 'metalink' => 'application/metalink+xml', 'mets' => 'application/mets+xml', 'mfm' => 'application/vnd.mfmp', 'mft' => 'application/rpki-manifest', 'mgp' => 'application/vnd.osgeo.mapguide.package', 'mgz' => 'application/vnd.proteus.magazine', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mie' => 'application/x-mie', 'mif' => 'application/vnd.mif', 'mime' => 'message/rfc822', 'mj2' => 'video/mj2', 'mjp2' => 'video/mj2', 'mjs' => 'text/javascript', 'mk3d' => 'video/x-matroska', 'mka' => 'audio/x-matroska', 'mkd' => 'text/x-markdown', 'mks' => 'video/x-matroska', 'mkv' => 'video/x-matroska', 'mlp' => 'application/vnd.dolby.mlp', 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', 'mmf' => 'application/vnd.smaf', 'mml' => 'text/mathml', 'mmr' => 'image/vnd.fujixerox.edmics-mmr', 'mng' => 'video/x-mng', 'mny' => 'application/x-msmoney', 'mobi' => 'application/x-mobipocket-ebook', 'mods' => 'application/mods+xml', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp2a' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'mp4a' => 'audio/mp4', 'mp4s' => 'application/mp4', 'mp4v' => 'video/mp4', 'mp21' => 'application/mp21', 'mpc' => 'application/vnd.mophun.certificate', 'mpd' => 'application/dash+xml', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpf' => 'application/media-policy-dataset+xml', 'mpg' => 'video/mpeg', 'mpg4' => 'video/mp4', 'mpga' => 'audio/mpeg', 'mpkg' => 'application/vnd.apple.installer+xml', 'mpm' => 'application/vnd.blueice.multipass', 'mpn' => 'application/vnd.mophun.application', 'mpp' => 'application/vnd.ms-project', 'mpt' => 'application/vnd.ms-project', 'mpy' => 'application/vnd.ibm.minipay', 'mqy' => 'application/vnd.mobius.mqy', 'mrc' => 'application/marc', 'mrcx' => 'application/marcxml+xml', 'ms' => 'text/troff', 'mscml' => 'application/mediaservercontrol+xml', 'mseed' => 'application/vnd.fdsn.mseed', 'mseq' => 'application/vnd.mseq', 'msf' => 'application/vnd.epson.msf', 'msg' => 'application/vnd.ms-outlook', 'msh' => 'model/mesh', 'msi' => 'application/x-msdownload', 'msix' => 'application/msix', 'msixbundle' => 'application/msixbundle', 'msl' => 'application/vnd.mobius.msl', 'msm' => 'application/octet-stream', 'msp' => 'application/octet-stream', 'msty' => 'application/vnd.muvee.style', 'mtl' => 'model/mtl', 'mts' => 'model/vnd.mts', 'mus' => 'application/vnd.musician', 'musd' => 'application/mmt-usd+xml', 'musicxml' => 'application/vnd.recordare.musicxml+xml', 'mvb' => 'application/x-msmediaview', 'mvt' => 'application/vnd.mapbox-vector-tile', 'mwf' => 'application/vnd.mfer', 'mxf' => 'application/mxf', 'mxl' => 'application/vnd.recordare.musicxml', 'mxmf' => 'audio/mobile-xmf', 'mxml' => 'application/xv+xml', 'mxs' => 'application/vnd.triscape.mxs', 'mxu' => 'video/vnd.mpegurl', 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', 'n3' => 'text/n3', 'nb' => 'application/mathematica', 'nbp' => 'application/vnd.wolfram.player', 'nc' => 'application/x-netcdf', 'ncx' => 'application/x-dtbncx+xml', 'nfo' => 'text/x-nfo', 'ngdat' => 'application/vnd.nokia.n-gage.data', 'nitf' => 'application/vnd.nitf', 'nlu' => 'application/vnd.neurolanguage.nlu', 'nml' => 'application/vnd.enliven', 'nnd' => 'application/vnd.noblenet-directory', 'nns' => 'application/vnd.noblenet-sealer', 'nnw' => 'application/vnd.noblenet-web', 'npx' => 'image/vnd.net-fpx', 'nq' => 'application/n-quads', 'nsc' => 'application/x-conference', 'nsf' => 'application/vnd.lotus-notes', 'nt' => 'application/n-triples', 'ntf' => 'application/vnd.nitf', 'numbers' => 'application/x-iwork-numbers-sffnumbers', 'nzb' => 'application/x-nzb', 'oa2' => 'application/vnd.fujitsu.oasys2', 'oa3' => 'application/vnd.fujitsu.oasys3', 'oas' => 'application/vnd.fujitsu.oasys', 'obd' => 'application/x-msbinder', 'obgx' => 'application/vnd.openblox.game+xml', 'obj' => 'model/obj', 'oda' => 'application/oda', 'odb' => 'application/vnd.oasis.opendocument.database', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odft' => 'application/vnd.oasis.opendocument.formula-template', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odt' => 'application/vnd.oasis.opendocument.text', 'oga' => 'audio/ogg', 'ogex' => 'model/vnd.opengex', 'ogg' => 'audio/ogg', 'ogv' => 'video/ogg', 'ogx' => 'application/ogg', 'omdoc' => 'application/omdoc+xml', 'onepkg' => 'application/onenote', 'onetmp' => 'application/onenote', 'onetoc' => 'application/onenote', 'onetoc2' => 'application/onenote', 'opf' => 'application/oebps-package+xml', 'opml' => 'text/x-opml', 'oprc' => 'application/vnd.palm', 'opus' => 'audio/ogg', 'org' => 'text/x-org', 'osf' => 'application/vnd.yamaha.openscoreformat', 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', 'osm' => 'application/vnd.openstreetmap.data+xml', 'otc' => 'application/vnd.oasis.opendocument.chart-template', 'otf' => 'font/otf', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'oth' => 'application/vnd.oasis.opendocument.text-web', 'oti' => 'application/vnd.oasis.opendocument.image-template', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'ova' => 'application/x-virtualbox-ova', 'ovf' => 'application/x-virtualbox-ovf', 'owl' => 'application/rdf+xml', 'oxps' => 'application/oxps', 'oxt' => 'application/vnd.openofficeorg.extension', 'p' => 'text/x-pascal', 'p7a' => 'application/x-pkcs7-signature', 'p7b' => 'application/x-pkcs7-certificates', 'p7c' => 'application/pkcs7-mime', 'p7m' => 'application/pkcs7-mime', 'p7r' => 'application/x-pkcs7-certreqresp', 'p7s' => 'application/pkcs7-signature', 'p8' => 'application/pkcs8', 'p10' => 'application/x-pkcs10', 'p12' => 'application/x-pkcs12', 'pac' => 'application/x-ns-proxy-autoconfig', 'pages' => 'application/x-iwork-pages-sffpages', 'pas' => 'text/x-pascal', 'paw' => 'application/vnd.pawaafile', 'pbd' => 'application/vnd.powerbuilder6', 'pbm' => 'image/x-portable-bitmap', 'pcap' => 'application/vnd.tcpdump.pcap', 'pcf' => 'application/x-font-pcf', 'pcl' => 'application/vnd.hp-pcl', 'pclxl' => 'application/vnd.hp-pclxl', 'pct' => 'image/x-pict', 'pcurl' => 'application/vnd.curl.pcurl', 'pcx' => 'image/x-pcx', 'pdb' => 'application/x-pilot', 'pde' => 'text/x-processing', 'pdf' => 'application/pdf', 'pem' => 'application/x-x509-user-cert', 'pfa' => 'application/x-font-type1', 'pfb' => 'application/x-font-type1', 'pfm' => 'application/x-font-type1', 'pfr' => 'application/font-tdpfr', 'pfx' => 'application/x-pkcs12', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'pgp' => 'application/pgp', 'phar' => 'application/octet-stream', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'phtml' => 'application/x-httpd-php', 'pic' => 'image/x-pict', 'pkg' => 'application/octet-stream', 'pki' => 'application/pkixcmp', 'pkipath' => 'application/pkix-pkipath', 'pkpass' => 'application/vnd.apple.pkpass', 'pl' => 'application/x-perl', 'plb' => 'application/vnd.3gpp.pic-bw-large', 'plc' => 'application/vnd.mobius.plc', 'plf' => 'application/vnd.pocketlearn', 'pls' => 'application/pls+xml', 'pm' => 'application/x-perl', 'pml' => 'application/vnd.ctc-posml', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'portpkg' => 'application/vnd.macports.portpkg', 'pot' => 'application/vnd.ms-powerpoint', 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppa' => 'application/vnd.ms-powerpoint', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'ppd' => 'application/vnd.cups-ppd', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/vnd.ms-powerpoint', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppt' => 'application/powerpoint', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pqa' => 'application/vnd.palm', 'prc' => 'model/prc', 'pre' => 'application/vnd.lotus-freelance', 'prf' => 'application/pics-rules', 'provx' => 'application/provenance+xml', 'ps' => 'application/postscript', 'psb' => 'application/vnd.3gpp.pic-bw-small', 'psd' => 'application/x-photoshop', 'psf' => 'application/x-font-linux-psf', 'pskcxml' => 'application/pskc+xml', 'pti' => 'image/prs.pti', 'ptid' => 'application/vnd.pvi.ptid1', 'pub' => 'application/x-mspublisher', 'pvb' => 'application/vnd.3gpp.pic-bw-var', 'pwn' => 'application/vnd.3m.post-it-notes', 'pya' => 'audio/vnd.ms-playready.media.pya', 'pyo' => 'model/vnd.pytha.pyox', 'pyox' => 'model/vnd.pytha.pyox', 'pyv' => 'video/vnd.ms-playready.media.pyv', 'qam' => 'application/vnd.epson.quickanime', 'qbo' => 'application/vnd.intu.qbo', 'qfx' => 'application/vnd.intu.qfx', 'qps' => 'application/vnd.publishare-delta-tree', 'qt' => 'video/quicktime', 'qwd' => 'application/vnd.quark.quarkxpress', 'qwt' => 'application/vnd.quark.quarkxpress', 'qxb' => 'application/vnd.quark.quarkxpress', 'qxd' => 'application/vnd.quark.quarkxpress', 'qxl' => 'application/vnd.quark.quarkxpress', 'qxt' => 'application/vnd.quark.quarkxpress', 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'raml' => 'application/raml+yaml', 'rapd' => 'application/route-apd+xml', 'rar' => 'application/x-rar', 'ras' => 'image/x-cmu-raster', 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', 'rdf' => 'application/rdf+xml', 'rdz' => 'application/vnd.data-vision.rdz', 'relo' => 'application/p2p-overlay+xml', 'rep' => 'application/vnd.businessobjects', 'res' => 'application/x-dtbresource+xml', 'rgb' => 'image/x-rgb', 'rif' => 'application/reginfo+xml', 'rip' => 'audio/vnd.rip', 'ris' => 'application/x-research-info-systems', 'rl' => 'application/resource-lists+xml', 'rlc' => 'image/vnd.fujixerox.edmics-rlc', 'rld' => 'application/resource-lists-diff+xml', 'rm' => 'audio/x-pn-realaudio', 'rmi' => 'audio/midi', 'rmp' => 'audio/x-pn-realaudio-plugin', 'rms' => 'application/vnd.jcp.javame.midlet-rms', 'rmvb' => 'application/vnd.rn-realmedia-vbr', 'rnc' => 'application/relax-ng-compact-syntax', 'rng' => 'application/xml', 'roa' => 'application/rpki-roa', 'roff' => 'text/troff', 'rp9' => 'application/vnd.cloanto.rp9', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rpss' => 'application/vnd.nokia.radio-presets', 'rpst' => 'application/vnd.nokia.radio-preset', 'rq' => 'application/sparql-query', 'rs' => 'application/rls-services+xml', 'rsa' => 'application/x-pkcs7', 'rsat' => 'application/atsc-rsat+xml', 'rsd' => 'application/rsd+xml', 'rsheet' => 'application/urc-ressheet+xml', 'rss' => 'application/rss+xml', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'run' => 'application/x-makeself', 'rusd' => 'application/route-usd+xml', 'rv' => 'video/vnd.rn-realvideo', 's' => 'text/x-asm', 's3m' => 'audio/s3m', 'saf' => 'application/vnd.yamaha.smaf-audio', 'sass' => 'text/x-sass', 'sbml' => 'application/sbml+xml', 'sc' => 'application/vnd.ibm.secure-container', 'scd' => 'application/x-msschedule', 'scm' => 'application/vnd.lotus-screencam', 'scq' => 'application/scvp-cv-request', 'scs' => 'application/scvp-cv-response', 'scss' => 'text/x-scss', 'scurl' => 'text/vnd.curl.scurl', 'sda' => 'application/vnd.stardivision.draw', 'sdc' => 'application/vnd.stardivision.calc', 'sdd' => 'application/vnd.stardivision.impress', 'sdkd' => 'application/vnd.solent.sdkm+xml', 'sdkm' => 'application/vnd.solent.sdkm+xml', 'sdp' => 'application/sdp', 'sdw' => 'application/vnd.stardivision.writer', 'sea' => 'application/octet-stream', 'see' => 'application/vnd.seemail', 'seed' => 'application/vnd.fdsn.seed', 'sema' => 'application/vnd.sema', 'semd' => 'application/vnd.semd', 'semf' => 'application/vnd.semf', 'senmlx' => 'application/senml+xml', 'sensmlx' => 'application/sensml+xml', 'ser' => 'application/java-serialized-object', 'setpay' => 'application/set-payment-initiation', 'setreg' => 'application/set-registration-initiation', 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', 'sfs' => 'application/vnd.spotfire.sfs', 'sfv' => 'text/x-sfv', 'sgi' => 'image/sgi', 'sgl' => 'application/vnd.stardivision.writer-global', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'shex' => 'text/shex', 'shf' => 'application/shf+xml', 'shtml' => 'text/html', 'sid' => 'image/x-mrsid-image', 'sieve' => 'application/sieve', 'sig' => 'application/pgp-signature', 'sil' => 'audio/silk', 'silo' => 'model/mesh', 'sis' => 'application/vnd.symbian.install', 'sisx' => 'application/vnd.symbian.install', 'sit' => 'application/x-stuffit', 'sitx' => 'application/x-stuffitx', 'siv' => 'application/sieve', 'skd' => 'application/vnd.koan', 'skm' => 'application/vnd.koan', 'skp' => 'application/vnd.koan', 'skt' => 'application/vnd.koan', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'slim' => 'text/slim', 'slm' => 'text/slim', 'sls' => 'application/route-s-tsid+xml', 'slt' => 'application/vnd.epson.salt', 'sm' => 'application/vnd.stepmania.stepchart', 'smf' => 'application/vnd.stardivision.math', 'smi' => 'application/smil', 'smil' => 'application/smil', 'smv' => 'video/x-smv', 'smzip' => 'application/vnd.stepmania.package', 'snd' => 'audio/basic', 'snf' => 'application/x-font-snf', 'so' => 'application/octet-stream', 'spc' => 'application/x-pkcs7-certificates', 'spdx' => 'text/spdx', 'spf' => 'application/vnd.yamaha.smaf-phrase', 'spl' => 'application/x-futuresplash', 'spot' => 'text/vnd.in3d.spot', 'spp' => 'application/scvp-vp-response', 'spq' => 'application/scvp-vp-request', 'spx' => 'audio/ogg', 'sql' => 'application/x-sql', 'src' => 'application/x-wais-source', 'srt' => 'application/x-subrip', 'sru' => 'application/sru+xml', 'srx' => 'application/sparql-results+xml', 'ssdl' => 'application/ssdl+xml', 'sse' => 'application/vnd.kodak-descriptor', 'ssf' => 'application/vnd.epson.ssf', 'ssml' => 'application/ssml+xml', 'sst' => 'application/octet-stream', 'st' => 'application/vnd.sailingtracker.track', 'stc' => 'application/vnd.sun.xml.calc.template', 'std' => 'application/vnd.sun.xml.draw.template', 'step' => 'application/STEP', 'stf' => 'application/vnd.wt.stf', 'sti' => 'application/vnd.sun.xml.impress.template', 'stk' => 'application/hyperstudio', 'stl' => 'model/stl', 'stp' => 'application/STEP', 'stpx' => 'model/step+xml', 'stpxz' => 'model/step-xml+zip', 'stpz' => 'model/step+zip', 'str' => 'application/vnd.pg.format', 'stw' => 'application/vnd.sun.xml.writer.template', 'styl' => 'text/stylus', 'stylus' => 'text/stylus', 'sub' => 'text/vnd.dvb.subtitle', 'sus' => 'application/vnd.sus-calendar', 'susp' => 'application/vnd.sus-calendar', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'svc' => 'application/vnd.dvb.service', 'svd' => 'application/vnd.svd', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'swa' => 'application/x-director', 'swf' => 'application/x-shockwave-flash', 'swi' => 'application/vnd.aristanetworks.swi', 'swidtag' => 'application/swid+xml', 'sxc' => 'application/vnd.sun.xml.calc', 'sxd' => 'application/vnd.sun.xml.draw', 'sxg' => 'application/vnd.sun.xml.writer.global', 'sxi' => 'application/vnd.sun.xml.impress', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 't' => 'text/troff', 't3' => 'application/x-t3vm-image', 't38' => 'image/t38', 'taglet' => 'application/vnd.mynfc', 'tao' => 'application/vnd.tao.intent-module-archive', 'tap' => 'image/vnd.tencent.tap', 'tar' => 'application/x-tar', 'tcap' => 'application/vnd.3gpp2.tcap', 'tcl' => 'application/x-tcl', 'td' => 'application/urc-targetdesc+xml', 'teacher' => 'application/vnd.smart.teacher', 'tei' => 'application/tei+xml', 'teicorpus' => 'application/tei+xml', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'text' => 'text/plain', 'tfi' => 'application/thraud+xml', 'tfm' => 'application/x-tex-tfm', 'tfx' => 'image/tiff-fx', 'tga' => 'image/x-tga', 'tgz' => 'application/x-tar', 'thmx' => 'application/vnd.ms-officetheme', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tk' => 'application/x-tcl', 'tmo' => 'application/vnd.tmobile-livetv', 'toml' => 'application/toml', 'torrent' => 'application/x-bittorrent', 'tpl' => 'application/vnd.groove-tool-template', 'tpt' => 'application/vnd.trid.tpt', 'tr' => 'text/troff', 'tra' => 'application/vnd.trueapp', 'trig' => 'application/trig', 'trm' => 'application/x-msterminal', 'ts' => 'video/mp2t', 'tsd' => 'application/timestamped-data', 'tsv' => 'text/tab-separated-values', 'ttc' => 'font/collection', 'ttf' => 'font/ttf', 'ttl' => 'text/turtle', 'ttml' => 'application/ttml+xml', 'twd' => 'application/vnd.simtech-mindmapper', 'twds' => 'application/vnd.simtech-mindmapper', 'txd' => 'application/vnd.genomatix.tuxedo', 'txf' => 'application/vnd.mobius.txf', 'txt' => 'text/plain', 'u3d' => 'model/u3d', 'u8dsn' => 'message/global-delivery-status', 'u8hdr' => 'message/global-headers', 'u8mdn' => 'message/global-disposition-notification', 'u8msg' => 'message/global', 'u32' => 'application/x-authorware-bin', 'ubj' => 'application/ubjson', 'udeb' => 'application/x-debian-package', 'ufd' => 'application/vnd.ufdl', 'ufdl' => 'application/vnd.ufdl', 'ulx' => 'application/x-glulx', 'umj' => 'application/vnd.umajin', 'unityweb' => 'application/vnd.unity', 'uo' => 'application/vnd.uoml+xml', 'uoml' => 'application/vnd.uoml+xml', 'uri' => 'text/uri-list', 'uris' => 'text/uri-list', 'urls' => 'text/uri-list', 'usda' => 'model/vnd.usda', 'usdz' => 'model/vnd.usdz+zip', 'ustar' => 'application/x-ustar', 'utz' => 'application/vnd.uiq.theme', 'uu' => 'text/x-uuencode', 'uva' => 'audio/vnd.dece.audio', 'uvd' => 'application/vnd.dece.data', 'uvf' => 'application/vnd.dece.data', 'uvg' => 'image/vnd.dece.graphic', 'uvh' => 'video/vnd.dece.hd', 'uvi' => 'image/vnd.dece.graphic', 'uvm' => 'video/vnd.dece.mobile', 'uvp' => 'video/vnd.dece.pd', 'uvs' => 'video/vnd.dece.sd', 'uvt' => 'application/vnd.dece.ttml+xml', 'uvu' => 'video/vnd.uvvu.mp4', 'uvv' => 'video/vnd.dece.video', 'uvva' => 'audio/vnd.dece.audio', 'uvvd' => 'application/vnd.dece.data', 'uvvf' => 'application/vnd.dece.data', 'uvvg' => 'image/vnd.dece.graphic', 'uvvh' => 'video/vnd.dece.hd', 'uvvi' => 'image/vnd.dece.graphic', 'uvvm' => 'video/vnd.dece.mobile', 'uvvp' => 'video/vnd.dece.pd', 'uvvs' => 'video/vnd.dece.sd', 'uvvt' => 'application/vnd.dece.ttml+xml', 'uvvu' => 'video/vnd.uvvu.mp4', 'uvvv' => 'video/vnd.dece.video', 'uvvx' => 'application/vnd.dece.unspecified', 'uvvz' => 'application/vnd.dece.zip', 'uvx' => 'application/vnd.dece.unspecified', 'uvz' => 'application/vnd.dece.zip', 'vbox' => 'application/x-virtualbox-vbox', 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', 'vcard' => 'text/vcard', 'vcd' => 'application/x-cdlink', 'vcf' => 'text/x-vcard', 'vcg' => 'application/vnd.groove-vcard', 'vcs' => 'text/x-vcalendar', 'vcx' => 'application/vnd.vcx', 'vdi' => 'application/x-virtualbox-vdi', 'vds' => 'model/vnd.sap.vds', 'vhd' => 'application/x-virtualbox-vhd', 'vis' => 'application/vnd.visionary', 'viv' => 'video/vnd.vivo', 'vlc' => 'application/videolan', 'vmdk' => 'application/x-virtualbox-vmdk', 'vob' => 'video/x-ms-vob', 'vor' => 'application/vnd.stardivision.writer', 'vox' => 'application/x-authorware-bin', 'vrml' => 'model/vrml', 'vsd' => 'application/vnd.visio', 'vsf' => 'application/vnd.vsf', 'vss' => 'application/vnd.visio', 'vst' => 'application/vnd.visio', 'vsw' => 'application/vnd.visio', 'vtf' => 'image/vnd.valve.source.texture', 'vtt' => 'text/vtt', 'vtu' => 'model/vnd.vtu', 'vxml' => 'application/voicexml+xml', 'w3d' => 'application/x-director', 'wad' => 'application/x-doom', 'wadl' => 'application/vnd.sun.wadl+xml', 'war' => 'application/java-archive', 'wasm' => 'application/wasm', 'wav' => 'audio/x-wav', 'wax' => 'audio/x-ms-wax', 'wbmp' => 'image/vnd.wap.wbmp', 'wbs' => 'application/vnd.criticaltools.wbs+xml', 'wbxml' => 'application/wbxml', 'wcm' => 'application/vnd.ms-works', 'wdb' => 'application/vnd.ms-works', 'wdp' => 'image/vnd.ms-photo', 'weba' => 'audio/webm', 'webapp' => 'application/x-web-app-manifest+json', 'webm' => 'video/webm', 'webmanifest' => 'application/manifest+json', 'webp' => 'image/webp', 'wg' => 'application/vnd.pmi.widget', 'wgsl' => 'text/wgsl', 'wgt' => 'application/widget', 'wif' => 'application/watcherinfo+xml', 'wks' => 'application/vnd.ms-works', 'wm' => 'video/x-ms-wm', 'wma' => 'audio/x-ms-wma', 'wmd' => 'application/x-ms-wmd', 'wmf' => 'image/wmf', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wmz' => 'application/x-msmetafile', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'word' => 'application/msword', 'wpd' => 'application/vnd.wordperfect', 'wpl' => 'application/vnd.ms-wpl', 'wps' => 'application/vnd.ms-works', 'wqd' => 'application/vnd.wqd', 'wri' => 'application/x-mswrite', 'wrl' => 'model/vrml', 'wsc' => 'message/vnd.wfa.wsc', 'wsdl' => 'application/wsdl+xml', 'wspolicy' => 'application/wspolicy+xml', 'wtb' => 'application/vnd.webturbo', 'wvx' => 'video/x-ms-wvx', 'x3d' => 'model/x3d+xml', 'x3db' => 'model/x3d+fastinfoset', 'x3dbz' => 'model/x3d+binary', 'x3dv' => 'model/x3d-vrml', 'x3dvz' => 'model/x3d+vrml', 'x3dz' => 'model/x3d+xml', 'x32' => 'application/x-authorware-bin', 'x_b' => 'model/vnd.parasolid.transmit.binary', 'x_t' => 'model/vnd.parasolid.transmit.text', 'xaml' => 'application/xaml+xml', 'xap' => 'application/x-silverlight-app', 'xar' => 'application/vnd.xara', 'xav' => 'application/xcap-att+xml', 'xbap' => 'application/x-ms-xbap', 'xbd' => 'application/vnd.fujixerox.docuworks.binder', 'xbm' => 'image/x-xbitmap', 'xca' => 'application/xcap-caps+xml', 'xcs' => 'application/calendar+xml', 'xdf' => 'application/xcap-diff+xml', 'xdm' => 'application/vnd.syncml.dm+xml', 'xdp' => 'application/vnd.adobe.xdp+xml', 'xdssc' => 'application/dssc+xml', 'xdw' => 'application/vnd.fujixerox.docuworks', 'xel' => 'application/xcap-el+xml', 'xenc' => 'application/xenc+xml', 'xer' => 'application/patch-ops-error+xml', 'xfdf' => 'application/xfdf', 'xfdl' => 'application/vnd.xfdl', 'xht' => 'application/xhtml+xml', 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', 'xhtml' => 'application/xhtml+xml', 'xhvml' => 'application/xv+xml', 'xif' => 'image/vnd.xiff', 'xl' => 'application/excel', 'xla' => 'application/vnd.ms-excel', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlc' => 'application/vnd.ms-excel', 'xlf' => 'application/xliff+xml', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlt' => 'application/vnd.ms-excel', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xlw' => 'application/vnd.ms-excel', 'xm' => 'audio/xm', 'xml' => 'application/xml', 'xns' => 'application/xcap-ns+xml', 'xo' => 'application/vnd.olpc-sugar', 'xop' => 'application/xop+xml', 'xpi' => 'application/x-xpinstall', 'xpl' => 'application/xproc+xml', 'xpm' => 'image/x-xpixmap', 'xpr' => 'application/vnd.is-xpr', 'xps' => 'application/vnd.ms-xpsdocument', 'xpw' => 'application/vnd.intercon.formnet', 'xpx' => 'application/vnd.intercon.formnet', 'xsd' => 'application/xml', 'xsf' => 'application/prs.xsf+xml', 'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 'xsm' => 'application/vnd.syncml+xml', 'xspf' => 'application/xspf+xml', 'xul' => 'application/vnd.mozilla.xul+xml', 'xvm' => 'application/xv+xml', 'xvml' => 'application/xv+xml', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 'xz' => 'application/x-xz', 'yaml' => 'text/yaml', 'yang' => 'application/yang', 'yin' => 'application/yin+xml', 'yml' => 'text/yaml', 'ymp' => 'text/x-suse-ymp', 'z' => 'application/x-compress', 'z1' => 'application/x-zmachine', 'z2' => 'application/x-zmachine', 'z3' => 'application/x-zmachine', 'z4' => 'application/x-zmachine', 'z5' => 'application/x-zmachine', 'z6' => 'application/x-zmachine', 'z7' => 'application/x-zmachine', 'z8' => 'application/x-zmachine', 'zaz' => 'application/vnd.zzazz.deck+xml', 'zip' => 'application/zip', 'zir' => 'application/vnd.zul', 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml', 'zsh' => 'text/x-scriptzsh']; |
|
9 | - /** |
|
10 | - * Determines the mimetype of a file by looking at its extension. |
|
11 | - * |
|
12 | - * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json |
|
13 | - */ |
|
14 | - public static function fromFilename(string $filename) : ?string |
|
15 | - { |
|
16 | - return self::fromExtension(\pathinfo($filename, \PATHINFO_EXTENSION)); |
|
17 | - } |
|
18 | - /** |
|
19 | - * Maps a file extensions to a mimetype. |
|
20 | - * |
|
21 | - * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json |
|
22 | - */ |
|
23 | - public static function fromExtension(string $extension) : ?string |
|
24 | - { |
|
25 | - return self::MIME_TYPES[\strtolower($extension)] ?? null; |
|
26 | - } |
|
8 | + private const MIME_TYPES = ['1km' => 'application/vnd.1000minds.decision-model+xml', '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', '3g2' => 'video/3gpp2', '3gp' => 'video/3gp', '3gpp' => 'video/3gpp', '3mf' => 'model/3mf', '7z' => 'application/x-7z-compressed', '7zip' => 'application/x-7z-compressed', '123' => 'application/vnd.lotus-1-2-3', 'aab' => 'application/x-authorware-bin', 'aac' => 'audio/aac', 'aam' => 'application/x-authorware-map', 'aas' => 'application/x-authorware-seg', 'abw' => 'application/x-abiword', 'ac' => 'application/vnd.nokia.n-gage.ac+xml', 'ac3' => 'audio/ac3', 'acc' => 'application/vnd.americandynamics.acc', 'ace' => 'application/x-ace-compressed', 'acu' => 'application/vnd.acucobol', 'acutc' => 'application/vnd.acucorp', 'adp' => 'audio/adpcm', 'adts' => 'audio/aac', 'aep' => 'application/vnd.audiograph', 'afm' => 'application/x-font-type1', 'afp' => 'application/vnd.ibm.modcap', 'age' => 'application/vnd.age', 'ahead' => 'application/vnd.ahead.space', 'ai' => 'application/pdf', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'air' => 'application/vnd.adobe.air-application-installer-package+zip', 'ait' => 'application/vnd.dvb.ait', 'ami' => 'application/vnd.amiga.ami', 'aml' => 'application/automationml-aml+xml', 'amlx' => 'application/automationml-amlx+zip', 'amr' => 'audio/amr', 'apk' => 'application/vnd.android.package-archive', 'apng' => 'image/apng', 'appcache' => 'text/cache-manifest', 'appinstaller' => 'application/appinstaller', 'application' => 'application/x-ms-application', 'appx' => 'application/appx', 'appxbundle' => 'application/appxbundle', 'apr' => 'application/vnd.lotus-approach', 'arc' => 'application/x-freearc', 'arj' => 'application/x-arj', 'asc' => 'application/pgp-signature', 'asf' => 'video/x-ms-asf', 'asm' => 'text/x-asm', 'aso' => 'application/vnd.accpac.simply.aso', 'asx' => 'video/x-ms-asf', 'atc' => 'application/vnd.acucorp', 'atom' => 'application/atom+xml', 'atomcat' => 'application/atomcat+xml', 'atomdeleted' => 'application/atomdeleted+xml', 'atomsvc' => 'application/atomsvc+xml', 'atx' => 'application/vnd.antix.game-component', 'au' => 'audio/x-au', 'avci' => 'image/avci', 'avcs' => 'image/avcs', 'avi' => 'video/x-msvideo', 'avif' => 'image/avif', 'aw' => 'application/applixware', 'azf' => 'application/vnd.airzip.filesecure.azf', 'azs' => 'application/vnd.airzip.filesecure.azs', 'azv' => 'image/vnd.airzip.accelerator.azv', 'azw' => 'application/vnd.amazon.ebook', 'b16' => 'image/vnd.pco.b16', 'bat' => 'application/x-msdownload', 'bcpio' => 'application/x-bcpio', 'bdf' => 'application/x-font-bdf', 'bdm' => 'application/vnd.syncml.dm+wbxml', 'bdoc' => 'application/x-bdoc', 'bed' => 'application/vnd.realvnc.bed', 'bh2' => 'application/vnd.fujitsu.oasysprs', 'bin' => 'application/octet-stream', 'blb' => 'application/x-blorb', 'blorb' => 'application/x-blorb', 'bmi' => 'application/vnd.bmi', 'bmml' => 'application/vnd.balsamiq.bmml+xml', 'bmp' => 'image/bmp', 'book' => 'application/vnd.framemaker', 'box' => 'application/vnd.previewsystems.box', 'boz' => 'application/x-bzip2', 'bpk' => 'application/octet-stream', 'bpmn' => 'application/octet-stream', 'bsp' => 'model/vnd.valve.source.compiled-map', 'btf' => 'image/prs.btif', 'btif' => 'image/prs.btif', 'buffer' => 'application/octet-stream', 'bz' => 'application/x-bzip', 'bz2' => 'application/x-bzip2', 'c' => 'text/x-c', 'c4d' => 'application/vnd.clonk.c4group', 'c4f' => 'application/vnd.clonk.c4group', 'c4g' => 'application/vnd.clonk.c4group', 'c4p' => 'application/vnd.clonk.c4group', 'c4u' => 'application/vnd.clonk.c4group', 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', 'cab' => 'application/vnd.ms-cab-compressed', 'caf' => 'audio/x-caf', 'cap' => 'application/vnd.tcpdump.pcap', 'car' => 'application/vnd.curl.car', 'cat' => 'application/vnd.ms-pki.seccat', 'cb7' => 'application/x-cbr', 'cba' => 'application/x-cbr', 'cbr' => 'application/x-cbr', 'cbt' => 'application/x-cbr', 'cbz' => 'application/x-cbr', 'cc' => 'text/x-c', 'cco' => 'application/x-cocoa', 'cct' => 'application/x-director', 'ccxml' => 'application/ccxml+xml', 'cdbcmsg' => 'application/vnd.contact.cmsg', 'cdf' => 'application/x-netcdf', 'cdfx' => 'application/cdfx+xml', 'cdkey' => 'application/vnd.mediastation.cdkey', 'cdmia' => 'application/cdmi-capability', 'cdmic' => 'application/cdmi-container', 'cdmid' => 'application/cdmi-domain', 'cdmio' => 'application/cdmi-object', 'cdmiq' => 'application/cdmi-queue', 'cdr' => 'application/cdr', 'cdx' => 'chemical/x-cdx', 'cdxml' => 'application/vnd.chemdraw+xml', 'cdy' => 'application/vnd.cinderella', 'cer' => 'application/pkix-cert', 'cfs' => 'application/x-cfs-compressed', 'cgm' => 'image/cgm', 'chat' => 'application/x-chat', 'chm' => 'application/vnd.ms-htmlhelp', 'chrt' => 'application/vnd.kde.kchart', 'cif' => 'chemical/x-cif', 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', 'cil' => 'application/vnd.ms-artgalry', 'cjs' => 'application/node', 'cla' => 'application/vnd.claymore', 'class' => 'application/octet-stream', 'cld' => 'model/vnd.cld', 'clkk' => 'application/vnd.crick.clicker.keyboard', 'clkp' => 'application/vnd.crick.clicker.palette', 'clkt' => 'application/vnd.crick.clicker.template', 'clkw' => 'application/vnd.crick.clicker.wordbank', 'clkx' => 'application/vnd.crick.clicker', 'clp' => 'application/x-msclip', 'cmc' => 'application/vnd.cosmocaller', 'cmdf' => 'chemical/x-cmdf', 'cml' => 'chemical/x-cml', 'cmp' => 'application/vnd.yellowriver-custom-menu', 'cmx' => 'image/x-cmx', 'cod' => 'application/vnd.rim.cod', 'coffee' => 'text/coffeescript', 'com' => 'application/x-msdownload', 'conf' => 'text/plain', 'cpio' => 'application/x-cpio', 'cpl' => 'application/cpl+xml', 'cpp' => 'text/x-c', 'cpt' => 'application/mac-compactpro', 'crd' => 'application/x-mscardfile', 'crl' => 'application/pkix-crl', 'crt' => 'application/x-x509-ca-cert', 'crx' => 'application/x-chrome-extension', 'cryptonote' => 'application/vnd.rig.cryptonote', 'csh' => 'application/x-csh', 'csl' => 'application/vnd.citationstyles.style+xml', 'csml' => 'chemical/x-csml', 'csp' => 'application/vnd.commonspace', 'csr' => 'application/octet-stream', 'css' => 'text/css', 'cst' => 'application/x-director', 'csv' => 'text/csv', 'cu' => 'application/cu-seeme', 'curl' => 'text/vnd.curl', 'cwl' => 'application/cwl', 'cww' => 'application/prs.cww', 'cxt' => 'application/x-director', 'cxx' => 'text/x-c', 'dae' => 'model/vnd.collada+xml', 'daf' => 'application/vnd.mobius.daf', 'dart' => 'application/vnd.dart', 'dataless' => 'application/vnd.fdsn.seed', 'davmount' => 'application/davmount+xml', 'dbf' => 'application/vnd.dbf', 'dbk' => 'application/docbook+xml', 'dcr' => 'application/x-director', 'dcurl' => 'text/vnd.curl.dcurl', 'dd2' => 'application/vnd.oma.dd2+xml', 'ddd' => 'application/vnd.fujixerox.ddd', 'ddf' => 'application/vnd.syncml.dmddf+xml', 'dds' => 'image/vnd.ms-dds', 'deb' => 'application/x-debian-package', 'def' => 'text/plain', 'deploy' => 'application/octet-stream', 'der' => 'application/x-x509-ca-cert', 'dfac' => 'application/vnd.dreamfactory', 'dgc' => 'application/x-dgc-compressed', 'dib' => 'image/bmp', 'dic' => 'text/x-c', 'dir' => 'application/x-director', 'dis' => 'application/vnd.mobius.dis', 'disposition-notification' => 'message/disposition-notification', 'dist' => 'application/octet-stream', 'distz' => 'application/octet-stream', 'djv' => 'image/vnd.djvu', 'djvu' => 'image/vnd.djvu', 'dll' => 'application/octet-stream', 'dmg' => 'application/x-apple-diskimage', 'dmn' => 'application/octet-stream', 'dmp' => 'application/vnd.tcpdump.pcap', 'dms' => 'application/octet-stream', 'dna' => 'application/vnd.dna', 'doc' => 'application/msword', 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dot' => 'application/msword', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dp' => 'application/vnd.osgi.dp', 'dpg' => 'application/vnd.dpgraph', 'dpx' => 'image/dpx', 'dra' => 'audio/vnd.dra', 'drle' => 'image/dicom-rle', 'dsc' => 'text/prs.lines.tag', 'dssc' => 'application/dssc+der', 'dtb' => 'application/x-dtbook+xml', 'dtd' => 'application/xml-dtd', 'dts' => 'audio/vnd.dts', 'dtshd' => 'audio/vnd.dts.hd', 'dump' => 'application/octet-stream', 'dvb' => 'video/vnd.dvb.file', 'dvi' => 'application/x-dvi', 'dwd' => 'application/atsc-dwd+xml', 'dwf' => 'model/vnd.dwf', 'dwg' => 'image/vnd.dwg', 'dxf' => 'image/vnd.dxf', 'dxp' => 'application/vnd.spotfire.dxp', 'dxr' => 'application/x-director', 'ear' => 'application/java-archive', 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', 'ecma' => 'application/ecmascript', 'edm' => 'application/vnd.novadigm.edm', 'edx' => 'application/vnd.novadigm.edx', 'efif' => 'application/vnd.picsel', 'ei6' => 'application/vnd.pg.osasli', 'elc' => 'application/octet-stream', 'emf' => 'image/emf', 'eml' => 'message/rfc822', 'emma' => 'application/emma+xml', 'emotionml' => 'application/emotionml+xml', 'emz' => 'application/x-msmetafile', 'eol' => 'audio/vnd.digital-winds', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript', 'epub' => 'application/epub+zip', 'es3' => 'application/vnd.eszigno3+xml', 'esa' => 'application/vnd.osgi.subsystem', 'esf' => 'application/vnd.epson.esf', 'et3' => 'application/vnd.eszigno3+xml', 'etx' => 'text/x-setext', 'eva' => 'application/x-eva', 'evy' => 'application/x-envoy', 'exe' => 'application/octet-stream', 'exi' => 'application/exi', 'exp' => 'application/express', 'exr' => 'image/aces', 'ext' => 'application/vnd.novadigm.ext', 'ez' => 'application/andrew-inset', 'ez2' => 'application/vnd.ezpix-album', 'ez3' => 'application/vnd.ezpix-package', 'f' => 'text/x-fortran', 'f4v' => 'video/mp4', 'f77' => 'text/x-fortran', 'f90' => 'text/x-fortran', 'fbs' => 'image/vnd.fastbidsheet', 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', 'fcs' => 'application/vnd.isac.fcs', 'fdf' => 'application/vnd.fdf', 'fdt' => 'application/fdt+xml', 'fe_launch' => 'application/vnd.denovo.fcselayout-link', 'fg5' => 'application/vnd.fujitsu.oasysgp', 'fgd' => 'application/x-director', 'fh' => 'image/x-freehand', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fh7' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'fig' => 'application/x-xfig', 'fits' => 'image/fits', 'flac' => 'audio/x-flac', 'fli' => 'video/x-fli', 'flo' => 'application/vnd.micrografx.flo', 'flv' => 'video/x-flv', 'flw' => 'application/vnd.kde.kivio', 'flx' => 'text/vnd.fmi.flexstor', 'fly' => 'text/vnd.fly', 'fm' => 'application/vnd.framemaker', 'fnc' => 'application/vnd.frogans.fnc', 'fo' => 'application/vnd.software602.filler.form+xml', 'for' => 'text/x-fortran', 'fpx' => 'image/vnd.fpx', 'frame' => 'application/vnd.framemaker', 'fsc' => 'application/vnd.fsc.weblaunch', 'fst' => 'image/vnd.fst', 'ftc' => 'application/vnd.fluxtime.clip', 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', 'fvt' => 'video/vnd.fvt', 'fxp' => 'application/vnd.adobe.fxp', 'fxpl' => 'application/vnd.adobe.fxp', 'fzs' => 'application/vnd.fuzzysheet', 'g2w' => 'application/vnd.geoplan', 'g3' => 'image/g3fax', 'g3w' => 'application/vnd.geospace', 'gac' => 'application/vnd.groove-account', 'gam' => 'application/x-tads', 'gbr' => 'application/rpki-ghostbusters', 'gca' => 'application/x-gca-compressed', 'gdl' => 'model/vnd.gdl', 'gdoc' => 'application/vnd.google-apps.document', 'ged' => 'text/vnd.familysearch.gedcom', 'geo' => 'application/vnd.dynageo', 'geojson' => 'application/geo+json', 'gex' => 'application/vnd.geometry-explorer', 'ggb' => 'application/vnd.geogebra.file', 'ggt' => 'application/vnd.geogebra.tool', 'ghf' => 'application/vnd.groove-help', 'gif' => 'image/gif', 'gim' => 'application/vnd.groove-identity-message', 'glb' => 'model/gltf-binary', 'gltf' => 'model/gltf+json', 'gml' => 'application/gml+xml', 'gmx' => 'application/vnd.gmx', 'gnumeric' => 'application/x-gnumeric', 'gpg' => 'application/gpg-keys', 'gph' => 'application/vnd.flographit', 'gpx' => 'application/gpx+xml', 'gqf' => 'application/vnd.grafeq', 'gqs' => 'application/vnd.grafeq', 'gram' => 'application/srgs', 'gramps' => 'application/x-gramps-xml', 'gre' => 'application/vnd.geometry-explorer', 'grv' => 'application/vnd.groove-injector', 'grxml' => 'application/srgs+xml', 'gsf' => 'application/x-font-ghostscript', 'gsheet' => 'application/vnd.google-apps.spreadsheet', 'gslides' => 'application/vnd.google-apps.presentation', 'gtar' => 'application/x-gtar', 'gtm' => 'application/vnd.groove-tool-message', 'gtw' => 'model/vnd.gtw', 'gv' => 'text/vnd.graphviz', 'gxf' => 'application/gxf', 'gxt' => 'application/vnd.geonext', 'gz' => 'application/gzip', 'gzip' => 'application/gzip', 'h' => 'text/x-c', 'h261' => 'video/h261', 'h263' => 'video/h263', 'h264' => 'video/h264', 'hal' => 'application/vnd.hal+xml', 'hbci' => 'application/vnd.hbci', 'hbs' => 'text/x-handlebars-template', 'hdd' => 'application/x-virtualbox-hdd', 'hdf' => 'application/x-hdf', 'heic' => 'image/heic', 'heics' => 'image/heic-sequence', 'heif' => 'image/heif', 'heifs' => 'image/heif-sequence', 'hej2' => 'image/hej2k', 'held' => 'application/atsc-held+xml', 'hh' => 'text/x-c', 'hjson' => 'application/hjson', 'hlp' => 'application/winhlp', 'hpgl' => 'application/vnd.hp-hpgl', 'hpid' => 'application/vnd.hp-hpid', 'hps' => 'application/vnd.hp-hps', 'hqx' => 'application/mac-binhex40', 'hsj2' => 'image/hsj2', 'htc' => 'text/x-component', 'htke' => 'application/vnd.kenameaapp', 'htm' => 'text/html', 'html' => 'text/html', 'hvd' => 'application/vnd.yamaha.hv-dic', 'hvp' => 'application/vnd.yamaha.hv-voice', 'hvs' => 'application/vnd.yamaha.hv-script', 'i2g' => 'application/vnd.intergeo', 'icc' => 'application/vnd.iccprofile', 'ice' => 'x-conference/x-cooltalk', 'icm' => 'application/vnd.iccprofile', 'ico' => 'image/x-icon', 'ics' => 'text/calendar', 'ief' => 'image/ief', 'ifb' => 'text/calendar', 'ifm' => 'application/vnd.shana.informed.formdata', 'iges' => 'model/iges', 'igl' => 'application/vnd.igloader', 'igm' => 'application/vnd.insors.igm', 'igs' => 'model/iges', 'igx' => 'application/vnd.micrografx.igx', 'iif' => 'application/vnd.shana.informed.interchange', 'img' => 'application/octet-stream', 'imp' => 'application/vnd.accpac.simply.imp', 'ims' => 'application/vnd.ms-ims', 'in' => 'text/plain', 'ini' => 'text/plain', 'ink' => 'application/inkml+xml', 'inkml' => 'application/inkml+xml', 'install' => 'application/x-install-instructions', 'iota' => 'application/vnd.astraea-software.iota', 'ipfix' => 'application/ipfix', 'ipk' => 'application/vnd.shana.informed.package', 'irm' => 'application/vnd.ibm.rights-management', 'irp' => 'application/vnd.irepository.package+xml', 'iso' => 'application/x-iso9660-image', 'itp' => 'application/vnd.shana.informed.formtemplate', 'its' => 'application/its+xml', 'ivp' => 'application/vnd.immervision-ivp', 'ivu' => 'application/vnd.immervision-ivu', 'jad' => 'text/vnd.sun.j2me.app-descriptor', 'jade' => 'text/jade', 'jam' => 'application/vnd.jam', 'jar' => 'application/java-archive', 'jardiff' => 'application/x-java-archive-diff', 'java' => 'text/x-java-source', 'jhc' => 'image/jphc', 'jisp' => 'application/vnd.jisp', 'jls' => 'image/jls', 'jlt' => 'application/vnd.hp-jlyt', 'jng' => 'image/x-jng', 'jnlp' => 'application/x-java-jnlp-file', 'joda' => 'application/vnd.joost.joda-archive', 'jp2' => 'image/jp2', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpf' => 'image/jpx', 'jpg' => 'image/jpeg', 'jpg2' => 'image/jp2', 'jpgm' => 'video/jpm', 'jpgv' => 'video/jpeg', 'jph' => 'image/jph', 'jpm' => 'video/jpm', 'jpx' => 'image/jpx', 'js' => 'application/javascript', 'json' => 'application/json', 'json5' => 'application/json5', 'jsonld' => 'application/ld+json', 'jsonml' => 'application/jsonml+json', 'jsx' => 'text/jsx', 'jt' => 'model/jt', 'jxr' => 'image/jxr', 'jxra' => 'image/jxra', 'jxrs' => 'image/jxrs', 'jxs' => 'image/jxs', 'jxsc' => 'image/jxsc', 'jxsi' => 'image/jxsi', 'jxss' => 'image/jxss', 'kar' => 'audio/midi', 'karbon' => 'application/vnd.kde.karbon', 'kdb' => 'application/octet-stream', 'kdbx' => 'application/x-keepass2', 'key' => 'application/x-iwork-keynote-sffkey', 'kfo' => 'application/vnd.kde.kformula', 'kia' => 'application/vnd.kidspiration', 'kml' => 'application/vnd.google-earth.kml+xml', 'kmz' => 'application/vnd.google-earth.kmz', 'kne' => 'application/vnd.kinar', 'knp' => 'application/vnd.kinar', 'kon' => 'application/vnd.kde.kontour', 'kpr' => 'application/vnd.kde.kpresenter', 'kpt' => 'application/vnd.kde.kpresenter', 'kpxx' => 'application/vnd.ds-keypoint', 'ksp' => 'application/vnd.kde.kspread', 'ktr' => 'application/vnd.kahootz', 'ktx' => 'image/ktx', 'ktx2' => 'image/ktx2', 'ktz' => 'application/vnd.kahootz', 'kwd' => 'application/vnd.kde.kword', 'kwt' => 'application/vnd.kde.kword', 'lasxml' => 'application/vnd.las.las+xml', 'latex' => 'application/x-latex', 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', 'les' => 'application/vnd.hhe.lesson-player', 'less' => 'text/less', 'lgr' => 'application/lgr+xml', 'lha' => 'application/octet-stream', 'link66' => 'application/vnd.route66.link66+xml', 'list' => 'text/plain', 'list3820' => 'application/vnd.ibm.modcap', 'listafp' => 'application/vnd.ibm.modcap', 'litcoffee' => 'text/coffeescript', 'lnk' => 'application/x-ms-shortcut', 'log' => 'text/plain', 'lostxml' => 'application/lost+xml', 'lrf' => 'application/octet-stream', 'lrm' => 'application/vnd.ms-lrm', 'ltf' => 'application/vnd.frogans.ltf', 'lua' => 'text/x-lua', 'luac' => 'application/x-lua-bytecode', 'lvp' => 'audio/vnd.lucent.voice', 'lwp' => 'application/vnd.lotus-wordpro', 'lzh' => 'application/octet-stream', 'm1v' => 'video/mpeg', 'm2a' => 'audio/mpeg', 'm2v' => 'video/mpeg', 'm3a' => 'audio/mpeg', 'm3u' => 'text/plain', 'm3u8' => 'application/vnd.apple.mpegurl', 'm4a' => 'audio/x-m4a', 'm4p' => 'application/mp4', 'm4s' => 'video/iso.segment', 'm4u' => 'application/vnd.mpegurl', 'm4v' => 'video/x-m4v', 'm13' => 'application/x-msmediaview', 'm14' => 'application/x-msmediaview', 'm21' => 'application/mp21', 'ma' => 'application/mathematica', 'mads' => 'application/mads+xml', 'maei' => 'application/mmt-aei+xml', 'mag' => 'application/vnd.ecowin.chart', 'maker' => 'application/vnd.framemaker', 'man' => 'text/troff', 'manifest' => 'text/cache-manifest', 'map' => 'application/json', 'mar' => 'application/octet-stream', 'markdown' => 'text/markdown', 'mathml' => 'application/mathml+xml', 'mb' => 'application/mathematica', 'mbk' => 'application/vnd.mobius.mbk', 'mbox' => 'application/mbox', 'mc1' => 'application/vnd.medcalcdata', 'mcd' => 'application/vnd.mcd', 'mcurl' => 'text/vnd.curl.mcurl', 'md' => 'text/markdown', 'mdb' => 'application/x-msaccess', 'mdi' => 'image/vnd.ms-modi', 'mdx' => 'text/mdx', 'me' => 'text/troff', 'mesh' => 'model/mesh', 'meta4' => 'application/metalink4+xml', 'metalink' => 'application/metalink+xml', 'mets' => 'application/mets+xml', 'mfm' => 'application/vnd.mfmp', 'mft' => 'application/rpki-manifest', 'mgp' => 'application/vnd.osgeo.mapguide.package', 'mgz' => 'application/vnd.proteus.magazine', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mie' => 'application/x-mie', 'mif' => 'application/vnd.mif', 'mime' => 'message/rfc822', 'mj2' => 'video/mj2', 'mjp2' => 'video/mj2', 'mjs' => 'text/javascript', 'mk3d' => 'video/x-matroska', 'mka' => 'audio/x-matroska', 'mkd' => 'text/x-markdown', 'mks' => 'video/x-matroska', 'mkv' => 'video/x-matroska', 'mlp' => 'application/vnd.dolby.mlp', 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', 'mmf' => 'application/vnd.smaf', 'mml' => 'text/mathml', 'mmr' => 'image/vnd.fujixerox.edmics-mmr', 'mng' => 'video/x-mng', 'mny' => 'application/x-msmoney', 'mobi' => 'application/x-mobipocket-ebook', 'mods' => 'application/mods+xml', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp2a' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'mp4a' => 'audio/mp4', 'mp4s' => 'application/mp4', 'mp4v' => 'video/mp4', 'mp21' => 'application/mp21', 'mpc' => 'application/vnd.mophun.certificate', 'mpd' => 'application/dash+xml', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpf' => 'application/media-policy-dataset+xml', 'mpg' => 'video/mpeg', 'mpg4' => 'video/mp4', 'mpga' => 'audio/mpeg', 'mpkg' => 'application/vnd.apple.installer+xml', 'mpm' => 'application/vnd.blueice.multipass', 'mpn' => 'application/vnd.mophun.application', 'mpp' => 'application/vnd.ms-project', 'mpt' => 'application/vnd.ms-project', 'mpy' => 'application/vnd.ibm.minipay', 'mqy' => 'application/vnd.mobius.mqy', 'mrc' => 'application/marc', 'mrcx' => 'application/marcxml+xml', 'ms' => 'text/troff', 'mscml' => 'application/mediaservercontrol+xml', 'mseed' => 'application/vnd.fdsn.mseed', 'mseq' => 'application/vnd.mseq', 'msf' => 'application/vnd.epson.msf', 'msg' => 'application/vnd.ms-outlook', 'msh' => 'model/mesh', 'msi' => 'application/x-msdownload', 'msix' => 'application/msix', 'msixbundle' => 'application/msixbundle', 'msl' => 'application/vnd.mobius.msl', 'msm' => 'application/octet-stream', 'msp' => 'application/octet-stream', 'msty' => 'application/vnd.muvee.style', 'mtl' => 'model/mtl', 'mts' => 'model/vnd.mts', 'mus' => 'application/vnd.musician', 'musd' => 'application/mmt-usd+xml', 'musicxml' => 'application/vnd.recordare.musicxml+xml', 'mvb' => 'application/x-msmediaview', 'mvt' => 'application/vnd.mapbox-vector-tile', 'mwf' => 'application/vnd.mfer', 'mxf' => 'application/mxf', 'mxl' => 'application/vnd.recordare.musicxml', 'mxmf' => 'audio/mobile-xmf', 'mxml' => 'application/xv+xml', 'mxs' => 'application/vnd.triscape.mxs', 'mxu' => 'video/vnd.mpegurl', 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', 'n3' => 'text/n3', 'nb' => 'application/mathematica', 'nbp' => 'application/vnd.wolfram.player', 'nc' => 'application/x-netcdf', 'ncx' => 'application/x-dtbncx+xml', 'nfo' => 'text/x-nfo', 'ngdat' => 'application/vnd.nokia.n-gage.data', 'nitf' => 'application/vnd.nitf', 'nlu' => 'application/vnd.neurolanguage.nlu', 'nml' => 'application/vnd.enliven', 'nnd' => 'application/vnd.noblenet-directory', 'nns' => 'application/vnd.noblenet-sealer', 'nnw' => 'application/vnd.noblenet-web', 'npx' => 'image/vnd.net-fpx', 'nq' => 'application/n-quads', 'nsc' => 'application/x-conference', 'nsf' => 'application/vnd.lotus-notes', 'nt' => 'application/n-triples', 'ntf' => 'application/vnd.nitf', 'numbers' => 'application/x-iwork-numbers-sffnumbers', 'nzb' => 'application/x-nzb', 'oa2' => 'application/vnd.fujitsu.oasys2', 'oa3' => 'application/vnd.fujitsu.oasys3', 'oas' => 'application/vnd.fujitsu.oasys', 'obd' => 'application/x-msbinder', 'obgx' => 'application/vnd.openblox.game+xml', 'obj' => 'model/obj', 'oda' => 'application/oda', 'odb' => 'application/vnd.oasis.opendocument.database', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odft' => 'application/vnd.oasis.opendocument.formula-template', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odt' => 'application/vnd.oasis.opendocument.text', 'oga' => 'audio/ogg', 'ogex' => 'model/vnd.opengex', 'ogg' => 'audio/ogg', 'ogv' => 'video/ogg', 'ogx' => 'application/ogg', 'omdoc' => 'application/omdoc+xml', 'onepkg' => 'application/onenote', 'onetmp' => 'application/onenote', 'onetoc' => 'application/onenote', 'onetoc2' => 'application/onenote', 'opf' => 'application/oebps-package+xml', 'opml' => 'text/x-opml', 'oprc' => 'application/vnd.palm', 'opus' => 'audio/ogg', 'org' => 'text/x-org', 'osf' => 'application/vnd.yamaha.openscoreformat', 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', 'osm' => 'application/vnd.openstreetmap.data+xml', 'otc' => 'application/vnd.oasis.opendocument.chart-template', 'otf' => 'font/otf', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'oth' => 'application/vnd.oasis.opendocument.text-web', 'oti' => 'application/vnd.oasis.opendocument.image-template', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'ova' => 'application/x-virtualbox-ova', 'ovf' => 'application/x-virtualbox-ovf', 'owl' => 'application/rdf+xml', 'oxps' => 'application/oxps', 'oxt' => 'application/vnd.openofficeorg.extension', 'p' => 'text/x-pascal', 'p7a' => 'application/x-pkcs7-signature', 'p7b' => 'application/x-pkcs7-certificates', 'p7c' => 'application/pkcs7-mime', 'p7m' => 'application/pkcs7-mime', 'p7r' => 'application/x-pkcs7-certreqresp', 'p7s' => 'application/pkcs7-signature', 'p8' => 'application/pkcs8', 'p10' => 'application/x-pkcs10', 'p12' => 'application/x-pkcs12', 'pac' => 'application/x-ns-proxy-autoconfig', 'pages' => 'application/x-iwork-pages-sffpages', 'pas' => 'text/x-pascal', 'paw' => 'application/vnd.pawaafile', 'pbd' => 'application/vnd.powerbuilder6', 'pbm' => 'image/x-portable-bitmap', 'pcap' => 'application/vnd.tcpdump.pcap', 'pcf' => 'application/x-font-pcf', 'pcl' => 'application/vnd.hp-pcl', 'pclxl' => 'application/vnd.hp-pclxl', 'pct' => 'image/x-pict', 'pcurl' => 'application/vnd.curl.pcurl', 'pcx' => 'image/x-pcx', 'pdb' => 'application/x-pilot', 'pde' => 'text/x-processing', 'pdf' => 'application/pdf', 'pem' => 'application/x-x509-user-cert', 'pfa' => 'application/x-font-type1', 'pfb' => 'application/x-font-type1', 'pfm' => 'application/x-font-type1', 'pfr' => 'application/font-tdpfr', 'pfx' => 'application/x-pkcs12', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'pgp' => 'application/pgp', 'phar' => 'application/octet-stream', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'phtml' => 'application/x-httpd-php', 'pic' => 'image/x-pict', 'pkg' => 'application/octet-stream', 'pki' => 'application/pkixcmp', 'pkipath' => 'application/pkix-pkipath', 'pkpass' => 'application/vnd.apple.pkpass', 'pl' => 'application/x-perl', 'plb' => 'application/vnd.3gpp.pic-bw-large', 'plc' => 'application/vnd.mobius.plc', 'plf' => 'application/vnd.pocketlearn', 'pls' => 'application/pls+xml', 'pm' => 'application/x-perl', 'pml' => 'application/vnd.ctc-posml', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'portpkg' => 'application/vnd.macports.portpkg', 'pot' => 'application/vnd.ms-powerpoint', 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppa' => 'application/vnd.ms-powerpoint', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'ppd' => 'application/vnd.cups-ppd', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/vnd.ms-powerpoint', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppt' => 'application/powerpoint', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pqa' => 'application/vnd.palm', 'prc' => 'model/prc', 'pre' => 'application/vnd.lotus-freelance', 'prf' => 'application/pics-rules', 'provx' => 'application/provenance+xml', 'ps' => 'application/postscript', 'psb' => 'application/vnd.3gpp.pic-bw-small', 'psd' => 'application/x-photoshop', 'psf' => 'application/x-font-linux-psf', 'pskcxml' => 'application/pskc+xml', 'pti' => 'image/prs.pti', 'ptid' => 'application/vnd.pvi.ptid1', 'pub' => 'application/x-mspublisher', 'pvb' => 'application/vnd.3gpp.pic-bw-var', 'pwn' => 'application/vnd.3m.post-it-notes', 'pya' => 'audio/vnd.ms-playready.media.pya', 'pyo' => 'model/vnd.pytha.pyox', 'pyox' => 'model/vnd.pytha.pyox', 'pyv' => 'video/vnd.ms-playready.media.pyv', 'qam' => 'application/vnd.epson.quickanime', 'qbo' => 'application/vnd.intu.qbo', 'qfx' => 'application/vnd.intu.qfx', 'qps' => 'application/vnd.publishare-delta-tree', 'qt' => 'video/quicktime', 'qwd' => 'application/vnd.quark.quarkxpress', 'qwt' => 'application/vnd.quark.quarkxpress', 'qxb' => 'application/vnd.quark.quarkxpress', 'qxd' => 'application/vnd.quark.quarkxpress', 'qxl' => 'application/vnd.quark.quarkxpress', 'qxt' => 'application/vnd.quark.quarkxpress', 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'raml' => 'application/raml+yaml', 'rapd' => 'application/route-apd+xml', 'rar' => 'application/x-rar', 'ras' => 'image/x-cmu-raster', 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', 'rdf' => 'application/rdf+xml', 'rdz' => 'application/vnd.data-vision.rdz', 'relo' => 'application/p2p-overlay+xml', 'rep' => 'application/vnd.businessobjects', 'res' => 'application/x-dtbresource+xml', 'rgb' => 'image/x-rgb', 'rif' => 'application/reginfo+xml', 'rip' => 'audio/vnd.rip', 'ris' => 'application/x-research-info-systems', 'rl' => 'application/resource-lists+xml', 'rlc' => 'image/vnd.fujixerox.edmics-rlc', 'rld' => 'application/resource-lists-diff+xml', 'rm' => 'audio/x-pn-realaudio', 'rmi' => 'audio/midi', 'rmp' => 'audio/x-pn-realaudio-plugin', 'rms' => 'application/vnd.jcp.javame.midlet-rms', 'rmvb' => 'application/vnd.rn-realmedia-vbr', 'rnc' => 'application/relax-ng-compact-syntax', 'rng' => 'application/xml', 'roa' => 'application/rpki-roa', 'roff' => 'text/troff', 'rp9' => 'application/vnd.cloanto.rp9', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rpss' => 'application/vnd.nokia.radio-presets', 'rpst' => 'application/vnd.nokia.radio-preset', 'rq' => 'application/sparql-query', 'rs' => 'application/rls-services+xml', 'rsa' => 'application/x-pkcs7', 'rsat' => 'application/atsc-rsat+xml', 'rsd' => 'application/rsd+xml', 'rsheet' => 'application/urc-ressheet+xml', 'rss' => 'application/rss+xml', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'run' => 'application/x-makeself', 'rusd' => 'application/route-usd+xml', 'rv' => 'video/vnd.rn-realvideo', 's' => 'text/x-asm', 's3m' => 'audio/s3m', 'saf' => 'application/vnd.yamaha.smaf-audio', 'sass' => 'text/x-sass', 'sbml' => 'application/sbml+xml', 'sc' => 'application/vnd.ibm.secure-container', 'scd' => 'application/x-msschedule', 'scm' => 'application/vnd.lotus-screencam', 'scq' => 'application/scvp-cv-request', 'scs' => 'application/scvp-cv-response', 'scss' => 'text/x-scss', 'scurl' => 'text/vnd.curl.scurl', 'sda' => 'application/vnd.stardivision.draw', 'sdc' => 'application/vnd.stardivision.calc', 'sdd' => 'application/vnd.stardivision.impress', 'sdkd' => 'application/vnd.solent.sdkm+xml', 'sdkm' => 'application/vnd.solent.sdkm+xml', 'sdp' => 'application/sdp', 'sdw' => 'application/vnd.stardivision.writer', 'sea' => 'application/octet-stream', 'see' => 'application/vnd.seemail', 'seed' => 'application/vnd.fdsn.seed', 'sema' => 'application/vnd.sema', 'semd' => 'application/vnd.semd', 'semf' => 'application/vnd.semf', 'senmlx' => 'application/senml+xml', 'sensmlx' => 'application/sensml+xml', 'ser' => 'application/java-serialized-object', 'setpay' => 'application/set-payment-initiation', 'setreg' => 'application/set-registration-initiation', 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', 'sfs' => 'application/vnd.spotfire.sfs', 'sfv' => 'text/x-sfv', 'sgi' => 'image/sgi', 'sgl' => 'application/vnd.stardivision.writer-global', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'shex' => 'text/shex', 'shf' => 'application/shf+xml', 'shtml' => 'text/html', 'sid' => 'image/x-mrsid-image', 'sieve' => 'application/sieve', 'sig' => 'application/pgp-signature', 'sil' => 'audio/silk', 'silo' => 'model/mesh', 'sis' => 'application/vnd.symbian.install', 'sisx' => 'application/vnd.symbian.install', 'sit' => 'application/x-stuffit', 'sitx' => 'application/x-stuffitx', 'siv' => 'application/sieve', 'skd' => 'application/vnd.koan', 'skm' => 'application/vnd.koan', 'skp' => 'application/vnd.koan', 'skt' => 'application/vnd.koan', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'slim' => 'text/slim', 'slm' => 'text/slim', 'sls' => 'application/route-s-tsid+xml', 'slt' => 'application/vnd.epson.salt', 'sm' => 'application/vnd.stepmania.stepchart', 'smf' => 'application/vnd.stardivision.math', 'smi' => 'application/smil', 'smil' => 'application/smil', 'smv' => 'video/x-smv', 'smzip' => 'application/vnd.stepmania.package', 'snd' => 'audio/basic', 'snf' => 'application/x-font-snf', 'so' => 'application/octet-stream', 'spc' => 'application/x-pkcs7-certificates', 'spdx' => 'text/spdx', 'spf' => 'application/vnd.yamaha.smaf-phrase', 'spl' => 'application/x-futuresplash', 'spot' => 'text/vnd.in3d.spot', 'spp' => 'application/scvp-vp-response', 'spq' => 'application/scvp-vp-request', 'spx' => 'audio/ogg', 'sql' => 'application/x-sql', 'src' => 'application/x-wais-source', 'srt' => 'application/x-subrip', 'sru' => 'application/sru+xml', 'srx' => 'application/sparql-results+xml', 'ssdl' => 'application/ssdl+xml', 'sse' => 'application/vnd.kodak-descriptor', 'ssf' => 'application/vnd.epson.ssf', 'ssml' => 'application/ssml+xml', 'sst' => 'application/octet-stream', 'st' => 'application/vnd.sailingtracker.track', 'stc' => 'application/vnd.sun.xml.calc.template', 'std' => 'application/vnd.sun.xml.draw.template', 'step' => 'application/STEP', 'stf' => 'application/vnd.wt.stf', 'sti' => 'application/vnd.sun.xml.impress.template', 'stk' => 'application/hyperstudio', 'stl' => 'model/stl', 'stp' => 'application/STEP', 'stpx' => 'model/step+xml', 'stpxz' => 'model/step-xml+zip', 'stpz' => 'model/step+zip', 'str' => 'application/vnd.pg.format', 'stw' => 'application/vnd.sun.xml.writer.template', 'styl' => 'text/stylus', 'stylus' => 'text/stylus', 'sub' => 'text/vnd.dvb.subtitle', 'sus' => 'application/vnd.sus-calendar', 'susp' => 'application/vnd.sus-calendar', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'svc' => 'application/vnd.dvb.service', 'svd' => 'application/vnd.svd', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'swa' => 'application/x-director', 'swf' => 'application/x-shockwave-flash', 'swi' => 'application/vnd.aristanetworks.swi', 'swidtag' => 'application/swid+xml', 'sxc' => 'application/vnd.sun.xml.calc', 'sxd' => 'application/vnd.sun.xml.draw', 'sxg' => 'application/vnd.sun.xml.writer.global', 'sxi' => 'application/vnd.sun.xml.impress', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 't' => 'text/troff', 't3' => 'application/x-t3vm-image', 't38' => 'image/t38', 'taglet' => 'application/vnd.mynfc', 'tao' => 'application/vnd.tao.intent-module-archive', 'tap' => 'image/vnd.tencent.tap', 'tar' => 'application/x-tar', 'tcap' => 'application/vnd.3gpp2.tcap', 'tcl' => 'application/x-tcl', 'td' => 'application/urc-targetdesc+xml', 'teacher' => 'application/vnd.smart.teacher', 'tei' => 'application/tei+xml', 'teicorpus' => 'application/tei+xml', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'text' => 'text/plain', 'tfi' => 'application/thraud+xml', 'tfm' => 'application/x-tex-tfm', 'tfx' => 'image/tiff-fx', 'tga' => 'image/x-tga', 'tgz' => 'application/x-tar', 'thmx' => 'application/vnd.ms-officetheme', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tk' => 'application/x-tcl', 'tmo' => 'application/vnd.tmobile-livetv', 'toml' => 'application/toml', 'torrent' => 'application/x-bittorrent', 'tpl' => 'application/vnd.groove-tool-template', 'tpt' => 'application/vnd.trid.tpt', 'tr' => 'text/troff', 'tra' => 'application/vnd.trueapp', 'trig' => 'application/trig', 'trm' => 'application/x-msterminal', 'ts' => 'video/mp2t', 'tsd' => 'application/timestamped-data', 'tsv' => 'text/tab-separated-values', 'ttc' => 'font/collection', 'ttf' => 'font/ttf', 'ttl' => 'text/turtle', 'ttml' => 'application/ttml+xml', 'twd' => 'application/vnd.simtech-mindmapper', 'twds' => 'application/vnd.simtech-mindmapper', 'txd' => 'application/vnd.genomatix.tuxedo', 'txf' => 'application/vnd.mobius.txf', 'txt' => 'text/plain', 'u3d' => 'model/u3d', 'u8dsn' => 'message/global-delivery-status', 'u8hdr' => 'message/global-headers', 'u8mdn' => 'message/global-disposition-notification', 'u8msg' => 'message/global', 'u32' => 'application/x-authorware-bin', 'ubj' => 'application/ubjson', 'udeb' => 'application/x-debian-package', 'ufd' => 'application/vnd.ufdl', 'ufdl' => 'application/vnd.ufdl', 'ulx' => 'application/x-glulx', 'umj' => 'application/vnd.umajin', 'unityweb' => 'application/vnd.unity', 'uo' => 'application/vnd.uoml+xml', 'uoml' => 'application/vnd.uoml+xml', 'uri' => 'text/uri-list', 'uris' => 'text/uri-list', 'urls' => 'text/uri-list', 'usda' => 'model/vnd.usda', 'usdz' => 'model/vnd.usdz+zip', 'ustar' => 'application/x-ustar', 'utz' => 'application/vnd.uiq.theme', 'uu' => 'text/x-uuencode', 'uva' => 'audio/vnd.dece.audio', 'uvd' => 'application/vnd.dece.data', 'uvf' => 'application/vnd.dece.data', 'uvg' => 'image/vnd.dece.graphic', 'uvh' => 'video/vnd.dece.hd', 'uvi' => 'image/vnd.dece.graphic', 'uvm' => 'video/vnd.dece.mobile', 'uvp' => 'video/vnd.dece.pd', 'uvs' => 'video/vnd.dece.sd', 'uvt' => 'application/vnd.dece.ttml+xml', 'uvu' => 'video/vnd.uvvu.mp4', 'uvv' => 'video/vnd.dece.video', 'uvva' => 'audio/vnd.dece.audio', 'uvvd' => 'application/vnd.dece.data', 'uvvf' => 'application/vnd.dece.data', 'uvvg' => 'image/vnd.dece.graphic', 'uvvh' => 'video/vnd.dece.hd', 'uvvi' => 'image/vnd.dece.graphic', 'uvvm' => 'video/vnd.dece.mobile', 'uvvp' => 'video/vnd.dece.pd', 'uvvs' => 'video/vnd.dece.sd', 'uvvt' => 'application/vnd.dece.ttml+xml', 'uvvu' => 'video/vnd.uvvu.mp4', 'uvvv' => 'video/vnd.dece.video', 'uvvx' => 'application/vnd.dece.unspecified', 'uvvz' => 'application/vnd.dece.zip', 'uvx' => 'application/vnd.dece.unspecified', 'uvz' => 'application/vnd.dece.zip', 'vbox' => 'application/x-virtualbox-vbox', 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', 'vcard' => 'text/vcard', 'vcd' => 'application/x-cdlink', 'vcf' => 'text/x-vcard', 'vcg' => 'application/vnd.groove-vcard', 'vcs' => 'text/x-vcalendar', 'vcx' => 'application/vnd.vcx', 'vdi' => 'application/x-virtualbox-vdi', 'vds' => 'model/vnd.sap.vds', 'vhd' => 'application/x-virtualbox-vhd', 'vis' => 'application/vnd.visionary', 'viv' => 'video/vnd.vivo', 'vlc' => 'application/videolan', 'vmdk' => 'application/x-virtualbox-vmdk', 'vob' => 'video/x-ms-vob', 'vor' => 'application/vnd.stardivision.writer', 'vox' => 'application/x-authorware-bin', 'vrml' => 'model/vrml', 'vsd' => 'application/vnd.visio', 'vsf' => 'application/vnd.vsf', 'vss' => 'application/vnd.visio', 'vst' => 'application/vnd.visio', 'vsw' => 'application/vnd.visio', 'vtf' => 'image/vnd.valve.source.texture', 'vtt' => 'text/vtt', 'vtu' => 'model/vnd.vtu', 'vxml' => 'application/voicexml+xml', 'w3d' => 'application/x-director', 'wad' => 'application/x-doom', 'wadl' => 'application/vnd.sun.wadl+xml', 'war' => 'application/java-archive', 'wasm' => 'application/wasm', 'wav' => 'audio/x-wav', 'wax' => 'audio/x-ms-wax', 'wbmp' => 'image/vnd.wap.wbmp', 'wbs' => 'application/vnd.criticaltools.wbs+xml', 'wbxml' => 'application/wbxml', 'wcm' => 'application/vnd.ms-works', 'wdb' => 'application/vnd.ms-works', 'wdp' => 'image/vnd.ms-photo', 'weba' => 'audio/webm', 'webapp' => 'application/x-web-app-manifest+json', 'webm' => 'video/webm', 'webmanifest' => 'application/manifest+json', 'webp' => 'image/webp', 'wg' => 'application/vnd.pmi.widget', 'wgsl' => 'text/wgsl', 'wgt' => 'application/widget', 'wif' => 'application/watcherinfo+xml', 'wks' => 'application/vnd.ms-works', 'wm' => 'video/x-ms-wm', 'wma' => 'audio/x-ms-wma', 'wmd' => 'application/x-ms-wmd', 'wmf' => 'image/wmf', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wmz' => 'application/x-msmetafile', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'word' => 'application/msword', 'wpd' => 'application/vnd.wordperfect', 'wpl' => 'application/vnd.ms-wpl', 'wps' => 'application/vnd.ms-works', 'wqd' => 'application/vnd.wqd', 'wri' => 'application/x-mswrite', 'wrl' => 'model/vrml', 'wsc' => 'message/vnd.wfa.wsc', 'wsdl' => 'application/wsdl+xml', 'wspolicy' => 'application/wspolicy+xml', 'wtb' => 'application/vnd.webturbo', 'wvx' => 'video/x-ms-wvx', 'x3d' => 'model/x3d+xml', 'x3db' => 'model/x3d+fastinfoset', 'x3dbz' => 'model/x3d+binary', 'x3dv' => 'model/x3d-vrml', 'x3dvz' => 'model/x3d+vrml', 'x3dz' => 'model/x3d+xml', 'x32' => 'application/x-authorware-bin', 'x_b' => 'model/vnd.parasolid.transmit.binary', 'x_t' => 'model/vnd.parasolid.transmit.text', 'xaml' => 'application/xaml+xml', 'xap' => 'application/x-silverlight-app', 'xar' => 'application/vnd.xara', 'xav' => 'application/xcap-att+xml', 'xbap' => 'application/x-ms-xbap', 'xbd' => 'application/vnd.fujixerox.docuworks.binder', 'xbm' => 'image/x-xbitmap', 'xca' => 'application/xcap-caps+xml', 'xcs' => 'application/calendar+xml', 'xdf' => 'application/xcap-diff+xml', 'xdm' => 'application/vnd.syncml.dm+xml', 'xdp' => 'application/vnd.adobe.xdp+xml', 'xdssc' => 'application/dssc+xml', 'xdw' => 'application/vnd.fujixerox.docuworks', 'xel' => 'application/xcap-el+xml', 'xenc' => 'application/xenc+xml', 'xer' => 'application/patch-ops-error+xml', 'xfdf' => 'application/xfdf', 'xfdl' => 'application/vnd.xfdl', 'xht' => 'application/xhtml+xml', 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', 'xhtml' => 'application/xhtml+xml', 'xhvml' => 'application/xv+xml', 'xif' => 'image/vnd.xiff', 'xl' => 'application/excel', 'xla' => 'application/vnd.ms-excel', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlc' => 'application/vnd.ms-excel', 'xlf' => 'application/xliff+xml', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlt' => 'application/vnd.ms-excel', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xlw' => 'application/vnd.ms-excel', 'xm' => 'audio/xm', 'xml' => 'application/xml', 'xns' => 'application/xcap-ns+xml', 'xo' => 'application/vnd.olpc-sugar', 'xop' => 'application/xop+xml', 'xpi' => 'application/x-xpinstall', 'xpl' => 'application/xproc+xml', 'xpm' => 'image/x-xpixmap', 'xpr' => 'application/vnd.is-xpr', 'xps' => 'application/vnd.ms-xpsdocument', 'xpw' => 'application/vnd.intercon.formnet', 'xpx' => 'application/vnd.intercon.formnet', 'xsd' => 'application/xml', 'xsf' => 'application/prs.xsf+xml', 'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 'xsm' => 'application/vnd.syncml+xml', 'xspf' => 'application/xspf+xml', 'xul' => 'application/vnd.mozilla.xul+xml', 'xvm' => 'application/xv+xml', 'xvml' => 'application/xv+xml', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 'xz' => 'application/x-xz', 'yaml' => 'text/yaml', 'yang' => 'application/yang', 'yin' => 'application/yin+xml', 'yml' => 'text/yaml', 'ymp' => 'text/x-suse-ymp', 'z' => 'application/x-compress', 'z1' => 'application/x-zmachine', 'z2' => 'application/x-zmachine', 'z3' => 'application/x-zmachine', 'z4' => 'application/x-zmachine', 'z5' => 'application/x-zmachine', 'z6' => 'application/x-zmachine', 'z7' => 'application/x-zmachine', 'z8' => 'application/x-zmachine', 'zaz' => 'application/vnd.zzazz.deck+xml', 'zip' => 'application/zip', 'zir' => 'application/vnd.zul', 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml', 'zsh' => 'text/x-scriptzsh']; |
|
9 | + /** |
|
10 | + * Determines the mimetype of a file by looking at its extension. |
|
11 | + * |
|
12 | + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json |
|
13 | + */ |
|
14 | + public static function fromFilename(string $filename) : ?string |
|
15 | + { |
|
16 | + return self::fromExtension(\pathinfo($filename, \PATHINFO_EXTENSION)); |
|
17 | + } |
|
18 | + /** |
|
19 | + * Maps a file extensions to a mimetype. |
|
20 | + * |
|
21 | + * @see https://raw.githubusercontent.com/jshttp/mime-db/master/db.json |
|
22 | + */ |
|
23 | + public static function fromExtension(string $extension) : ?string |
|
24 | + { |
|
25 | + return self::MIME_TYPES[\strtolower($extension)] ?? null; |
|
26 | + } |
|
27 | 27 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | final class MimeType |
@@ -3,8 +3,7 @@ |
||
3 | 3 | declare (strict_types=1); |
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | -final class MimeType |
|
7 | -{ |
|
6 | +final class MimeType { |
|
8 | 7 | private const MIME_TYPES = ['1km' => 'application/vnd.1000minds.decision-model+xml', '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', '3g2' => 'video/3gpp2', '3gp' => 'video/3gp', '3gpp' => 'video/3gpp', '3mf' => 'model/3mf', '7z' => 'application/x-7z-compressed', '7zip' => 'application/x-7z-compressed', '123' => 'application/vnd.lotus-1-2-3', 'aab' => 'application/x-authorware-bin', 'aac' => 'audio/aac', 'aam' => 'application/x-authorware-map', 'aas' => 'application/x-authorware-seg', 'abw' => 'application/x-abiword', 'ac' => 'application/vnd.nokia.n-gage.ac+xml', 'ac3' => 'audio/ac3', 'acc' => 'application/vnd.americandynamics.acc', 'ace' => 'application/x-ace-compressed', 'acu' => 'application/vnd.acucobol', 'acutc' => 'application/vnd.acucorp', 'adp' => 'audio/adpcm', 'adts' => 'audio/aac', 'aep' => 'application/vnd.audiograph', 'afm' => 'application/x-font-type1', 'afp' => 'application/vnd.ibm.modcap', 'age' => 'application/vnd.age', 'ahead' => 'application/vnd.ahead.space', 'ai' => 'application/pdf', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'air' => 'application/vnd.adobe.air-application-installer-package+zip', 'ait' => 'application/vnd.dvb.ait', 'ami' => 'application/vnd.amiga.ami', 'aml' => 'application/automationml-aml+xml', 'amlx' => 'application/automationml-amlx+zip', 'amr' => 'audio/amr', 'apk' => 'application/vnd.android.package-archive', 'apng' => 'image/apng', 'appcache' => 'text/cache-manifest', 'appinstaller' => 'application/appinstaller', 'application' => 'application/x-ms-application', 'appx' => 'application/appx', 'appxbundle' => 'application/appxbundle', 'apr' => 'application/vnd.lotus-approach', 'arc' => 'application/x-freearc', 'arj' => 'application/x-arj', 'asc' => 'application/pgp-signature', 'asf' => 'video/x-ms-asf', 'asm' => 'text/x-asm', 'aso' => 'application/vnd.accpac.simply.aso', 'asx' => 'video/x-ms-asf', 'atc' => 'application/vnd.acucorp', 'atom' => 'application/atom+xml', 'atomcat' => 'application/atomcat+xml', 'atomdeleted' => 'application/atomdeleted+xml', 'atomsvc' => 'application/atomsvc+xml', 'atx' => 'application/vnd.antix.game-component', 'au' => 'audio/x-au', 'avci' => 'image/avci', 'avcs' => 'image/avcs', 'avi' => 'video/x-msvideo', 'avif' => 'image/avif', 'aw' => 'application/applixware', 'azf' => 'application/vnd.airzip.filesecure.azf', 'azs' => 'application/vnd.airzip.filesecure.azs', 'azv' => 'image/vnd.airzip.accelerator.azv', 'azw' => 'application/vnd.amazon.ebook', 'b16' => 'image/vnd.pco.b16', 'bat' => 'application/x-msdownload', 'bcpio' => 'application/x-bcpio', 'bdf' => 'application/x-font-bdf', 'bdm' => 'application/vnd.syncml.dm+wbxml', 'bdoc' => 'application/x-bdoc', 'bed' => 'application/vnd.realvnc.bed', 'bh2' => 'application/vnd.fujitsu.oasysprs', 'bin' => 'application/octet-stream', 'blb' => 'application/x-blorb', 'blorb' => 'application/x-blorb', 'bmi' => 'application/vnd.bmi', 'bmml' => 'application/vnd.balsamiq.bmml+xml', 'bmp' => 'image/bmp', 'book' => 'application/vnd.framemaker', 'box' => 'application/vnd.previewsystems.box', 'boz' => 'application/x-bzip2', 'bpk' => 'application/octet-stream', 'bpmn' => 'application/octet-stream', 'bsp' => 'model/vnd.valve.source.compiled-map', 'btf' => 'image/prs.btif', 'btif' => 'image/prs.btif', 'buffer' => 'application/octet-stream', 'bz' => 'application/x-bzip', 'bz2' => 'application/x-bzip2', 'c' => 'text/x-c', 'c4d' => 'application/vnd.clonk.c4group', 'c4f' => 'application/vnd.clonk.c4group', 'c4g' => 'application/vnd.clonk.c4group', 'c4p' => 'application/vnd.clonk.c4group', 'c4u' => 'application/vnd.clonk.c4group', 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', 'cab' => 'application/vnd.ms-cab-compressed', 'caf' => 'audio/x-caf', 'cap' => 'application/vnd.tcpdump.pcap', 'car' => 'application/vnd.curl.car', 'cat' => 'application/vnd.ms-pki.seccat', 'cb7' => 'application/x-cbr', 'cba' => 'application/x-cbr', 'cbr' => 'application/x-cbr', 'cbt' => 'application/x-cbr', 'cbz' => 'application/x-cbr', 'cc' => 'text/x-c', 'cco' => 'application/x-cocoa', 'cct' => 'application/x-director', 'ccxml' => 'application/ccxml+xml', 'cdbcmsg' => 'application/vnd.contact.cmsg', 'cdf' => 'application/x-netcdf', 'cdfx' => 'application/cdfx+xml', 'cdkey' => 'application/vnd.mediastation.cdkey', 'cdmia' => 'application/cdmi-capability', 'cdmic' => 'application/cdmi-container', 'cdmid' => 'application/cdmi-domain', 'cdmio' => 'application/cdmi-object', 'cdmiq' => 'application/cdmi-queue', 'cdr' => 'application/cdr', 'cdx' => 'chemical/x-cdx', 'cdxml' => 'application/vnd.chemdraw+xml', 'cdy' => 'application/vnd.cinderella', 'cer' => 'application/pkix-cert', 'cfs' => 'application/x-cfs-compressed', 'cgm' => 'image/cgm', 'chat' => 'application/x-chat', 'chm' => 'application/vnd.ms-htmlhelp', 'chrt' => 'application/vnd.kde.kchart', 'cif' => 'chemical/x-cif', 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', 'cil' => 'application/vnd.ms-artgalry', 'cjs' => 'application/node', 'cla' => 'application/vnd.claymore', 'class' => 'application/octet-stream', 'cld' => 'model/vnd.cld', 'clkk' => 'application/vnd.crick.clicker.keyboard', 'clkp' => 'application/vnd.crick.clicker.palette', 'clkt' => 'application/vnd.crick.clicker.template', 'clkw' => 'application/vnd.crick.clicker.wordbank', 'clkx' => 'application/vnd.crick.clicker', 'clp' => 'application/x-msclip', 'cmc' => 'application/vnd.cosmocaller', 'cmdf' => 'chemical/x-cmdf', 'cml' => 'chemical/x-cml', 'cmp' => 'application/vnd.yellowriver-custom-menu', 'cmx' => 'image/x-cmx', 'cod' => 'application/vnd.rim.cod', 'coffee' => 'text/coffeescript', 'com' => 'application/x-msdownload', 'conf' => 'text/plain', 'cpio' => 'application/x-cpio', 'cpl' => 'application/cpl+xml', 'cpp' => 'text/x-c', 'cpt' => 'application/mac-compactpro', 'crd' => 'application/x-mscardfile', 'crl' => 'application/pkix-crl', 'crt' => 'application/x-x509-ca-cert', 'crx' => 'application/x-chrome-extension', 'cryptonote' => 'application/vnd.rig.cryptonote', 'csh' => 'application/x-csh', 'csl' => 'application/vnd.citationstyles.style+xml', 'csml' => 'chemical/x-csml', 'csp' => 'application/vnd.commonspace', 'csr' => 'application/octet-stream', 'css' => 'text/css', 'cst' => 'application/x-director', 'csv' => 'text/csv', 'cu' => 'application/cu-seeme', 'curl' => 'text/vnd.curl', 'cwl' => 'application/cwl', 'cww' => 'application/prs.cww', 'cxt' => 'application/x-director', 'cxx' => 'text/x-c', 'dae' => 'model/vnd.collada+xml', 'daf' => 'application/vnd.mobius.daf', 'dart' => 'application/vnd.dart', 'dataless' => 'application/vnd.fdsn.seed', 'davmount' => 'application/davmount+xml', 'dbf' => 'application/vnd.dbf', 'dbk' => 'application/docbook+xml', 'dcr' => 'application/x-director', 'dcurl' => 'text/vnd.curl.dcurl', 'dd2' => 'application/vnd.oma.dd2+xml', 'ddd' => 'application/vnd.fujixerox.ddd', 'ddf' => 'application/vnd.syncml.dmddf+xml', 'dds' => 'image/vnd.ms-dds', 'deb' => 'application/x-debian-package', 'def' => 'text/plain', 'deploy' => 'application/octet-stream', 'der' => 'application/x-x509-ca-cert', 'dfac' => 'application/vnd.dreamfactory', 'dgc' => 'application/x-dgc-compressed', 'dib' => 'image/bmp', 'dic' => 'text/x-c', 'dir' => 'application/x-director', 'dis' => 'application/vnd.mobius.dis', 'disposition-notification' => 'message/disposition-notification', 'dist' => 'application/octet-stream', 'distz' => 'application/octet-stream', 'djv' => 'image/vnd.djvu', 'djvu' => 'image/vnd.djvu', 'dll' => 'application/octet-stream', 'dmg' => 'application/x-apple-diskimage', 'dmn' => 'application/octet-stream', 'dmp' => 'application/vnd.tcpdump.pcap', 'dms' => 'application/octet-stream', 'dna' => 'application/vnd.dna', 'doc' => 'application/msword', 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'dot' => 'application/msword', 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dp' => 'application/vnd.osgi.dp', 'dpg' => 'application/vnd.dpgraph', 'dpx' => 'image/dpx', 'dra' => 'audio/vnd.dra', 'drle' => 'image/dicom-rle', 'dsc' => 'text/prs.lines.tag', 'dssc' => 'application/dssc+der', 'dtb' => 'application/x-dtbook+xml', 'dtd' => 'application/xml-dtd', 'dts' => 'audio/vnd.dts', 'dtshd' => 'audio/vnd.dts.hd', 'dump' => 'application/octet-stream', 'dvb' => 'video/vnd.dvb.file', 'dvi' => 'application/x-dvi', 'dwd' => 'application/atsc-dwd+xml', 'dwf' => 'model/vnd.dwf', 'dwg' => 'image/vnd.dwg', 'dxf' => 'image/vnd.dxf', 'dxp' => 'application/vnd.spotfire.dxp', 'dxr' => 'application/x-director', 'ear' => 'application/java-archive', 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', 'ecma' => 'application/ecmascript', 'edm' => 'application/vnd.novadigm.edm', 'edx' => 'application/vnd.novadigm.edx', 'efif' => 'application/vnd.picsel', 'ei6' => 'application/vnd.pg.osasli', 'elc' => 'application/octet-stream', 'emf' => 'image/emf', 'eml' => 'message/rfc822', 'emma' => 'application/emma+xml', 'emotionml' => 'application/emotionml+xml', 'emz' => 'application/x-msmetafile', 'eol' => 'audio/vnd.digital-winds', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript', 'epub' => 'application/epub+zip', 'es3' => 'application/vnd.eszigno3+xml', 'esa' => 'application/vnd.osgi.subsystem', 'esf' => 'application/vnd.epson.esf', 'et3' => 'application/vnd.eszigno3+xml', 'etx' => 'text/x-setext', 'eva' => 'application/x-eva', 'evy' => 'application/x-envoy', 'exe' => 'application/octet-stream', 'exi' => 'application/exi', 'exp' => 'application/express', 'exr' => 'image/aces', 'ext' => 'application/vnd.novadigm.ext', 'ez' => 'application/andrew-inset', 'ez2' => 'application/vnd.ezpix-album', 'ez3' => 'application/vnd.ezpix-package', 'f' => 'text/x-fortran', 'f4v' => 'video/mp4', 'f77' => 'text/x-fortran', 'f90' => 'text/x-fortran', 'fbs' => 'image/vnd.fastbidsheet', 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', 'fcs' => 'application/vnd.isac.fcs', 'fdf' => 'application/vnd.fdf', 'fdt' => 'application/fdt+xml', 'fe_launch' => 'application/vnd.denovo.fcselayout-link', 'fg5' => 'application/vnd.fujitsu.oasysgp', 'fgd' => 'application/x-director', 'fh' => 'image/x-freehand', 'fh4' => 'image/x-freehand', 'fh5' => 'image/x-freehand', 'fh7' => 'image/x-freehand', 'fhc' => 'image/x-freehand', 'fig' => 'application/x-xfig', 'fits' => 'image/fits', 'flac' => 'audio/x-flac', 'fli' => 'video/x-fli', 'flo' => 'application/vnd.micrografx.flo', 'flv' => 'video/x-flv', 'flw' => 'application/vnd.kde.kivio', 'flx' => 'text/vnd.fmi.flexstor', 'fly' => 'text/vnd.fly', 'fm' => 'application/vnd.framemaker', 'fnc' => 'application/vnd.frogans.fnc', 'fo' => 'application/vnd.software602.filler.form+xml', 'for' => 'text/x-fortran', 'fpx' => 'image/vnd.fpx', 'frame' => 'application/vnd.framemaker', 'fsc' => 'application/vnd.fsc.weblaunch', 'fst' => 'image/vnd.fst', 'ftc' => 'application/vnd.fluxtime.clip', 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', 'fvt' => 'video/vnd.fvt', 'fxp' => 'application/vnd.adobe.fxp', 'fxpl' => 'application/vnd.adobe.fxp', 'fzs' => 'application/vnd.fuzzysheet', 'g2w' => 'application/vnd.geoplan', 'g3' => 'image/g3fax', 'g3w' => 'application/vnd.geospace', 'gac' => 'application/vnd.groove-account', 'gam' => 'application/x-tads', 'gbr' => 'application/rpki-ghostbusters', 'gca' => 'application/x-gca-compressed', 'gdl' => 'model/vnd.gdl', 'gdoc' => 'application/vnd.google-apps.document', 'ged' => 'text/vnd.familysearch.gedcom', 'geo' => 'application/vnd.dynageo', 'geojson' => 'application/geo+json', 'gex' => 'application/vnd.geometry-explorer', 'ggb' => 'application/vnd.geogebra.file', 'ggt' => 'application/vnd.geogebra.tool', 'ghf' => 'application/vnd.groove-help', 'gif' => 'image/gif', 'gim' => 'application/vnd.groove-identity-message', 'glb' => 'model/gltf-binary', 'gltf' => 'model/gltf+json', 'gml' => 'application/gml+xml', 'gmx' => 'application/vnd.gmx', 'gnumeric' => 'application/x-gnumeric', 'gpg' => 'application/gpg-keys', 'gph' => 'application/vnd.flographit', 'gpx' => 'application/gpx+xml', 'gqf' => 'application/vnd.grafeq', 'gqs' => 'application/vnd.grafeq', 'gram' => 'application/srgs', 'gramps' => 'application/x-gramps-xml', 'gre' => 'application/vnd.geometry-explorer', 'grv' => 'application/vnd.groove-injector', 'grxml' => 'application/srgs+xml', 'gsf' => 'application/x-font-ghostscript', 'gsheet' => 'application/vnd.google-apps.spreadsheet', 'gslides' => 'application/vnd.google-apps.presentation', 'gtar' => 'application/x-gtar', 'gtm' => 'application/vnd.groove-tool-message', 'gtw' => 'model/vnd.gtw', 'gv' => 'text/vnd.graphviz', 'gxf' => 'application/gxf', 'gxt' => 'application/vnd.geonext', 'gz' => 'application/gzip', 'gzip' => 'application/gzip', 'h' => 'text/x-c', 'h261' => 'video/h261', 'h263' => 'video/h263', 'h264' => 'video/h264', 'hal' => 'application/vnd.hal+xml', 'hbci' => 'application/vnd.hbci', 'hbs' => 'text/x-handlebars-template', 'hdd' => 'application/x-virtualbox-hdd', 'hdf' => 'application/x-hdf', 'heic' => 'image/heic', 'heics' => 'image/heic-sequence', 'heif' => 'image/heif', 'heifs' => 'image/heif-sequence', 'hej2' => 'image/hej2k', 'held' => 'application/atsc-held+xml', 'hh' => 'text/x-c', 'hjson' => 'application/hjson', 'hlp' => 'application/winhlp', 'hpgl' => 'application/vnd.hp-hpgl', 'hpid' => 'application/vnd.hp-hpid', 'hps' => 'application/vnd.hp-hps', 'hqx' => 'application/mac-binhex40', 'hsj2' => 'image/hsj2', 'htc' => 'text/x-component', 'htke' => 'application/vnd.kenameaapp', 'htm' => 'text/html', 'html' => 'text/html', 'hvd' => 'application/vnd.yamaha.hv-dic', 'hvp' => 'application/vnd.yamaha.hv-voice', 'hvs' => 'application/vnd.yamaha.hv-script', 'i2g' => 'application/vnd.intergeo', 'icc' => 'application/vnd.iccprofile', 'ice' => 'x-conference/x-cooltalk', 'icm' => 'application/vnd.iccprofile', 'ico' => 'image/x-icon', 'ics' => 'text/calendar', 'ief' => 'image/ief', 'ifb' => 'text/calendar', 'ifm' => 'application/vnd.shana.informed.formdata', 'iges' => 'model/iges', 'igl' => 'application/vnd.igloader', 'igm' => 'application/vnd.insors.igm', 'igs' => 'model/iges', 'igx' => 'application/vnd.micrografx.igx', 'iif' => 'application/vnd.shana.informed.interchange', 'img' => 'application/octet-stream', 'imp' => 'application/vnd.accpac.simply.imp', 'ims' => 'application/vnd.ms-ims', 'in' => 'text/plain', 'ini' => 'text/plain', 'ink' => 'application/inkml+xml', 'inkml' => 'application/inkml+xml', 'install' => 'application/x-install-instructions', 'iota' => 'application/vnd.astraea-software.iota', 'ipfix' => 'application/ipfix', 'ipk' => 'application/vnd.shana.informed.package', 'irm' => 'application/vnd.ibm.rights-management', 'irp' => 'application/vnd.irepository.package+xml', 'iso' => 'application/x-iso9660-image', 'itp' => 'application/vnd.shana.informed.formtemplate', 'its' => 'application/its+xml', 'ivp' => 'application/vnd.immervision-ivp', 'ivu' => 'application/vnd.immervision-ivu', 'jad' => 'text/vnd.sun.j2me.app-descriptor', 'jade' => 'text/jade', 'jam' => 'application/vnd.jam', 'jar' => 'application/java-archive', 'jardiff' => 'application/x-java-archive-diff', 'java' => 'text/x-java-source', 'jhc' => 'image/jphc', 'jisp' => 'application/vnd.jisp', 'jls' => 'image/jls', 'jlt' => 'application/vnd.hp-jlyt', 'jng' => 'image/x-jng', 'jnlp' => 'application/x-java-jnlp-file', 'joda' => 'application/vnd.joost.joda-archive', 'jp2' => 'image/jp2', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpf' => 'image/jpx', 'jpg' => 'image/jpeg', 'jpg2' => 'image/jp2', 'jpgm' => 'video/jpm', 'jpgv' => 'video/jpeg', 'jph' => 'image/jph', 'jpm' => 'video/jpm', 'jpx' => 'image/jpx', 'js' => 'application/javascript', 'json' => 'application/json', 'json5' => 'application/json5', 'jsonld' => 'application/ld+json', 'jsonml' => 'application/jsonml+json', 'jsx' => 'text/jsx', 'jt' => 'model/jt', 'jxr' => 'image/jxr', 'jxra' => 'image/jxra', 'jxrs' => 'image/jxrs', 'jxs' => 'image/jxs', 'jxsc' => 'image/jxsc', 'jxsi' => 'image/jxsi', 'jxss' => 'image/jxss', 'kar' => 'audio/midi', 'karbon' => 'application/vnd.kde.karbon', 'kdb' => 'application/octet-stream', 'kdbx' => 'application/x-keepass2', 'key' => 'application/x-iwork-keynote-sffkey', 'kfo' => 'application/vnd.kde.kformula', 'kia' => 'application/vnd.kidspiration', 'kml' => 'application/vnd.google-earth.kml+xml', 'kmz' => 'application/vnd.google-earth.kmz', 'kne' => 'application/vnd.kinar', 'knp' => 'application/vnd.kinar', 'kon' => 'application/vnd.kde.kontour', 'kpr' => 'application/vnd.kde.kpresenter', 'kpt' => 'application/vnd.kde.kpresenter', 'kpxx' => 'application/vnd.ds-keypoint', 'ksp' => 'application/vnd.kde.kspread', 'ktr' => 'application/vnd.kahootz', 'ktx' => 'image/ktx', 'ktx2' => 'image/ktx2', 'ktz' => 'application/vnd.kahootz', 'kwd' => 'application/vnd.kde.kword', 'kwt' => 'application/vnd.kde.kword', 'lasxml' => 'application/vnd.las.las+xml', 'latex' => 'application/x-latex', 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', 'les' => 'application/vnd.hhe.lesson-player', 'less' => 'text/less', 'lgr' => 'application/lgr+xml', 'lha' => 'application/octet-stream', 'link66' => 'application/vnd.route66.link66+xml', 'list' => 'text/plain', 'list3820' => 'application/vnd.ibm.modcap', 'listafp' => 'application/vnd.ibm.modcap', 'litcoffee' => 'text/coffeescript', 'lnk' => 'application/x-ms-shortcut', 'log' => 'text/plain', 'lostxml' => 'application/lost+xml', 'lrf' => 'application/octet-stream', 'lrm' => 'application/vnd.ms-lrm', 'ltf' => 'application/vnd.frogans.ltf', 'lua' => 'text/x-lua', 'luac' => 'application/x-lua-bytecode', 'lvp' => 'audio/vnd.lucent.voice', 'lwp' => 'application/vnd.lotus-wordpro', 'lzh' => 'application/octet-stream', 'm1v' => 'video/mpeg', 'm2a' => 'audio/mpeg', 'm2v' => 'video/mpeg', 'm3a' => 'audio/mpeg', 'm3u' => 'text/plain', 'm3u8' => 'application/vnd.apple.mpegurl', 'm4a' => 'audio/x-m4a', 'm4p' => 'application/mp4', 'm4s' => 'video/iso.segment', 'm4u' => 'application/vnd.mpegurl', 'm4v' => 'video/x-m4v', 'm13' => 'application/x-msmediaview', 'm14' => 'application/x-msmediaview', 'm21' => 'application/mp21', 'ma' => 'application/mathematica', 'mads' => 'application/mads+xml', 'maei' => 'application/mmt-aei+xml', 'mag' => 'application/vnd.ecowin.chart', 'maker' => 'application/vnd.framemaker', 'man' => 'text/troff', 'manifest' => 'text/cache-manifest', 'map' => 'application/json', 'mar' => 'application/octet-stream', 'markdown' => 'text/markdown', 'mathml' => 'application/mathml+xml', 'mb' => 'application/mathematica', 'mbk' => 'application/vnd.mobius.mbk', 'mbox' => 'application/mbox', 'mc1' => 'application/vnd.medcalcdata', 'mcd' => 'application/vnd.mcd', 'mcurl' => 'text/vnd.curl.mcurl', 'md' => 'text/markdown', 'mdb' => 'application/x-msaccess', 'mdi' => 'image/vnd.ms-modi', 'mdx' => 'text/mdx', 'me' => 'text/troff', 'mesh' => 'model/mesh', 'meta4' => 'application/metalink4+xml', 'metalink' => 'application/metalink+xml', 'mets' => 'application/mets+xml', 'mfm' => 'application/vnd.mfmp', 'mft' => 'application/rpki-manifest', 'mgp' => 'application/vnd.osgeo.mapguide.package', 'mgz' => 'application/vnd.proteus.magazine', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mie' => 'application/x-mie', 'mif' => 'application/vnd.mif', 'mime' => 'message/rfc822', 'mj2' => 'video/mj2', 'mjp2' => 'video/mj2', 'mjs' => 'text/javascript', 'mk3d' => 'video/x-matroska', 'mka' => 'audio/x-matroska', 'mkd' => 'text/x-markdown', 'mks' => 'video/x-matroska', 'mkv' => 'video/x-matroska', 'mlp' => 'application/vnd.dolby.mlp', 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', 'mmf' => 'application/vnd.smaf', 'mml' => 'text/mathml', 'mmr' => 'image/vnd.fujixerox.edmics-mmr', 'mng' => 'video/x-mng', 'mny' => 'application/x-msmoney', 'mobi' => 'application/x-mobipocket-ebook', 'mods' => 'application/mods+xml', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp2a' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4', 'mp4a' => 'audio/mp4', 'mp4s' => 'application/mp4', 'mp4v' => 'video/mp4', 'mp21' => 'application/mp21', 'mpc' => 'application/vnd.mophun.certificate', 'mpd' => 'application/dash+xml', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpf' => 'application/media-policy-dataset+xml', 'mpg' => 'video/mpeg', 'mpg4' => 'video/mp4', 'mpga' => 'audio/mpeg', 'mpkg' => 'application/vnd.apple.installer+xml', 'mpm' => 'application/vnd.blueice.multipass', 'mpn' => 'application/vnd.mophun.application', 'mpp' => 'application/vnd.ms-project', 'mpt' => 'application/vnd.ms-project', 'mpy' => 'application/vnd.ibm.minipay', 'mqy' => 'application/vnd.mobius.mqy', 'mrc' => 'application/marc', 'mrcx' => 'application/marcxml+xml', 'ms' => 'text/troff', 'mscml' => 'application/mediaservercontrol+xml', 'mseed' => 'application/vnd.fdsn.mseed', 'mseq' => 'application/vnd.mseq', 'msf' => 'application/vnd.epson.msf', 'msg' => 'application/vnd.ms-outlook', 'msh' => 'model/mesh', 'msi' => 'application/x-msdownload', 'msix' => 'application/msix', 'msixbundle' => 'application/msixbundle', 'msl' => 'application/vnd.mobius.msl', 'msm' => 'application/octet-stream', 'msp' => 'application/octet-stream', 'msty' => 'application/vnd.muvee.style', 'mtl' => 'model/mtl', 'mts' => 'model/vnd.mts', 'mus' => 'application/vnd.musician', 'musd' => 'application/mmt-usd+xml', 'musicxml' => 'application/vnd.recordare.musicxml+xml', 'mvb' => 'application/x-msmediaview', 'mvt' => 'application/vnd.mapbox-vector-tile', 'mwf' => 'application/vnd.mfer', 'mxf' => 'application/mxf', 'mxl' => 'application/vnd.recordare.musicxml', 'mxmf' => 'audio/mobile-xmf', 'mxml' => 'application/xv+xml', 'mxs' => 'application/vnd.triscape.mxs', 'mxu' => 'video/vnd.mpegurl', 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', 'n3' => 'text/n3', 'nb' => 'application/mathematica', 'nbp' => 'application/vnd.wolfram.player', 'nc' => 'application/x-netcdf', 'ncx' => 'application/x-dtbncx+xml', 'nfo' => 'text/x-nfo', 'ngdat' => 'application/vnd.nokia.n-gage.data', 'nitf' => 'application/vnd.nitf', 'nlu' => 'application/vnd.neurolanguage.nlu', 'nml' => 'application/vnd.enliven', 'nnd' => 'application/vnd.noblenet-directory', 'nns' => 'application/vnd.noblenet-sealer', 'nnw' => 'application/vnd.noblenet-web', 'npx' => 'image/vnd.net-fpx', 'nq' => 'application/n-quads', 'nsc' => 'application/x-conference', 'nsf' => 'application/vnd.lotus-notes', 'nt' => 'application/n-triples', 'ntf' => 'application/vnd.nitf', 'numbers' => 'application/x-iwork-numbers-sffnumbers', 'nzb' => 'application/x-nzb', 'oa2' => 'application/vnd.fujitsu.oasys2', 'oa3' => 'application/vnd.fujitsu.oasys3', 'oas' => 'application/vnd.fujitsu.oasys', 'obd' => 'application/x-msbinder', 'obgx' => 'application/vnd.openblox.game+xml', 'obj' => 'model/obj', 'oda' => 'application/oda', 'odb' => 'application/vnd.oasis.opendocument.database', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odft' => 'application/vnd.oasis.opendocument.formula-template', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odt' => 'application/vnd.oasis.opendocument.text', 'oga' => 'audio/ogg', 'ogex' => 'model/vnd.opengex', 'ogg' => 'audio/ogg', 'ogv' => 'video/ogg', 'ogx' => 'application/ogg', 'omdoc' => 'application/omdoc+xml', 'onepkg' => 'application/onenote', 'onetmp' => 'application/onenote', 'onetoc' => 'application/onenote', 'onetoc2' => 'application/onenote', 'opf' => 'application/oebps-package+xml', 'opml' => 'text/x-opml', 'oprc' => 'application/vnd.palm', 'opus' => 'audio/ogg', 'org' => 'text/x-org', 'osf' => 'application/vnd.yamaha.openscoreformat', 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', 'osm' => 'application/vnd.openstreetmap.data+xml', 'otc' => 'application/vnd.oasis.opendocument.chart-template', 'otf' => 'font/otf', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'oth' => 'application/vnd.oasis.opendocument.text-web', 'oti' => 'application/vnd.oasis.opendocument.image-template', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'ova' => 'application/x-virtualbox-ova', 'ovf' => 'application/x-virtualbox-ovf', 'owl' => 'application/rdf+xml', 'oxps' => 'application/oxps', 'oxt' => 'application/vnd.openofficeorg.extension', 'p' => 'text/x-pascal', 'p7a' => 'application/x-pkcs7-signature', 'p7b' => 'application/x-pkcs7-certificates', 'p7c' => 'application/pkcs7-mime', 'p7m' => 'application/pkcs7-mime', 'p7r' => 'application/x-pkcs7-certreqresp', 'p7s' => 'application/pkcs7-signature', 'p8' => 'application/pkcs8', 'p10' => 'application/x-pkcs10', 'p12' => 'application/x-pkcs12', 'pac' => 'application/x-ns-proxy-autoconfig', 'pages' => 'application/x-iwork-pages-sffpages', 'pas' => 'text/x-pascal', 'paw' => 'application/vnd.pawaafile', 'pbd' => 'application/vnd.powerbuilder6', 'pbm' => 'image/x-portable-bitmap', 'pcap' => 'application/vnd.tcpdump.pcap', 'pcf' => 'application/x-font-pcf', 'pcl' => 'application/vnd.hp-pcl', 'pclxl' => 'application/vnd.hp-pclxl', 'pct' => 'image/x-pict', 'pcurl' => 'application/vnd.curl.pcurl', 'pcx' => 'image/x-pcx', 'pdb' => 'application/x-pilot', 'pde' => 'text/x-processing', 'pdf' => 'application/pdf', 'pem' => 'application/x-x509-user-cert', 'pfa' => 'application/x-font-type1', 'pfb' => 'application/x-font-type1', 'pfm' => 'application/x-font-type1', 'pfr' => 'application/font-tdpfr', 'pfx' => 'application/x-pkcs12', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'pgp' => 'application/pgp', 'phar' => 'application/octet-stream', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'phtml' => 'application/x-httpd-php', 'pic' => 'image/x-pict', 'pkg' => 'application/octet-stream', 'pki' => 'application/pkixcmp', 'pkipath' => 'application/pkix-pkipath', 'pkpass' => 'application/vnd.apple.pkpass', 'pl' => 'application/x-perl', 'plb' => 'application/vnd.3gpp.pic-bw-large', 'plc' => 'application/vnd.mobius.plc', 'plf' => 'application/vnd.pocketlearn', 'pls' => 'application/pls+xml', 'pm' => 'application/x-perl', 'pml' => 'application/vnd.ctc-posml', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'portpkg' => 'application/vnd.macports.portpkg', 'pot' => 'application/vnd.ms-powerpoint', 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 'ppa' => 'application/vnd.ms-powerpoint', 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'ppd' => 'application/vnd.cups-ppd', 'ppm' => 'image/x-portable-pixmap', 'pps' => 'application/vnd.ms-powerpoint', 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'ppt' => 'application/powerpoint', 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'pqa' => 'application/vnd.palm', 'prc' => 'model/prc', 'pre' => 'application/vnd.lotus-freelance', 'prf' => 'application/pics-rules', 'provx' => 'application/provenance+xml', 'ps' => 'application/postscript', 'psb' => 'application/vnd.3gpp.pic-bw-small', 'psd' => 'application/x-photoshop', 'psf' => 'application/x-font-linux-psf', 'pskcxml' => 'application/pskc+xml', 'pti' => 'image/prs.pti', 'ptid' => 'application/vnd.pvi.ptid1', 'pub' => 'application/x-mspublisher', 'pvb' => 'application/vnd.3gpp.pic-bw-var', 'pwn' => 'application/vnd.3m.post-it-notes', 'pya' => 'audio/vnd.ms-playready.media.pya', 'pyo' => 'model/vnd.pytha.pyox', 'pyox' => 'model/vnd.pytha.pyox', 'pyv' => 'video/vnd.ms-playready.media.pyv', 'qam' => 'application/vnd.epson.quickanime', 'qbo' => 'application/vnd.intu.qbo', 'qfx' => 'application/vnd.intu.qfx', 'qps' => 'application/vnd.publishare-delta-tree', 'qt' => 'video/quicktime', 'qwd' => 'application/vnd.quark.quarkxpress', 'qwt' => 'application/vnd.quark.quarkxpress', 'qxb' => 'application/vnd.quark.quarkxpress', 'qxd' => 'application/vnd.quark.quarkxpress', 'qxl' => 'application/vnd.quark.quarkxpress', 'qxt' => 'application/vnd.quark.quarkxpress', 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'raml' => 'application/raml+yaml', 'rapd' => 'application/route-apd+xml', 'rar' => 'application/x-rar', 'ras' => 'image/x-cmu-raster', 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', 'rdf' => 'application/rdf+xml', 'rdz' => 'application/vnd.data-vision.rdz', 'relo' => 'application/p2p-overlay+xml', 'rep' => 'application/vnd.businessobjects', 'res' => 'application/x-dtbresource+xml', 'rgb' => 'image/x-rgb', 'rif' => 'application/reginfo+xml', 'rip' => 'audio/vnd.rip', 'ris' => 'application/x-research-info-systems', 'rl' => 'application/resource-lists+xml', 'rlc' => 'image/vnd.fujixerox.edmics-rlc', 'rld' => 'application/resource-lists-diff+xml', 'rm' => 'audio/x-pn-realaudio', 'rmi' => 'audio/midi', 'rmp' => 'audio/x-pn-realaudio-plugin', 'rms' => 'application/vnd.jcp.javame.midlet-rms', 'rmvb' => 'application/vnd.rn-realmedia-vbr', 'rnc' => 'application/relax-ng-compact-syntax', 'rng' => 'application/xml', 'roa' => 'application/rpki-roa', 'roff' => 'text/troff', 'rp9' => 'application/vnd.cloanto.rp9', 'rpm' => 'audio/x-pn-realaudio-plugin', 'rpss' => 'application/vnd.nokia.radio-presets', 'rpst' => 'application/vnd.nokia.radio-preset', 'rq' => 'application/sparql-query', 'rs' => 'application/rls-services+xml', 'rsa' => 'application/x-pkcs7', 'rsat' => 'application/atsc-rsat+xml', 'rsd' => 'application/rsd+xml', 'rsheet' => 'application/urc-ressheet+xml', 'rss' => 'application/rss+xml', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'run' => 'application/x-makeself', 'rusd' => 'application/route-usd+xml', 'rv' => 'video/vnd.rn-realvideo', 's' => 'text/x-asm', 's3m' => 'audio/s3m', 'saf' => 'application/vnd.yamaha.smaf-audio', 'sass' => 'text/x-sass', 'sbml' => 'application/sbml+xml', 'sc' => 'application/vnd.ibm.secure-container', 'scd' => 'application/x-msschedule', 'scm' => 'application/vnd.lotus-screencam', 'scq' => 'application/scvp-cv-request', 'scs' => 'application/scvp-cv-response', 'scss' => 'text/x-scss', 'scurl' => 'text/vnd.curl.scurl', 'sda' => 'application/vnd.stardivision.draw', 'sdc' => 'application/vnd.stardivision.calc', 'sdd' => 'application/vnd.stardivision.impress', 'sdkd' => 'application/vnd.solent.sdkm+xml', 'sdkm' => 'application/vnd.solent.sdkm+xml', 'sdp' => 'application/sdp', 'sdw' => 'application/vnd.stardivision.writer', 'sea' => 'application/octet-stream', 'see' => 'application/vnd.seemail', 'seed' => 'application/vnd.fdsn.seed', 'sema' => 'application/vnd.sema', 'semd' => 'application/vnd.semd', 'semf' => 'application/vnd.semf', 'senmlx' => 'application/senml+xml', 'sensmlx' => 'application/sensml+xml', 'ser' => 'application/java-serialized-object', 'setpay' => 'application/set-payment-initiation', 'setreg' => 'application/set-registration-initiation', 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', 'sfs' => 'application/vnd.spotfire.sfs', 'sfv' => 'text/x-sfv', 'sgi' => 'image/sgi', 'sgl' => 'application/vnd.stardivision.writer-global', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'shex' => 'text/shex', 'shf' => 'application/shf+xml', 'shtml' => 'text/html', 'sid' => 'image/x-mrsid-image', 'sieve' => 'application/sieve', 'sig' => 'application/pgp-signature', 'sil' => 'audio/silk', 'silo' => 'model/mesh', 'sis' => 'application/vnd.symbian.install', 'sisx' => 'application/vnd.symbian.install', 'sit' => 'application/x-stuffit', 'sitx' => 'application/x-stuffitx', 'siv' => 'application/sieve', 'skd' => 'application/vnd.koan', 'skm' => 'application/vnd.koan', 'skp' => 'application/vnd.koan', 'skt' => 'application/vnd.koan', 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 'slim' => 'text/slim', 'slm' => 'text/slim', 'sls' => 'application/route-s-tsid+xml', 'slt' => 'application/vnd.epson.salt', 'sm' => 'application/vnd.stepmania.stepchart', 'smf' => 'application/vnd.stardivision.math', 'smi' => 'application/smil', 'smil' => 'application/smil', 'smv' => 'video/x-smv', 'smzip' => 'application/vnd.stepmania.package', 'snd' => 'audio/basic', 'snf' => 'application/x-font-snf', 'so' => 'application/octet-stream', 'spc' => 'application/x-pkcs7-certificates', 'spdx' => 'text/spdx', 'spf' => 'application/vnd.yamaha.smaf-phrase', 'spl' => 'application/x-futuresplash', 'spot' => 'text/vnd.in3d.spot', 'spp' => 'application/scvp-vp-response', 'spq' => 'application/scvp-vp-request', 'spx' => 'audio/ogg', 'sql' => 'application/x-sql', 'src' => 'application/x-wais-source', 'srt' => 'application/x-subrip', 'sru' => 'application/sru+xml', 'srx' => 'application/sparql-results+xml', 'ssdl' => 'application/ssdl+xml', 'sse' => 'application/vnd.kodak-descriptor', 'ssf' => 'application/vnd.epson.ssf', 'ssml' => 'application/ssml+xml', 'sst' => 'application/octet-stream', 'st' => 'application/vnd.sailingtracker.track', 'stc' => 'application/vnd.sun.xml.calc.template', 'std' => 'application/vnd.sun.xml.draw.template', 'step' => 'application/STEP', 'stf' => 'application/vnd.wt.stf', 'sti' => 'application/vnd.sun.xml.impress.template', 'stk' => 'application/hyperstudio', 'stl' => 'model/stl', 'stp' => 'application/STEP', 'stpx' => 'model/step+xml', 'stpxz' => 'model/step-xml+zip', 'stpz' => 'model/step+zip', 'str' => 'application/vnd.pg.format', 'stw' => 'application/vnd.sun.xml.writer.template', 'styl' => 'text/stylus', 'stylus' => 'text/stylus', 'sub' => 'text/vnd.dvb.subtitle', 'sus' => 'application/vnd.sus-calendar', 'susp' => 'application/vnd.sus-calendar', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'svc' => 'application/vnd.dvb.service', 'svd' => 'application/vnd.svd', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', 'swa' => 'application/x-director', 'swf' => 'application/x-shockwave-flash', 'swi' => 'application/vnd.aristanetworks.swi', 'swidtag' => 'application/swid+xml', 'sxc' => 'application/vnd.sun.xml.calc', 'sxd' => 'application/vnd.sun.xml.draw', 'sxg' => 'application/vnd.sun.xml.writer.global', 'sxi' => 'application/vnd.sun.xml.impress', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 't' => 'text/troff', 't3' => 'application/x-t3vm-image', 't38' => 'image/t38', 'taglet' => 'application/vnd.mynfc', 'tao' => 'application/vnd.tao.intent-module-archive', 'tap' => 'image/vnd.tencent.tap', 'tar' => 'application/x-tar', 'tcap' => 'application/vnd.3gpp2.tcap', 'tcl' => 'application/x-tcl', 'td' => 'application/urc-targetdesc+xml', 'teacher' => 'application/vnd.smart.teacher', 'tei' => 'application/tei+xml', 'teicorpus' => 'application/tei+xml', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'text' => 'text/plain', 'tfi' => 'application/thraud+xml', 'tfm' => 'application/x-tex-tfm', 'tfx' => 'image/tiff-fx', 'tga' => 'image/x-tga', 'tgz' => 'application/x-tar', 'thmx' => 'application/vnd.ms-officetheme', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tk' => 'application/x-tcl', 'tmo' => 'application/vnd.tmobile-livetv', 'toml' => 'application/toml', 'torrent' => 'application/x-bittorrent', 'tpl' => 'application/vnd.groove-tool-template', 'tpt' => 'application/vnd.trid.tpt', 'tr' => 'text/troff', 'tra' => 'application/vnd.trueapp', 'trig' => 'application/trig', 'trm' => 'application/x-msterminal', 'ts' => 'video/mp2t', 'tsd' => 'application/timestamped-data', 'tsv' => 'text/tab-separated-values', 'ttc' => 'font/collection', 'ttf' => 'font/ttf', 'ttl' => 'text/turtle', 'ttml' => 'application/ttml+xml', 'twd' => 'application/vnd.simtech-mindmapper', 'twds' => 'application/vnd.simtech-mindmapper', 'txd' => 'application/vnd.genomatix.tuxedo', 'txf' => 'application/vnd.mobius.txf', 'txt' => 'text/plain', 'u3d' => 'model/u3d', 'u8dsn' => 'message/global-delivery-status', 'u8hdr' => 'message/global-headers', 'u8mdn' => 'message/global-disposition-notification', 'u8msg' => 'message/global', 'u32' => 'application/x-authorware-bin', 'ubj' => 'application/ubjson', 'udeb' => 'application/x-debian-package', 'ufd' => 'application/vnd.ufdl', 'ufdl' => 'application/vnd.ufdl', 'ulx' => 'application/x-glulx', 'umj' => 'application/vnd.umajin', 'unityweb' => 'application/vnd.unity', 'uo' => 'application/vnd.uoml+xml', 'uoml' => 'application/vnd.uoml+xml', 'uri' => 'text/uri-list', 'uris' => 'text/uri-list', 'urls' => 'text/uri-list', 'usda' => 'model/vnd.usda', 'usdz' => 'model/vnd.usdz+zip', 'ustar' => 'application/x-ustar', 'utz' => 'application/vnd.uiq.theme', 'uu' => 'text/x-uuencode', 'uva' => 'audio/vnd.dece.audio', 'uvd' => 'application/vnd.dece.data', 'uvf' => 'application/vnd.dece.data', 'uvg' => 'image/vnd.dece.graphic', 'uvh' => 'video/vnd.dece.hd', 'uvi' => 'image/vnd.dece.graphic', 'uvm' => 'video/vnd.dece.mobile', 'uvp' => 'video/vnd.dece.pd', 'uvs' => 'video/vnd.dece.sd', 'uvt' => 'application/vnd.dece.ttml+xml', 'uvu' => 'video/vnd.uvvu.mp4', 'uvv' => 'video/vnd.dece.video', 'uvva' => 'audio/vnd.dece.audio', 'uvvd' => 'application/vnd.dece.data', 'uvvf' => 'application/vnd.dece.data', 'uvvg' => 'image/vnd.dece.graphic', 'uvvh' => 'video/vnd.dece.hd', 'uvvi' => 'image/vnd.dece.graphic', 'uvvm' => 'video/vnd.dece.mobile', 'uvvp' => 'video/vnd.dece.pd', 'uvvs' => 'video/vnd.dece.sd', 'uvvt' => 'application/vnd.dece.ttml+xml', 'uvvu' => 'video/vnd.uvvu.mp4', 'uvvv' => 'video/vnd.dece.video', 'uvvx' => 'application/vnd.dece.unspecified', 'uvvz' => 'application/vnd.dece.zip', 'uvx' => 'application/vnd.dece.unspecified', 'uvz' => 'application/vnd.dece.zip', 'vbox' => 'application/x-virtualbox-vbox', 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', 'vcard' => 'text/vcard', 'vcd' => 'application/x-cdlink', 'vcf' => 'text/x-vcard', 'vcg' => 'application/vnd.groove-vcard', 'vcs' => 'text/x-vcalendar', 'vcx' => 'application/vnd.vcx', 'vdi' => 'application/x-virtualbox-vdi', 'vds' => 'model/vnd.sap.vds', 'vhd' => 'application/x-virtualbox-vhd', 'vis' => 'application/vnd.visionary', 'viv' => 'video/vnd.vivo', 'vlc' => 'application/videolan', 'vmdk' => 'application/x-virtualbox-vmdk', 'vob' => 'video/x-ms-vob', 'vor' => 'application/vnd.stardivision.writer', 'vox' => 'application/x-authorware-bin', 'vrml' => 'model/vrml', 'vsd' => 'application/vnd.visio', 'vsf' => 'application/vnd.vsf', 'vss' => 'application/vnd.visio', 'vst' => 'application/vnd.visio', 'vsw' => 'application/vnd.visio', 'vtf' => 'image/vnd.valve.source.texture', 'vtt' => 'text/vtt', 'vtu' => 'model/vnd.vtu', 'vxml' => 'application/voicexml+xml', 'w3d' => 'application/x-director', 'wad' => 'application/x-doom', 'wadl' => 'application/vnd.sun.wadl+xml', 'war' => 'application/java-archive', 'wasm' => 'application/wasm', 'wav' => 'audio/x-wav', 'wax' => 'audio/x-ms-wax', 'wbmp' => 'image/vnd.wap.wbmp', 'wbs' => 'application/vnd.criticaltools.wbs+xml', 'wbxml' => 'application/wbxml', 'wcm' => 'application/vnd.ms-works', 'wdb' => 'application/vnd.ms-works', 'wdp' => 'image/vnd.ms-photo', 'weba' => 'audio/webm', 'webapp' => 'application/x-web-app-manifest+json', 'webm' => 'video/webm', 'webmanifest' => 'application/manifest+json', 'webp' => 'image/webp', 'wg' => 'application/vnd.pmi.widget', 'wgsl' => 'text/wgsl', 'wgt' => 'application/widget', 'wif' => 'application/watcherinfo+xml', 'wks' => 'application/vnd.ms-works', 'wm' => 'video/x-ms-wm', 'wma' => 'audio/x-ms-wma', 'wmd' => 'application/x-ms-wmd', 'wmf' => 'image/wmf', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wmz' => 'application/x-msmetafile', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'word' => 'application/msword', 'wpd' => 'application/vnd.wordperfect', 'wpl' => 'application/vnd.ms-wpl', 'wps' => 'application/vnd.ms-works', 'wqd' => 'application/vnd.wqd', 'wri' => 'application/x-mswrite', 'wrl' => 'model/vrml', 'wsc' => 'message/vnd.wfa.wsc', 'wsdl' => 'application/wsdl+xml', 'wspolicy' => 'application/wspolicy+xml', 'wtb' => 'application/vnd.webturbo', 'wvx' => 'video/x-ms-wvx', 'x3d' => 'model/x3d+xml', 'x3db' => 'model/x3d+fastinfoset', 'x3dbz' => 'model/x3d+binary', 'x3dv' => 'model/x3d-vrml', 'x3dvz' => 'model/x3d+vrml', 'x3dz' => 'model/x3d+xml', 'x32' => 'application/x-authorware-bin', 'x_b' => 'model/vnd.parasolid.transmit.binary', 'x_t' => 'model/vnd.parasolid.transmit.text', 'xaml' => 'application/xaml+xml', 'xap' => 'application/x-silverlight-app', 'xar' => 'application/vnd.xara', 'xav' => 'application/xcap-att+xml', 'xbap' => 'application/x-ms-xbap', 'xbd' => 'application/vnd.fujixerox.docuworks.binder', 'xbm' => 'image/x-xbitmap', 'xca' => 'application/xcap-caps+xml', 'xcs' => 'application/calendar+xml', 'xdf' => 'application/xcap-diff+xml', 'xdm' => 'application/vnd.syncml.dm+xml', 'xdp' => 'application/vnd.adobe.xdp+xml', 'xdssc' => 'application/dssc+xml', 'xdw' => 'application/vnd.fujixerox.docuworks', 'xel' => 'application/xcap-el+xml', 'xenc' => 'application/xenc+xml', 'xer' => 'application/patch-ops-error+xml', 'xfdf' => 'application/xfdf', 'xfdl' => 'application/vnd.xfdl', 'xht' => 'application/xhtml+xml', 'xhtm' => 'application/vnd.pwg-xhtml-print+xml', 'xhtml' => 'application/xhtml+xml', 'xhvml' => 'application/xv+xml', 'xif' => 'image/vnd.xiff', 'xl' => 'application/excel', 'xla' => 'application/vnd.ms-excel', 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 'xlc' => 'application/vnd.ms-excel', 'xlf' => 'application/xliff+xml', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xlt' => 'application/vnd.ms-excel', 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'xlw' => 'application/vnd.ms-excel', 'xm' => 'audio/xm', 'xml' => 'application/xml', 'xns' => 'application/xcap-ns+xml', 'xo' => 'application/vnd.olpc-sugar', 'xop' => 'application/xop+xml', 'xpi' => 'application/x-xpinstall', 'xpl' => 'application/xproc+xml', 'xpm' => 'image/x-xpixmap', 'xpr' => 'application/vnd.is-xpr', 'xps' => 'application/vnd.ms-xpsdocument', 'xpw' => 'application/vnd.intercon.formnet', 'xpx' => 'application/vnd.intercon.formnet', 'xsd' => 'application/xml', 'xsf' => 'application/prs.xsf+xml', 'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml', 'xsm' => 'application/vnd.syncml+xml', 'xspf' => 'application/xspf+xml', 'xul' => 'application/vnd.mozilla.xul+xml', 'xvm' => 'application/xv+xml', 'xvml' => 'application/xv+xml', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 'xz' => 'application/x-xz', 'yaml' => 'text/yaml', 'yang' => 'application/yang', 'yin' => 'application/yin+xml', 'yml' => 'text/yaml', 'ymp' => 'text/x-suse-ymp', 'z' => 'application/x-compress', 'z1' => 'application/x-zmachine', 'z2' => 'application/x-zmachine', 'z3' => 'application/x-zmachine', 'z4' => 'application/x-zmachine', 'z5' => 'application/x-zmachine', 'z6' => 'application/x-zmachine', 'z7' => 'application/x-zmachine', 'z8' => 'application/x-zmachine', 'zaz' => 'application/vnd.zzazz.deck+xml', 'zip' => 'application/zip', 'zir' => 'application/vnd.zul', 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml', 'zsh' => 'text/x-scriptzsh']; |
9 | 8 | /** |
10 | 9 | * Determines the mimetype of a file by looking at its extension. |
@@ -11,193 +11,193 @@ |
||
11 | 11 | */ |
12 | 12 | final class AppendStream implements StreamInterface |
13 | 13 | { |
14 | - /** @var StreamInterface[] Streams being decorated */ |
|
15 | - private $streams = []; |
|
16 | - /** @var bool */ |
|
17 | - private $seekable = \true; |
|
18 | - /** @var int */ |
|
19 | - private $current = 0; |
|
20 | - /** @var int */ |
|
21 | - private $pos = 0; |
|
22 | - /** |
|
23 | - * @param StreamInterface[] $streams Streams to decorate. Each stream must |
|
24 | - * be readable. |
|
25 | - */ |
|
26 | - public function __construct(array $streams = []) |
|
27 | - { |
|
28 | - foreach ($streams as $stream) { |
|
29 | - $this->addStream($stream); |
|
30 | - } |
|
31 | - } |
|
32 | - public function __toString() : string |
|
33 | - { |
|
34 | - try { |
|
35 | - $this->rewind(); |
|
36 | - return $this->getContents(); |
|
37 | - } catch (\Throwable $e) { |
|
38 | - if (\PHP_VERSION_ID >= 70400) { |
|
39 | - throw $e; |
|
40 | - } |
|
41 | - \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR); |
|
42 | - return ''; |
|
43 | - } |
|
44 | - } |
|
45 | - /** |
|
46 | - * Add a stream to the AppendStream |
|
47 | - * |
|
48 | - * @param StreamInterface $stream Stream to append. Must be readable. |
|
49 | - * |
|
50 | - * @throws \InvalidArgumentException if the stream is not readable |
|
51 | - */ |
|
52 | - public function addStream(StreamInterface $stream) : void |
|
53 | - { |
|
54 | - if (!$stream->isReadable()) { |
|
55 | - throw new \InvalidArgumentException('Each stream must be readable'); |
|
56 | - } |
|
57 | - // The stream is only seekable if all streams are seekable |
|
58 | - if (!$stream->isSeekable()) { |
|
59 | - $this->seekable = \false; |
|
60 | - } |
|
61 | - $this->streams[] = $stream; |
|
62 | - } |
|
63 | - public function getContents() : string |
|
64 | - { |
|
65 | - return Utils::copyToString($this); |
|
66 | - } |
|
67 | - /** |
|
68 | - * Closes each attached stream. |
|
69 | - */ |
|
70 | - public function close() : void |
|
71 | - { |
|
72 | - $this->pos = $this->current = 0; |
|
73 | - $this->seekable = \true; |
|
74 | - foreach ($this->streams as $stream) { |
|
75 | - $stream->close(); |
|
76 | - } |
|
77 | - $this->streams = []; |
|
78 | - } |
|
79 | - /** |
|
80 | - * Detaches each attached stream. |
|
81 | - * |
|
82 | - * Returns null as it's not clear which underlying stream resource to return. |
|
83 | - */ |
|
84 | - public function detach() |
|
85 | - { |
|
86 | - $this->pos = $this->current = 0; |
|
87 | - $this->seekable = \true; |
|
88 | - foreach ($this->streams as $stream) { |
|
89 | - $stream->detach(); |
|
90 | - } |
|
91 | - $this->streams = []; |
|
92 | - return null; |
|
93 | - } |
|
94 | - public function tell() : int |
|
95 | - { |
|
96 | - return $this->pos; |
|
97 | - } |
|
98 | - /** |
|
99 | - * Tries to calculate the size by adding the size of each stream. |
|
100 | - * |
|
101 | - * If any of the streams do not return a valid number, then the size of the |
|
102 | - * append stream cannot be determined and null is returned. |
|
103 | - */ |
|
104 | - public function getSize() : ?int |
|
105 | - { |
|
106 | - $size = 0; |
|
107 | - foreach ($this->streams as $stream) { |
|
108 | - $s = $stream->getSize(); |
|
109 | - if ($s === null) { |
|
110 | - return null; |
|
111 | - } |
|
112 | - $size += $s; |
|
113 | - } |
|
114 | - return $size; |
|
115 | - } |
|
116 | - public function eof() : bool |
|
117 | - { |
|
118 | - return !$this->streams || $this->current >= \count($this->streams) - 1 && $this->streams[$this->current]->eof(); |
|
119 | - } |
|
120 | - public function rewind() : void |
|
121 | - { |
|
122 | - $this->seek(0); |
|
123 | - } |
|
124 | - /** |
|
125 | - * Attempts to seek to the given position. Only supports SEEK_SET. |
|
126 | - */ |
|
127 | - public function seek($offset, $whence = \SEEK_SET) : void |
|
128 | - { |
|
129 | - if (!$this->seekable) { |
|
130 | - throw new \RuntimeException('This AppendStream is not seekable'); |
|
131 | - } elseif ($whence !== \SEEK_SET) { |
|
132 | - throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); |
|
133 | - } |
|
134 | - $this->pos = $this->current = 0; |
|
135 | - // Rewind each stream |
|
136 | - foreach ($this->streams as $i => $stream) { |
|
137 | - try { |
|
138 | - $stream->rewind(); |
|
139 | - } catch (\Exception $e) { |
|
140 | - throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e); |
|
141 | - } |
|
142 | - } |
|
143 | - // Seek to the actual position by reading from each stream |
|
144 | - while ($this->pos < $offset && !$this->eof()) { |
|
145 | - $result = $this->read(\min(8096, $offset - $this->pos)); |
|
146 | - if ($result === '') { |
|
147 | - break; |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - /** |
|
152 | - * Reads from all of the appended streams until the length is met or EOF. |
|
153 | - */ |
|
154 | - public function read($length) : string |
|
155 | - { |
|
156 | - $buffer = ''; |
|
157 | - $total = \count($this->streams) - 1; |
|
158 | - $remaining = $length; |
|
159 | - $progressToNext = \false; |
|
160 | - while ($remaining > 0) { |
|
161 | - // Progress to the next stream if needed. |
|
162 | - if ($progressToNext || $this->streams[$this->current]->eof()) { |
|
163 | - $progressToNext = \false; |
|
164 | - if ($this->current === $total) { |
|
165 | - break; |
|
166 | - } |
|
167 | - ++$this->current; |
|
168 | - } |
|
169 | - $result = $this->streams[$this->current]->read($remaining); |
|
170 | - if ($result === '') { |
|
171 | - $progressToNext = \true; |
|
172 | - continue; |
|
173 | - } |
|
174 | - $buffer .= $result; |
|
175 | - $remaining = $length - \strlen($buffer); |
|
176 | - } |
|
177 | - $this->pos += \strlen($buffer); |
|
178 | - return $buffer; |
|
179 | - } |
|
180 | - public function isReadable() : bool |
|
181 | - { |
|
182 | - return \true; |
|
183 | - } |
|
184 | - public function isWritable() : bool |
|
185 | - { |
|
186 | - return \false; |
|
187 | - } |
|
188 | - public function isSeekable() : bool |
|
189 | - { |
|
190 | - return $this->seekable; |
|
191 | - } |
|
192 | - public function write($string) : int |
|
193 | - { |
|
194 | - throw new \RuntimeException('Cannot write to an AppendStream'); |
|
195 | - } |
|
196 | - /** |
|
197 | - * @return mixed |
|
198 | - */ |
|
199 | - public function getMetadata($key = null) |
|
200 | - { |
|
201 | - return $key ? null : []; |
|
202 | - } |
|
14 | + /** @var StreamInterface[] Streams being decorated */ |
|
15 | + private $streams = []; |
|
16 | + /** @var bool */ |
|
17 | + private $seekable = \true; |
|
18 | + /** @var int */ |
|
19 | + private $current = 0; |
|
20 | + /** @var int */ |
|
21 | + private $pos = 0; |
|
22 | + /** |
|
23 | + * @param StreamInterface[] $streams Streams to decorate. Each stream must |
|
24 | + * be readable. |
|
25 | + */ |
|
26 | + public function __construct(array $streams = []) |
|
27 | + { |
|
28 | + foreach ($streams as $stream) { |
|
29 | + $this->addStream($stream); |
|
30 | + } |
|
31 | + } |
|
32 | + public function __toString() : string |
|
33 | + { |
|
34 | + try { |
|
35 | + $this->rewind(); |
|
36 | + return $this->getContents(); |
|
37 | + } catch (\Throwable $e) { |
|
38 | + if (\PHP_VERSION_ID >= 70400) { |
|
39 | + throw $e; |
|
40 | + } |
|
41 | + \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR); |
|
42 | + return ''; |
|
43 | + } |
|
44 | + } |
|
45 | + /** |
|
46 | + * Add a stream to the AppendStream |
|
47 | + * |
|
48 | + * @param StreamInterface $stream Stream to append. Must be readable. |
|
49 | + * |
|
50 | + * @throws \InvalidArgumentException if the stream is not readable |
|
51 | + */ |
|
52 | + public function addStream(StreamInterface $stream) : void |
|
53 | + { |
|
54 | + if (!$stream->isReadable()) { |
|
55 | + throw new \InvalidArgumentException('Each stream must be readable'); |
|
56 | + } |
|
57 | + // The stream is only seekable if all streams are seekable |
|
58 | + if (!$stream->isSeekable()) { |
|
59 | + $this->seekable = \false; |
|
60 | + } |
|
61 | + $this->streams[] = $stream; |
|
62 | + } |
|
63 | + public function getContents() : string |
|
64 | + { |
|
65 | + return Utils::copyToString($this); |
|
66 | + } |
|
67 | + /** |
|
68 | + * Closes each attached stream. |
|
69 | + */ |
|
70 | + public function close() : void |
|
71 | + { |
|
72 | + $this->pos = $this->current = 0; |
|
73 | + $this->seekable = \true; |
|
74 | + foreach ($this->streams as $stream) { |
|
75 | + $stream->close(); |
|
76 | + } |
|
77 | + $this->streams = []; |
|
78 | + } |
|
79 | + /** |
|
80 | + * Detaches each attached stream. |
|
81 | + * |
|
82 | + * Returns null as it's not clear which underlying stream resource to return. |
|
83 | + */ |
|
84 | + public function detach() |
|
85 | + { |
|
86 | + $this->pos = $this->current = 0; |
|
87 | + $this->seekable = \true; |
|
88 | + foreach ($this->streams as $stream) { |
|
89 | + $stream->detach(); |
|
90 | + } |
|
91 | + $this->streams = []; |
|
92 | + return null; |
|
93 | + } |
|
94 | + public function tell() : int |
|
95 | + { |
|
96 | + return $this->pos; |
|
97 | + } |
|
98 | + /** |
|
99 | + * Tries to calculate the size by adding the size of each stream. |
|
100 | + * |
|
101 | + * If any of the streams do not return a valid number, then the size of the |
|
102 | + * append stream cannot be determined and null is returned. |
|
103 | + */ |
|
104 | + public function getSize() : ?int |
|
105 | + { |
|
106 | + $size = 0; |
|
107 | + foreach ($this->streams as $stream) { |
|
108 | + $s = $stream->getSize(); |
|
109 | + if ($s === null) { |
|
110 | + return null; |
|
111 | + } |
|
112 | + $size += $s; |
|
113 | + } |
|
114 | + return $size; |
|
115 | + } |
|
116 | + public function eof() : bool |
|
117 | + { |
|
118 | + return !$this->streams || $this->current >= \count($this->streams) - 1 && $this->streams[$this->current]->eof(); |
|
119 | + } |
|
120 | + public function rewind() : void |
|
121 | + { |
|
122 | + $this->seek(0); |
|
123 | + } |
|
124 | + /** |
|
125 | + * Attempts to seek to the given position. Only supports SEEK_SET. |
|
126 | + */ |
|
127 | + public function seek($offset, $whence = \SEEK_SET) : void |
|
128 | + { |
|
129 | + if (!$this->seekable) { |
|
130 | + throw new \RuntimeException('This AppendStream is not seekable'); |
|
131 | + } elseif ($whence !== \SEEK_SET) { |
|
132 | + throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); |
|
133 | + } |
|
134 | + $this->pos = $this->current = 0; |
|
135 | + // Rewind each stream |
|
136 | + foreach ($this->streams as $i => $stream) { |
|
137 | + try { |
|
138 | + $stream->rewind(); |
|
139 | + } catch (\Exception $e) { |
|
140 | + throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e); |
|
141 | + } |
|
142 | + } |
|
143 | + // Seek to the actual position by reading from each stream |
|
144 | + while ($this->pos < $offset && !$this->eof()) { |
|
145 | + $result = $this->read(\min(8096, $offset - $this->pos)); |
|
146 | + if ($result === '') { |
|
147 | + break; |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + /** |
|
152 | + * Reads from all of the appended streams until the length is met or EOF. |
|
153 | + */ |
|
154 | + public function read($length) : string |
|
155 | + { |
|
156 | + $buffer = ''; |
|
157 | + $total = \count($this->streams) - 1; |
|
158 | + $remaining = $length; |
|
159 | + $progressToNext = \false; |
|
160 | + while ($remaining > 0) { |
|
161 | + // Progress to the next stream if needed. |
|
162 | + if ($progressToNext || $this->streams[$this->current]->eof()) { |
|
163 | + $progressToNext = \false; |
|
164 | + if ($this->current === $total) { |
|
165 | + break; |
|
166 | + } |
|
167 | + ++$this->current; |
|
168 | + } |
|
169 | + $result = $this->streams[$this->current]->read($remaining); |
|
170 | + if ($result === '') { |
|
171 | + $progressToNext = \true; |
|
172 | + continue; |
|
173 | + } |
|
174 | + $buffer .= $result; |
|
175 | + $remaining = $length - \strlen($buffer); |
|
176 | + } |
|
177 | + $this->pos += \strlen($buffer); |
|
178 | + return $buffer; |
|
179 | + } |
|
180 | + public function isReadable() : bool |
|
181 | + { |
|
182 | + return \true; |
|
183 | + } |
|
184 | + public function isWritable() : bool |
|
185 | + { |
|
186 | + return \false; |
|
187 | + } |
|
188 | + public function isSeekable() : bool |
|
189 | + { |
|
190 | + return $this->seekable; |
|
191 | + } |
|
192 | + public function write($string) : int |
|
193 | + { |
|
194 | + throw new \RuntimeException('Cannot write to an AppendStream'); |
|
195 | + } |
|
196 | + /** |
|
197 | + * @return mixed |
|
198 | + */ |
|
199 | + public function getMetadata($key = null) |
|
200 | + { |
|
201 | + return $key ? null : []; |
|
202 | + } |
|
203 | 203 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare (strict_types=1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7; |
5 | 5 | |
6 | 6 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | if (\PHP_VERSION_ID >= 70400) { |
39 | 39 | throw $e; |
40 | 40 | } |
41 | - \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR); |
|
41 | + \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string)$e), \E_USER_ERROR); |
|
42 | 42 | return ''; |
43 | 43 | } |
44 | 44 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | try { |
138 | 138 | $stream->rewind(); |
139 | 139 | } catch (\Exception $e) { |
140 | - throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e); |
|
140 | + throw new \RuntimeException('Unable to seek stream '.$i.' of the AppendStream', 0, $e); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | // Seek to the actual position by reading from each stream |
@@ -9,8 +9,7 @@ |
||
9 | 9 | * |
10 | 10 | * This is a read-only stream decorator. |
11 | 11 | */ |
12 | -final class AppendStream implements StreamInterface |
|
13 | -{ |
|
12 | +final class AppendStream implements StreamInterface { |
|
14 | 13 | /** @var StreamInterface[] Streams being decorated */ |
15 | 14 | private $streams = []; |
16 | 15 | /** @var bool */ |