summaryrefslogtreecommitdiffstats
path: root/vendor/guzzlehttp/psr7/src
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-05-27 13:08:29 +0200
commit75160b12821f7f4299cce7f0b69c83c1502ae071 (patch)
tree27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/guzzlehttp/psr7/src
parentprvi-commit (diff)
download1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst
1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip
Diffstat (limited to 'vendor/guzzlehttp/psr7/src')
-rw-r--r--vendor/guzzlehttp/psr7/src/CachingStream.php8
-rw-r--r--vendor/guzzlehttp/psr7/src/Header.php142
-rw-r--r--vendor/guzzlehttp/psr7/src/Message.php504
-rw-r--r--vendor/guzzlehttp/psr7/src/MessageTrait.php483
-rw-r--r--vendor/guzzlehttp/psr7/src/MimeType.php280
-rw-r--r--vendor/guzzlehttp/psr7/src/Stream.php540
-rw-r--r--vendor/guzzlehttp/psr7/src/UriComparator.php55
-rw-r--r--vendor/guzzlehttp/psr7/src/functions_include.php12
8 files changed, 1070 insertions, 954 deletions
diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php
index 7000593..09e983d 100644
--- a/vendor/guzzlehttp/psr7/src/CachingStream.php
+++ b/vendor/guzzlehttp/psr7/src/CachingStream.php
@@ -36,7 +36,13 @@ class CachingStream implements StreamInterface
public function getSize()
{
- return max($this->stream->getSize(), $this->remoteStream->getSize());
+ $remoteSize = $this->remoteStream->getSize();
+
+ if (null === $remoteSize) {
+ return null;
+ }
+
+ return max($this->stream->getSize(), $remoteSize);
}
public function rewind()
diff --git a/vendor/guzzlehttp/psr7/src/Header.php b/vendor/guzzlehttp/psr7/src/Header.php
index 865d742..2435b82 100644
--- a/vendor/guzzlehttp/psr7/src/Header.php
+++ b/vendor/guzzlehttp/psr7/src/Header.php
@@ -1,71 +1,71 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class Header
-{
- /**
- * Parse an array of header values containing ";" separated data into an
- * array of associative arrays representing the header key value pair data
- * of the header. When a parameter does not contain a value, but just
- * contains a key, this function will inject a key with a '' string value.
- *
- * @param string|array $header Header to parse into components.
- *
- * @return array Returns the parsed header values.
- */
- public static function parse($header)
- {
- static $trimmed = "\"' \n\t\r";
- $params = $matches = [];
-
- foreach (self::normalize($header) as $val) {
- $part = [];
- foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
- if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
- $m = $matches[0];
- if (isset($m[1])) {
- $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
- } else {
- $part[] = trim($m[0], $trimmed);
- }
- }
- }
- if ($part) {
- $params[] = $part;
- }
- }
-
- return $params;
- }
-
- /**
- * Converts an array of header values that may contain comma separated
- * headers into an array of headers with no comma separated values.
- *
- * @param string|array $header Header to normalize.
- *
- * @return array Returns the normalized header field values.
- */
- public static function normalize($header)
- {
- if (!is_array($header)) {
- return array_map('trim', explode(',', $header));
- }
-
- $result = [];
- foreach ($header as $value) {
- foreach ((array) $value as $v) {
- if (strpos($v, ',') === false) {
- $result[] = $v;
- continue;
- }
- foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
- $result[] = trim($vv);
- }
- }
- }
-
- return $result;
- }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class Header
+{
+ /**
+ * Parse an array of header values containing ";" separated data into an
+ * array of associative arrays representing the header key value pair data
+ * of the header. When a parameter does not contain a value, but just
+ * contains a key, this function will inject a key with a '' string value.
+ *
+ * @param string|array $header Header to parse into components.
+ *
+ * @return array Returns the parsed header values.
+ */
+ public static function parse($header)
+ {
+ static $trimmed = "\"' \n\t\r";
+ $params = $matches = [];
+
+ foreach (self::normalize($header) as $val) {
+ $part = [];
+ foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
+ if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
+ $m = $matches[0];
+ if (isset($m[1])) {
+ $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
+ } else {
+ $part[] = trim($m[0], $trimmed);
+ }
+ }
+ }
+ if ($part) {
+ $params[] = $part;
+ }
+ }
+
+ return $params;
+ }
+
+ /**
+ * Converts an array of header values that may contain comma separated
+ * headers into an array of headers with no comma separated values.
+ *
+ * @param string|array $header Header to normalize.
+ *
+ * @return array Returns the normalized header field values.
+ */
+ public static function normalize($header)
+ {
+ if (!is_array($header)) {
+ return array_map('trim', explode(',', $header));
+ }
+
+ $result = [];
+ foreach ($header as $value) {
+ foreach ((array) $value as $v) {
+ if (strpos($v, ',') === false) {
+ $result[] = $v;
+ continue;
+ }
+ foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
+ $result[] = trim($vv);
+ }
+ }
+ }
+
+ return $result;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Message.php b/vendor/guzzlehttp/psr7/src/Message.php
index 516d1cb..01b44a0 100644
--- a/vendor/guzzlehttp/psr7/src/Message.php
+++ b/vendor/guzzlehttp/psr7/src/Message.php
@@ -1,252 +1,252 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\MessageInterface;
-use Psr\Http\Message\RequestInterface;
-use Psr\Http\Message\ResponseInterface;
-
-final class Message
-{
- /**
- * Returns the string representation of an HTTP message.
- *
- * @param MessageInterface $message Message to convert to a string.
- *
- * @return string
- */
- public static function toString(MessageInterface $message)
- {
- if ($message instanceof RequestInterface) {
- $msg = trim($message->getMethod() . ' '
- . $message->getRequestTarget())
- . ' HTTP/' . $message->getProtocolVersion();
- if (!$message->hasHeader('host')) {
- $msg .= "\r\nHost: " . $message->getUri()->getHost();
- }
- } elseif ($message instanceof ResponseInterface) {
- $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
- . $message->getStatusCode() . ' '
- . $message->getReasonPhrase();
- } else {
- throw new \InvalidArgumentException('Unknown message type');
- }
-
- foreach ($message->getHeaders() as $name => $values) {
- if (strtolower($name) === 'set-cookie') {
- foreach ($values as $value) {
- $msg .= "\r\n{$name}: " . $value;
- }
- } else {
- $msg .= "\r\n{$name}: " . implode(', ', $values);
- }
- }
-
- return "{$msg}\r\n\r\n" . $message->getBody();
- }
-
- /**
- * Get a short summary of the message body.
- *
- * Will return `null` if the response is not printable.
- *
- * @param MessageInterface $message The message to get the body summary
- * @param int $truncateAt The maximum allowed size of the summary
- *
- * @return string|null
- */
- public static function bodySummary(MessageInterface $message, $truncateAt = 120)
- {
- $body = $message->getBody();
-
- if (!$body->isSeekable() || !$body->isReadable()) {
- return null;
- }
-
- $size = $body->getSize();
-
- if ($size === 0) {
- return null;
- }
-
- $summary = $body->read($truncateAt);
- $body->rewind();
-
- if ($size > $truncateAt) {
- $summary .= ' (truncated...)';
- }
-
- // Matches any printable character, including unicode characters:
- // letters, marks, numbers, punctuation, spacing, and separators.
- if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) {
- return null;
- }
-
- return $summary;
- }
-
- /**
- * Attempts to rewind a message body and throws an exception on failure.
- *
- * The body of the message will only be rewound if a call to `tell()`
- * returns a value other than `0`.
- *
- * @param MessageInterface $message Message to rewind
- *
- * @throws \RuntimeException
- */
- public static function rewindBody(MessageInterface $message)
- {
- $body = $message->getBody();
-
- if ($body->tell()) {
- $body->rewind();
- }
- }
-
- /**
- * Parses an HTTP message into an associative array.
- *
- * The array contains the "start-line" key containing the start line of
- * the message, "headers" key containing an associative array of header
- * array values, and a "body" key containing the body of the message.
- *
- * @param string $message HTTP request or response to parse.
- *
- * @return array
- */
- public static function parseMessage($message)
- {
- if (!$message) {
- throw new \InvalidArgumentException('Invalid message');
- }
-
- $message = ltrim($message, "\r\n");
-
- $messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
-
- if ($messageParts === false || count($messageParts) !== 2) {
- throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
- }
-
- list($rawHeaders, $body) = $messageParts;
- $rawHeaders .= "\r\n"; // Put back the delimiter we split previously
- $headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
-
- if ($headerParts === false || count($headerParts) !== 2) {
- throw new \InvalidArgumentException('Invalid message: Missing status line');
- }
-
- list($startLine, $rawHeaders) = $headerParts;
-
- if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
- // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
- $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
- }
-
- /** @var array[] $headerLines */
- $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER);
-
- // If these aren't the same, then one line didn't match and there's an invalid header.
- if ($count !== substr_count($rawHeaders, "\n")) {
- // Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
- if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
- throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
- }
-
- throw new \InvalidArgumentException('Invalid header syntax');
- }
-
- $headers = [];
-
- foreach ($headerLines as $headerLine) {
- $headers[$headerLine[1]][] = $headerLine[2];
- }
-
- return [
- 'start-line' => $startLine,
- 'headers' => $headers,
- 'body' => $body,
- ];
- }
-
- /**
- * Constructs a URI for an HTTP request message.
- *
- * @param string $path Path from the start-line
- * @param array $headers Array of headers (each value an array).
- *
- * @return string
- */
- public static function parseRequestUri($path, array $headers)
- {
- $hostKey = array_filter(array_keys($headers), function ($k) {
- return strtolower($k) === 'host';
- });
-
- // If no host is found, then a full URI cannot be constructed.
- if (!$hostKey) {
- return $path;
- }
-
- $host = $headers[reset($hostKey)][0];
- $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
-
- return $scheme . '://' . $host . '/' . ltrim($path, '/');
- }
-
- /**
- * Parses a request message string into a request object.
- *
- * @param string $message Request message string.
- *
- * @return Request
- */
- public static function parseRequest($message)
- {
- $data = self::parseMessage($message);
- $matches = [];
- if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
- throw new \InvalidArgumentException('Invalid request string');
- }
- $parts = explode(' ', $data['start-line'], 3);
- $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
-
- $request = new Request(
- $parts[0],
- $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1],
- $data['headers'],
- $data['body'],
- $version
- );
-
- return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
- }
-
- /**
- * Parses a response message string into a response object.
- *
- * @param string $message Response message string.
- *
- * @return Response
- */
- public static function parseResponse($message)
- {
- $data = self::parseMessage($message);
- // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
- // between status-code and reason-phrase is required. But browsers accept
- // responses without space and reason as well.
- if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
- throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
- }
- $parts = explode(' ', $data['start-line'], 3);
-
- return new Response(
- (int) $parts[1],
- $data['headers'],
- $data['body'],
- explode('/', $parts[0])[1],
- isset($parts[2]) ? $parts[2] : null
- );
- }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\MessageInterface;
+use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
+
+final class Message
+{
+ /**
+ * Returns the string representation of an HTTP message.
+ *
+ * @param MessageInterface $message Message to convert to a string.
+ *
+ * @return string
+ */
+ public static function toString(MessageInterface $message)
+ {
+ if ($message instanceof RequestInterface) {
+ $msg = trim($message->getMethod() . ' '
+ . $message->getRequestTarget())
+ . ' HTTP/' . $message->getProtocolVersion();
+ if (!$message->hasHeader('host')) {
+ $msg .= "\r\nHost: " . $message->getUri()->getHost();
+ }
+ } elseif ($message instanceof ResponseInterface) {
+ $msg = 'HTTP/' . $message->getProtocolVersion() . ' '
+ . $message->getStatusCode() . ' '
+ . $message->getReasonPhrase();
+ } else {
+ throw new \InvalidArgumentException('Unknown message type');
+ }
+
+ foreach ($message->getHeaders() as $name => $values) {
+ if (strtolower($name) === 'set-cookie') {
+ foreach ($values as $value) {
+ $msg .= "\r\n{$name}: " . $value;
+ }
+ } else {
+ $msg .= "\r\n{$name}: " . implode(', ', $values);
+ }
+ }
+
+ return "{$msg}\r\n\r\n" . $message->getBody();
+ }
+
+ /**
+ * Get a short summary of the message body.
+ *
+ * Will return `null` if the response is not printable.
+ *
+ * @param MessageInterface $message The message to get the body summary
+ * @param int $truncateAt The maximum allowed size of the summary
+ *
+ * @return string|null
+ */
+ public static function bodySummary(MessageInterface $message, $truncateAt = 120)
+ {
+ $body = $message->getBody();
+
+ if (!$body->isSeekable() || !$body->isReadable()) {
+ return null;
+ }
+
+ $size = $body->getSize();
+
+ if ($size === 0) {
+ return null;
+ }
+
+ $summary = $body->read($truncateAt);
+ $body->rewind();
+
+ if ($size > $truncateAt) {
+ $summary .= ' (truncated...)';
+ }
+
+ // Matches any printable character, including unicode characters:
+ // letters, marks, numbers, punctuation, spacing, and separators.
+ if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) {
+ return null;
+ }
+
+ return $summary;
+ }
+
+ /**
+ * Attempts to rewind a message body and throws an exception on failure.
+ *
+ * The body of the message will only be rewound if a call to `tell()`
+ * returns a value other than `0`.
+ *
+ * @param MessageInterface $message Message to rewind
+ *
+ * @throws \RuntimeException
+ */
+ public static function rewindBody(MessageInterface $message)
+ {
+ $body = $message->getBody();
+
+ if ($body->tell()) {
+ $body->rewind();
+ }
+ }
+
+ /**
+ * Parses an HTTP message into an associative array.
+ *
+ * The array contains the "start-line" key containing the start line of
+ * the message, "headers" key containing an associative array of header
+ * array values, and a "body" key containing the body of the message.
+ *
+ * @param string $message HTTP request or response to parse.
+ *
+ * @return array
+ */
+ public static function parseMessage($message)
+ {
+ if (!$message) {
+ throw new \InvalidArgumentException('Invalid message');
+ }
+
+ $message = ltrim($message, "\r\n");
+
+ $messageParts = preg_split("/\r?\n\r?\n/", $message, 2);
+
+ if ($messageParts === false || count($messageParts) !== 2) {
+ throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
+ }
+
+ list($rawHeaders, $body) = $messageParts;
+ $rawHeaders .= "\r\n"; // Put back the delimiter we split previously
+ $headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
+
+ if ($headerParts === false || count($headerParts) !== 2) {
+ throw new \InvalidArgumentException('Invalid message: Missing status line');
+ }
+
+ list($startLine, $rawHeaders) = $headerParts;
+
+ if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
+ // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
+ $rawHeaders = preg_replace(Rfc7230::HEADER_FOLD_REGEX, ' ', $rawHeaders);
+ }
+
+ /** @var array[] $headerLines */
+ $count = preg_match_all(Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, PREG_SET_ORDER);
+
+ // If these aren't the same, then one line didn't match and there's an invalid header.
+ if ($count !== substr_count($rawHeaders, "\n")) {
+ // Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
+ if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
+ throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
+ }
+
+ throw new \InvalidArgumentException('Invalid header syntax');
+ }
+
+ $headers = [];
+
+ foreach ($headerLines as $headerLine) {
+ $headers[$headerLine[1]][] = $headerLine[2];
+ }
+
+ return [
+ 'start-line' => $startLine,
+ 'headers' => $headers,
+ 'body' => $body,
+ ];
+ }
+
+ /**
+ * Constructs a URI for an HTTP request message.
+ *
+ * @param string $path Path from the start-line
+ * @param array $headers Array of headers (each value an array).
+ *
+ * @return string
+ */
+ public static function parseRequestUri($path, array $headers)
+ {
+ $hostKey = array_filter(array_keys($headers), function ($k) {
+ return strtolower($k) === 'host';
+ });
+
+ // If no host is found, then a full URI cannot be constructed.
+ if (!$hostKey) {
+ return $path;
+ }
+
+ $host = $headers[reset($hostKey)][0];
+ $scheme = substr($host, -4) === ':443' ? 'https' : 'http';
+
+ return $scheme . '://' . $host . '/' . ltrim($path, '/');
+ }
+
+ /**
+ * Parses a request message string into a request object.
+ *
+ * @param string $message Request message string.
+ *
+ * @return Request
+ */
+ public static function parseRequest($message)
+ {
+ $data = self::parseMessage($message);
+ $matches = [];
+ if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) {
+ throw new \InvalidArgumentException('Invalid request string');
+ }
+ $parts = explode(' ', $data['start-line'], 3);
+ $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1';
+
+ $request = new Request(
+ $parts[0],
+ $matches[1] === '/' ? self::parseRequestUri($parts[1], $data['headers']) : $parts[1],
+ $data['headers'],
+ $data['body'],
+ $version
+ );
+
+ return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]);
+ }
+
+ /**
+ * Parses a response message string into a response object.
+ *
+ * @param string $message Response message string.
+ *
+ * @return Response
+ */
+ public static function parseResponse($message)
+ {
+ $data = self::parseMessage($message);
+ // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
+ // between status-code and reason-phrase is required. But browsers accept
+ // responses without space and reason as well.
+ if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
+ throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
+ }
+ $parts = explode(' ', $data['start-line'], 3);
+
+ return new Response(
+ (int) $parts[1],
+ $data['headers'],
+ $data['body'],
+ explode('/', $parts[0])[1],
+ isset($parts[2]) ? $parts[2] : null
+ );
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php
index 99203bb..87b3edf 100644
--- a/vendor/guzzlehttp/psr7/src/MessageTrait.php
+++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php
@@ -1,214 +1,269 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * Trait implementing functionality common to requests and responses.
- */
-trait MessageTrait
-{
- /** @var array Map of all registered headers, as original name => array of values */
- private $headers = [];
-
- /** @var array Map of lowercase header name => original name at registration */
- private $headerNames = [];
-
- /** @var string */
- private $protocol = '1.1';
-
- /** @var StreamInterface|null */
- private $stream;
-
- public function getProtocolVersion()
- {
- return $this->protocol;
- }
-
- public function withProtocolVersion($version)
- {
- if ($this->protocol === $version) {
- return $this;
- }
-
- $new = clone $this;
- $new->protocol = $version;
- return $new;
- }
-
- public function getHeaders()
- {
- return $this->headers;
- }
-
- public function hasHeader($header)
- {
- return isset($this->headerNames[strtolower($header)]);
- }
-
- public function getHeader($header)
- {
- $header = strtolower($header);
-
- if (!isset($this->headerNames[$header])) {
- return [];
- }
-
- $header = $this->headerNames[$header];
-
- return $this->headers[$header];
- }
-
- public function getHeaderLine($header)
- {
- return implode(', ', $this->getHeader($header));
- }
-
- public function withHeader($header, $value)
- {
- $this->assertHeader($header);
- $value = $this->normalizeHeaderValue($value);
- $normalized = strtolower($header);
-
- $new = clone $this;
- if (isset($new->headerNames[$normalized])) {
- unset($new->headers[$new->headerNames[$normalized]]);
- }
- $new->headerNames[$normalized] = $header;
- $new->headers[$header] = $value;
-
- return $new;
- }
-
- public function withAddedHeader($header, $value)
- {
- $this->assertHeader($header);
- $value = $this->normalizeHeaderValue($value);
- $normalized = strtolower($header);
-
- $new = clone $this;
- if (isset($new->headerNames[$normalized])) {
- $header = $this->headerNames[$normalized];
- $new->headers[$header] = array_merge($this->headers[$header], $value);
- } else {
- $new->headerNames[$normalized] = $header;
- $new->headers[$header] = $value;
- }
-
- return $new;
- }
-
- public function withoutHeader($header)
- {
- $normalized = strtolower($header);
-
- if (!isset($this->headerNames[$normalized])) {
- return $this;
- }
-
- $header = $this->headerNames[$normalized];
-
- $new = clone $this;
- unset($new->headers[$header], $new->headerNames[$normalized]);
-
- return $new;
- }
-
- public function getBody()
- {
- if (!$this->stream) {
- $this->stream = Utils::streamFor('');
- }
-
- return $this->stream;
- }
-
- public function withBody(StreamInterface $body)
- {
- if ($body === $this->stream) {
- return $this;
- }
-
- $new = clone $this;
- $new->stream = $body;
- return $new;
- }
-
- private function setHeaders(array $headers)
- {
- $this->headerNames = $this->headers = [];
- foreach ($headers as $header => $value) {
- if (is_int($header)) {
- // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
- // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
- $header = (string) $header;
- }
- $this->assertHeader($header);
- $value = $this->normalizeHeaderValue($value);
- $normalized = strtolower($header);
- if (isset($this->headerNames[$normalized])) {
- $header = $this->headerNames[$normalized];
- $this->headers[$header] = array_merge($this->headers[$header], $value);
- } else {
- $this->headerNames[$normalized] = $header;
- $this->headers[$header] = $value;
- }
- }
- }
-
- private function normalizeHeaderValue($value)
- {
- if (!is_array($value)) {
- return $this->trimHeaderValues([$value]);
- }
-
- if (count($value) === 0) {
- throw new \InvalidArgumentException('Header value can not be an empty array.');
- }
-
- return $this->trimHeaderValues($value);
- }
-
- /**
- * Trims whitespace from the header values.
- *
- * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
- *
- * header-field = field-name ":" OWS field-value OWS
- * OWS = *( SP / HTAB )
- *
- * @param string[] $values Header values
- *
- * @return string[] Trimmed header values
- *
- * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
- */
- private function trimHeaderValues(array $values)
- {
- return array_map(function ($value) {
- if (!is_scalar($value) && null !== $value) {
- throw new \InvalidArgumentException(sprintf(
- 'Header value must be scalar or null but %s provided.',
- is_object($value) ? get_class($value) : gettype($value)
- ));
- }
-
- return trim((string) $value, " \t");
- }, array_values($values));
- }
-
- private function assertHeader($header)
- {
- if (!is_string($header)) {
- throw new \InvalidArgumentException(sprintf(
- 'Header name must be a string but %s provided.',
- is_object($header) ? get_class($header) : gettype($header)
- ));
- }
-
- if ($header === '') {
- throw new \InvalidArgumentException('Header name can not be empty.');
- }
- }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * Trait implementing functionality common to requests and responses.
+ */
+trait MessageTrait
+{
+ /** @var array Map of all registered headers, as original name => array of values */
+ private $headers = [];
+
+ /** @var array Map of lowercase header name => original name at registration */
+ private $headerNames = [];
+
+ /** @var string */
+ private $protocol = '1.1';
+
+ /** @var StreamInterface|null */
+ private $stream;
+
+ public function getProtocolVersion()
+ {
+ return $this->protocol;
+ }
+
+ public function withProtocolVersion($version)
+ {
+ if ($this->protocol === $version) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->protocol = $version;
+ return $new;
+ }
+
+ public function getHeaders()
+ {
+ return $this->headers;
+ }
+
+ public function hasHeader($header)
+ {
+ return isset($this->headerNames[strtolower($header)]);
+ }
+
+ public function getHeader($header)
+ {
+ $header = strtolower($header);
+
+ if (!isset($this->headerNames[$header])) {
+ return [];
+ }
+
+ $header = $this->headerNames[$header];
+
+ return $this->headers[$header];
+ }
+
+ public function getHeaderLine($header)
+ {
+ return implode(', ', $this->getHeader($header));
+ }
+
+ public function withHeader($header, $value)
+ {
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+
+ $new = clone $this;
+ if (isset($new->headerNames[$normalized])) {
+ unset($new->headers[$new->headerNames[$normalized]]);
+ }
+ $new->headerNames[$normalized] = $header;
+ $new->headers[$header] = $value;
+
+ return $new;
+ }
+
+ public function withAddedHeader($header, $value)
+ {
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+
+ $new = clone $this;
+ if (isset($new->headerNames[$normalized])) {
+ $header = $this->headerNames[$normalized];
+ $new->headers[$header] = array_merge($this->headers[$header], $value);
+ } else {
+ $new->headerNames[$normalized] = $header;
+ $new->headers[$header] = $value;
+ }
+
+ return $new;
+ }
+
+ public function withoutHeader($header)
+ {
+ $normalized = strtolower($header);
+
+ if (!isset($this->headerNames[$normalized])) {
+ return $this;
+ }
+
+ $header = $this->headerNames[$normalized];
+
+ $new = clone $this;
+ unset($new->headers[$header], $new->headerNames[$normalized]);
+
+ return $new;
+ }
+
+ public function getBody()
+ {
+ if (!$this->stream) {
+ $this->stream = Utils::streamFor('');
+ }
+
+ return $this->stream;
+ }
+
+ public function withBody(StreamInterface $body)
+ {
+ if ($body === $this->stream) {
+ return $this;
+ }
+
+ $new = clone $this;
+ $new->stream = $body;
+ return $new;
+ }
+
+ private function setHeaders(array $headers)
+ {
+ $this->headerNames = $this->headers = [];
+ foreach ($headers as $header => $value) {
+ if (is_int($header)) {
+ // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
+ // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
+ $header = (string) $header;
+ }
+ $this->assertHeader($header);
+ $value = $this->normalizeHeaderValue($value);
+ $normalized = strtolower($header);
+ if (isset($this->headerNames[$normalized])) {
+ $header = $this->headerNames[$normalized];
+ $this->headers[$header] = array_merge($this->headers[$header], $value);
+ } else {
+ $this->headerNames[$normalized] = $header;
+ $this->headers[$header] = $value;
+ }
+ }
+ }
+
+ /**
+ * @param mixed $value
+ *
+ * @return string[]
+ */
+ private function normalizeHeaderValue($value)
+ {
+ if (!is_array($value)) {
+ return $this->trimAndValidateHeaderValues([$value]);
+ }
+
+ if (count($value) === 0) {
+ throw new \InvalidArgumentException('Header value can not be an empty array.');
+ }
+
+ return $this->trimAndValidateHeaderValues($value);
+ }
+
+ /**
+ * Trims whitespace from the header values.
+ *
+ * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field.
+ *
+ * header-field = field-name ":" OWS field-value OWS
+ * OWS = *( SP / HTAB )
+ *
+ * @param mixed[] $values Header values
+ *
+ * @return string[] Trimmed header values
+ *
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2.4
+ */
+ private function trimAndValidateHeaderValues(array $values)
+ {
+ return array_map(function ($value) {
+ if (!is_scalar($value) && null !== $value) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Header value must be scalar or null but %s provided.',
+ is_object($value) ? get_class($value) : gettype($value)
+ ));
+ }
+
+ $trimmed = trim((string) $value, " \t");
+ $this->assertValue($trimmed);
+
+ return $trimmed;
+ }, array_values($values));
+ }
+
+ /**
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2
+ *
+ * @param mixed $header
+ *
+ * @return void
+ */
+ private function assertHeader($header)
+ {
+ if (!is_string($header)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Header name must be a string but %s provided.',
+ is_object($header) ? get_class($header) : gettype($header)
+ ));
+ }
+
+ if ($header === '') {
+ throw new \InvalidArgumentException('Header name can not be empty.');
+ }
+
+ if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
+ throw new \InvalidArgumentException(
+ sprintf('"%s" is not valid header name.', $header)
+ );
+ }
+ }
+
+ /**
+ * @param string $value
+ *
+ * @return void
+ *
+ * @see https://tools.ietf.org/html/rfc7230#section-3.2
+ *
+ * field-value = *( field-content / obs-fold )
+ * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
+ * field-vchar = VCHAR / obs-text
+ * VCHAR = %x21-7E
+ * obs-text = %x80-FF
+ * obs-fold = CRLF 1*( SP / HTAB )
+ */
+ private function assertValue($value)
+ {
+ // The regular expression intentionally does not support the obs-fold production, because as
+ // per RFC 7230#3.2.4:
+ //
+ // A sender MUST NOT generate a message that includes
+ // line folding (i.e., that has any field-value that contains a match to
+ // the obs-fold rule) unless the message is intended for packaging
+ // within the message/http media type.
+ //
+ // Clients must not send a request with line folding and a server sending folded headers is
+ // likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
+ // folding is not likely to break any legitimate use case.
+ if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
+ throw new \InvalidArgumentException(
+ sprintf('"%s" is not valid header value.', $value)
+ );
+ }
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/MimeType.php b/vendor/guzzlehttp/psr7/src/MimeType.php
index 205c7b1..b4f5187 100644
--- a/vendor/guzzlehttp/psr7/src/MimeType.php
+++ b/vendor/guzzlehttp/psr7/src/MimeType.php
@@ -1,140 +1,140 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-final class MimeType
-{
- /**
- * Determines the mimetype of a file by looking at its extension.
- *
- * @param string $filename
- *
- * @return string|null
- */
- public static function fromFilename($filename)
- {
- return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
- }
-
- /**
- * Maps a file extensions to a mimetype.
- *
- * @param string $extension string The file extension.
- *
- * @return string|null
- *
- * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
- */
- public static function fromExtension($extension)
- {
- static $mimetypes = [
- '3gp' => 'video/3gpp',
- '7z' => 'application/x-7z-compressed',
- 'aac' => 'audio/x-aac',
- 'ai' => 'application/postscript',
- 'aif' => 'audio/x-aiff',
- 'asc' => 'text/plain',
- 'asf' => 'video/x-ms-asf',
- 'atom' => 'application/atom+xml',
- 'avi' => 'video/x-msvideo',
- 'bmp' => 'image/bmp',
- 'bz2' => 'application/x-bzip2',
- 'cer' => 'application/pkix-cert',
- 'crl' => 'application/pkix-crl',
- 'crt' => 'application/x-x509-ca-cert',
- 'css' => 'text/css',
- 'csv' => 'text/csv',
- 'cu' => 'application/cu-seeme',
- 'deb' => 'application/x-debian-package',
- 'doc' => 'application/msword',
- 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- 'dvi' => 'application/x-dvi',
- 'eot' => 'application/vnd.ms-fontobject',
- 'eps' => 'application/postscript',
- 'epub' => 'application/epub+zip',
- 'etx' => 'text/x-setext',
- 'flac' => 'audio/flac',
- 'flv' => 'video/x-flv',
- 'gif' => 'image/gif',
- 'gz' => 'application/gzip',
- 'htm' => 'text/html',
- 'html' => 'text/html',
- 'ico' => 'image/x-icon',
- 'ics' => 'text/calendar',
- 'ini' => 'text/plain',
- 'iso' => 'application/x-iso9660-image',
- 'jar' => 'application/java-archive',
- 'jpe' => 'image/jpeg',
- 'jpeg' => 'image/jpeg',
- 'jpg' => 'image/jpeg',
- 'js' => 'text/javascript',
- 'json' => 'application/json',
- 'latex' => 'application/x-latex',
- 'log' => 'text/plain',
- 'm4a' => 'audio/mp4',
- 'm4v' => 'video/mp4',
- 'mid' => 'audio/midi',
- 'midi' => 'audio/midi',
- 'mov' => 'video/quicktime',
- 'mkv' => 'video/x-matroska',
- 'mp3' => 'audio/mpeg',
- 'mp4' => 'video/mp4',
- 'mp4a' => 'audio/mp4',
- 'mp4v' => 'video/mp4',
- 'mpe' => 'video/mpeg',
- 'mpeg' => 'video/mpeg',
- 'mpg' => 'video/mpeg',
- 'mpg4' => 'video/mp4',
- 'oga' => 'audio/ogg',
- 'ogg' => 'audio/ogg',
- 'ogv' => 'video/ogg',
- 'ogx' => 'application/ogg',
- 'pbm' => 'image/x-portable-bitmap',
- 'pdf' => 'application/pdf',
- 'pgm' => 'image/x-portable-graymap',
- 'png' => 'image/png',
- 'pnm' => 'image/x-portable-anymap',
- 'ppm' => 'image/x-portable-pixmap',
- 'ppt' => 'application/vnd.ms-powerpoint',
- 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
- 'ps' => 'application/postscript',
- 'qt' => 'video/quicktime',
- 'rar' => 'application/x-rar-compressed',
- 'ras' => 'image/x-cmu-raster',
- 'rss' => 'application/rss+xml',
- 'rtf' => 'application/rtf',
- 'sgm' => 'text/sgml',
- 'sgml' => 'text/sgml',
- 'svg' => 'image/svg+xml',
- 'swf' => 'application/x-shockwave-flash',
- 'tar' => 'application/x-tar',
- 'tif' => 'image/tiff',
- 'tiff' => 'image/tiff',
- 'torrent' => 'application/x-bittorrent',
- 'ttf' => 'application/x-font-ttf',
- 'txt' => 'text/plain',
- 'wav' => 'audio/x-wav',
- 'webm' => 'video/webm',
- 'webp' => 'image/webp',
- 'wma' => 'audio/x-ms-wma',
- 'wmv' => 'video/x-ms-wmv',
- 'woff' => 'application/x-font-woff',
- 'wsdl' => 'application/wsdl+xml',
- 'xbm' => 'image/x-xbitmap',
- 'xls' => 'application/vnd.ms-excel',
- 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'xml' => 'application/xml',
- 'xpm' => 'image/x-xpixmap',
- 'xwd' => 'image/x-xwindowdump',
- 'yaml' => 'text/yaml',
- 'yml' => 'text/yaml',
- 'zip' => 'application/zip',
- ];
-
- $extension = strtolower($extension);
-
- return isset($mimetypes[$extension])
- ? $mimetypes[$extension]
- : null;
- }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+final class MimeType
+{
+ /**
+ * Determines the mimetype of a file by looking at its extension.
+ *
+ * @param string $filename
+ *
+ * @return string|null
+ */
+ public static function fromFilename($filename)
+ {
+ return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION));
+ }
+
+ /**
+ * Maps a file extensions to a mimetype.
+ *
+ * @param string $extension string The file extension.
+ *
+ * @return string|null
+ *
+ * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
+ */
+ public static function fromExtension($extension)
+ {
+ static $mimetypes = [
+ '3gp' => 'video/3gpp',
+ '7z' => 'application/x-7z-compressed',
+ 'aac' => 'audio/x-aac',
+ 'ai' => 'application/postscript',
+ 'aif' => 'audio/x-aiff',
+ 'asc' => 'text/plain',
+ 'asf' => 'video/x-ms-asf',
+ 'atom' => 'application/atom+xml',
+ 'avi' => 'video/x-msvideo',
+ 'bmp' => 'image/bmp',
+ 'bz2' => 'application/x-bzip2',
+ 'cer' => 'application/pkix-cert',
+ 'crl' => 'application/pkix-crl',
+ 'crt' => 'application/x-x509-ca-cert',
+ 'css' => 'text/css',
+ 'csv' => 'text/csv',
+ 'cu' => 'application/cu-seeme',
+ 'deb' => 'application/x-debian-package',
+ 'doc' => 'application/msword',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'dvi' => 'application/x-dvi',
+ 'eot' => 'application/vnd.ms-fontobject',
+ 'eps' => 'application/postscript',
+ 'epub' => 'application/epub+zip',
+ 'etx' => 'text/x-setext',
+ 'flac' => 'audio/flac',
+ 'flv' => 'video/x-flv',
+ 'gif' => 'image/gif',
+ 'gz' => 'application/gzip',
+ 'htm' => 'text/html',
+ 'html' => 'text/html',
+ 'ico' => 'image/x-icon',
+ 'ics' => 'text/calendar',
+ 'ini' => 'text/plain',
+ 'iso' => 'application/x-iso9660-image',
+ 'jar' => 'application/java-archive',
+ 'jpe' => 'image/jpeg',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'js' => 'text/javascript',
+ 'json' => 'application/json',
+ 'latex' => 'application/x-latex',
+ 'log' => 'text/plain',
+ 'm4a' => 'audio/mp4',
+ 'm4v' => 'video/mp4',
+ 'mid' => 'audio/midi',
+ 'midi' => 'audio/midi',
+ 'mov' => 'video/quicktime',
+ 'mkv' => 'video/x-matroska',
+ 'mp3' => 'audio/mpeg',
+ 'mp4' => 'video/mp4',
+ 'mp4a' => 'audio/mp4',
+ 'mp4v' => 'video/mp4',
+ 'mpe' => 'video/mpeg',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'mpg4' => 'video/mp4',
+ 'oga' => 'audio/ogg',
+ 'ogg' => 'audio/ogg',
+ 'ogv' => 'video/ogg',
+ 'ogx' => 'application/ogg',
+ 'pbm' => 'image/x-portable-bitmap',
+ 'pdf' => 'application/pdf',
+ 'pgm' => 'image/x-portable-graymap',
+ 'png' => 'image/png',
+ 'pnm' => 'image/x-portable-anymap',
+ 'ppm' => 'image/x-portable-pixmap',
+ 'ppt' => 'application/vnd.ms-powerpoint',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'ps' => 'application/postscript',
+ 'qt' => 'video/quicktime',
+ 'rar' => 'application/x-rar-compressed',
+ 'ras' => 'image/x-cmu-raster',
+ 'rss' => 'application/rss+xml',
+ 'rtf' => 'application/rtf',
+ 'sgm' => 'text/sgml',
+ 'sgml' => 'text/sgml',
+ 'svg' => 'image/svg+xml',
+ 'swf' => 'application/x-shockwave-flash',
+ 'tar' => 'application/x-tar',
+ 'tif' => 'image/tiff',
+ 'tiff' => 'image/tiff',
+ 'torrent' => 'application/x-bittorrent',
+ 'ttf' => 'application/x-font-ttf',
+ 'txt' => 'text/plain',
+ 'wav' => 'audio/x-wav',
+ 'webm' => 'video/webm',
+ 'webp' => 'image/webp',
+ 'wma' => 'audio/x-ms-wma',
+ 'wmv' => 'video/x-ms-wmv',
+ 'woff' => 'application/x-font-woff',
+ 'wsdl' => 'application/wsdl+xml',
+ 'xbm' => 'image/x-xbitmap',
+ 'xls' => 'application/vnd.ms-excel',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xml' => 'application/xml',
+ 'xpm' => 'image/x-xpixmap',
+ 'xwd' => 'image/x-xwindowdump',
+ 'yaml' => 'text/yaml',
+ 'yml' => 'text/yaml',
+ 'zip' => 'application/zip',
+ ];
+
+ $extension = strtolower($extension);
+
+ return isset($mimetypes[$extension])
+ ? $mimetypes[$extension]
+ : null;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php
index 3865d6d..e919517 100644
--- a/vendor/guzzlehttp/psr7/src/Stream.php
+++ b/vendor/guzzlehttp/psr7/src/Stream.php
@@ -1,270 +1,270 @@
-<?php
-
-namespace GuzzleHttp\Psr7;
-
-use Psr\Http\Message\StreamInterface;
-
-/**
- * PHP stream implementation.
- *
- * @var $stream
- */
-class Stream implements StreamInterface
-{
- /**
- * Resource modes.
- *
- * @var string
- *
- * @see http://php.net/manual/function.fopen.php
- * @see http://php.net/manual/en/function.gzopen.php
- */
- const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
- const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
-
- private $stream;
- private $size;
- private $seekable;
- private $readable;
- private $writable;
- private $uri;
- private $customMetadata;
-
- /**
- * This constructor accepts an associative array of options.
- *
- * - size: (int) If a read stream would otherwise have an indeterminate
- * size, but the size is known due to foreknowledge, then you can
- * provide that size, in bytes.
- * - metadata: (array) Any additional metadata to return when the metadata
- * of the stream is accessed.
- *
- * @param resource $stream Stream resource to wrap.
- * @param array $options Associative array of options.
- *
- * @throws \InvalidArgumentException if the stream is not a stream resource
- */
- public function __construct($stream, $options = [])
- {
- if (!is_resource($stream)) {
- throw new \InvalidArgumentException('Stream must be a resource');
- }
-
- if (isset($options['size'])) {
- $this->size = $options['size'];
- }
-
- $this->customMetadata = isset($options['metadata'])
- ? $options['metadata']
- : [];
-
- $this->stream = $stream;
- $meta = stream_get_meta_data($this->stream);
- $this->seekable = $meta['seekable'];
- $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
- $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
- $this->uri = $this->getMetadata('uri');
- }
-
- /**
- * Closes the stream when the destructed
- */
- public function __destruct()
- {
- $this->close();
- }
-
- public function __toString()
- {
- try {
- if ($this->isSeekable()) {
- $this->seek(0);
- }
- return $this->getContents();
- } catch (\Exception $e) {
- return '';
- }
- }
-
- public function getContents()
- {
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
-
- $contents = stream_get_contents($this->stream);
-
- if ($contents === false) {
- throw new \RuntimeException('Unable to read stream contents');
- }
-
- return $contents;
- }
-
- public function close()
- {
- if (isset($this->stream)) {
- if (is_resource($this->stream)) {
- fclose($this->stream);
- }
- $this->detach();
- }
- }
-
- public function detach()
- {
- if (!isset($this->stream)) {
- return null;
- }
-
- $result = $this->stream;
- unset($this->stream);
- $this->size = $this->uri = null;
- $this->readable = $this->writable = $this->seekable = false;
-
- return $result;
- }
-
- public function getSize()
- {
- if ($this->size !== null) {
- return $this->size;
- }
-
- if (!isset($this->stream)) {
- return null;
- }
-
- // Clear the stat cache if the stream has a URI
- if ($this->uri) {
- clearstatcache(true, $this->uri);
- }
-
- $stats = fstat($this->stream);
- if (isset($stats['size'])) {
- $this->size = $stats['size'];
- return $this->size;
- }
-
- return null;
- }
-
- public function isReadable()
- {
- return $this->readable;
- }
-
- public function isWritable()
- {
- return $this->writable;
- }
-
- public function isSeekable()
- {
- return $this->seekable;
- }
-
- public function eof()
- {
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
-
- return feof($this->stream);
- }
-
- public function tell()
- {
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
-
- $result = ftell($this->stream);
-
- if ($result === false) {
- throw new \RuntimeException('Unable to determine stream position');
- }
-
- return $result;
- }
-
- public function rewind()
- {
- $this->seek(0);
- }
-
- public function seek($offset, $whence = SEEK_SET)
- {
- $whence = (int) $whence;
-
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
- if (!$this->seekable) {
- throw new \RuntimeException('Stream is not seekable');
- }
- if (fseek($this->stream, $offset, $whence) === -1) {
- throw new \RuntimeException('Unable to seek to stream position '
- . $offset . ' with whence ' . var_export($whence, true));
- }
- }
-
- public function read($length)
- {
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
- if (!$this->readable) {
- throw new \RuntimeException('Cannot read from non-readable stream');
- }
- if ($length < 0) {
- throw new \RuntimeException('Length parameter cannot be negative');
- }
-
- if (0 === $length) {
- return '';
- }
-
- $string = fread($this->stream, $length);
- if (false === $string) {
- throw new \RuntimeException('Unable to read from stream');
- }
-
- return $string;
- }
-
- public function write($string)
- {
- if (!isset($this->stream)) {
- throw new \RuntimeException('Stream is detached');
- }
- if (!$this->writable) {
- throw new \RuntimeException('Cannot write to a non-writable stream');
- }
-
- // We can't know the size after writing anything
- $this->size = null;
- $result = fwrite($this->stream, $string);
-
- if ($result === false) {
- throw new \RuntimeException('Unable to write to stream');
- }
-
- return $result;
- }
-
- public function getMetadata($key = null)
- {
- if (!isset($this->stream)) {
- return $key ? null : [];
- } elseif (!$key) {
- return $this->customMetadata + stream_get_meta_data($this->stream);
- } elseif (isset($this->customMetadata[$key])) {
- return $this->customMetadata[$key];
- }
-
- $meta = stream_get_meta_data($this->stream);
-
- return isset($meta[$key]) ? $meta[$key] : null;
- }
-}
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\StreamInterface;
+
+/**
+ * PHP stream implementation.
+ *
+ * @var $stream
+ */
+class Stream implements StreamInterface
+{
+ /**
+ * Resource modes.
+ *
+ * @var string
+ *
+ * @see http://php.net/manual/function.fopen.php
+ * @see http://php.net/manual/en/function.gzopen.php
+ */
+ const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
+ const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
+
+ private $stream;
+ private $size;
+ private $seekable;
+ private $readable;
+ private $writable;
+ private $uri;
+ private $customMetadata;
+
+ /**
+ * This constructor accepts an associative array of options.
+ *
+ * - size: (int) If a read stream would otherwise have an indeterminate
+ * size, but the size is known due to foreknowledge, then you can
+ * provide that size, in bytes.
+ * - metadata: (array) Any additional metadata to return when the metadata
+ * of the stream is accessed.
+ *
+ * @param resource $stream Stream resource to wrap.
+ * @param array $options Associative array of options.
+ *
+ * @throws \InvalidArgumentException if the stream is not a stream resource
+ */
+ public function __construct($stream, $options = [])
+ {
+ if (!is_resource($stream)) {
+ throw new \InvalidArgumentException('Stream must be a resource');
+ }
+
+ if (isset($options['size'])) {
+ $this->size = $options['size'];
+ }
+
+ $this->customMetadata = isset($options['metadata'])
+ ? $options['metadata']
+ : [];
+
+ $this->stream = $stream;
+ $meta = stream_get_meta_data($this->stream);
+ $this->seekable = $meta['seekable'];
+ $this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
+ $this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
+ $this->uri = $this->getMetadata('uri');
+ }
+
+ /**
+ * Closes the stream when the destructed
+ */
+ public function __destruct()
+ {
+ $this->close();
+ }
+
+ public function __toString()
+ {
+ try {
+ if ($this->isSeekable()) {
+ $this->seek(0);
+ }
+ return $this->getContents();
+ } catch (\Exception $e) {
+ return '';
+ }
+ }
+
+ public function getContents()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ $contents = stream_get_contents($this->stream);
+
+ if ($contents === false) {
+ throw new \RuntimeException('Unable to read stream contents');
+ }
+
+ return $contents;
+ }
+
+ public function close()
+ {
+ if (isset($this->stream)) {
+ if (is_resource($this->stream)) {
+ fclose($this->stream);
+ }
+ $this->detach();
+ }
+ }
+
+ public function detach()
+ {
+ if (!isset($this->stream)) {
+ return null;
+ }
+
+ $result = $this->stream;
+ unset($this->stream);
+ $this->size = $this->uri = null;
+ $this->readable = $this->writable = $this->seekable = false;
+
+ return $result;
+ }
+
+ public function getSize()
+ {
+ if ($this->size !== null) {
+ return $this->size;
+ }
+
+ if (!isset($this->stream)) {
+ return null;
+ }
+
+ // Clear the stat cache if the stream has a URI
+ if ($this->uri) {
+ clearstatcache(true, $this->uri);
+ }
+
+ $stats = fstat($this->stream);
+ if (isset($stats['size'])) {
+ $this->size = $stats['size'];
+ return $this->size;
+ }
+
+ return null;
+ }
+
+ public function isReadable()
+ {
+ return $this->readable;
+ }
+
+ public function isWritable()
+ {
+ return $this->writable;
+ }
+
+ public function isSeekable()
+ {
+ return $this->seekable;
+ }
+
+ public function eof()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ return feof($this->stream);
+ }
+
+ public function tell()
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+
+ $result = ftell($this->stream);
+
+ if ($result === false) {
+ throw new \RuntimeException('Unable to determine stream position');
+ }
+
+ return $result;
+ }
+
+ public function rewind()
+ {
+ $this->seek(0);
+ }
+
+ public function seek($offset, $whence = SEEK_SET)
+ {
+ $whence = (int) $whence;
+
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->seekable) {
+ throw new \RuntimeException('Stream is not seekable');
+ }
+ if (fseek($this->stream, $offset, $whence) === -1) {
+ throw new \RuntimeException('Unable to seek to stream position '
+ . $offset . ' with whence ' . var_export($whence, true));
+ }
+ }
+
+ public function read($length)
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->readable) {
+ throw new \RuntimeException('Cannot read from non-readable stream');
+ }
+ if ($length < 0) {
+ throw new \RuntimeException('Length parameter cannot be negative');
+ }
+
+ if (0 === $length) {
+ return '';
+ }
+
+ $string = fread($this->stream, $length);
+ if (false === $string) {
+ throw new \RuntimeException('Unable to read from stream');
+ }
+
+ return $string;
+ }
+
+ public function write($string)
+ {
+ if (!isset($this->stream)) {
+ throw new \RuntimeException('Stream is detached');
+ }
+ if (!$this->writable) {
+ throw new \RuntimeException('Cannot write to a non-writable stream');
+ }
+
+ // We can't know the size after writing anything
+ $this->size = null;
+ $result = fwrite($this->stream, $string);
+
+ if ($result === false) {
+ throw new \RuntimeException('Unable to write to stream');
+ }
+
+ return $result;
+ }
+
+ public function getMetadata($key = null)
+ {
+ if (!isset($this->stream)) {
+ return $key ? null : [];
+ } elseif (!$key) {
+ return $this->customMetadata + stream_get_meta_data($this->stream);
+ } elseif (isset($this->customMetadata[$key])) {
+ return $this->customMetadata[$key];
+ }
+
+ $meta = stream_get_meta_data($this->stream);
+
+ return isset($meta[$key]) ? $meta[$key] : null;
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/UriComparator.php b/vendor/guzzlehttp/psr7/src/UriComparator.php
new file mode 100644
index 0000000..67b86f7
--- /dev/null
+++ b/vendor/guzzlehttp/psr7/src/UriComparator.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace GuzzleHttp\Psr7;
+
+use Psr\Http\Message\UriInterface;
+
+/**
+ * Provides methods to determine if a modified URL should be considered cross-origin.
+ *
+ * @author Graham Campbell
+ */
+final class UriComparator
+{
+ /**
+ * Determines if a modified URL should be considered cross-origin with
+ * respect to an original URL.
+ *
+ * @return bool
+ */
+ public static function isCrossOrigin(UriInterface $original, UriInterface $modified)
+ {
+ if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
+ return true;
+ }
+
+ if ($original->getScheme() !== $modified->getScheme()) {
+ return true;
+ }
+
+ if (self::computePort($original) !== self::computePort($modified)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @return int
+ */
+ private static function computePort(UriInterface $uri)
+ {
+ $port = $uri->getPort();
+
+ if (null !== $port) {
+ return $port;
+ }
+
+ return 'https' === $uri->getScheme() ? 443 : 80;
+ }
+
+ private function __construct()
+ {
+ // cannot be instantiated
+ }
+}
diff --git a/vendor/guzzlehttp/psr7/src/functions_include.php b/vendor/guzzlehttp/psr7/src/functions_include.php
index 96a4a83..e187958 100644
--- a/vendor/guzzlehttp/psr7/src/functions_include.php
+++ b/vendor/guzzlehttp/psr7/src/functions_include.php
@@ -1,6 +1,6 @@
-<?php
-
-// Don't redefine the functions if included multiple times.
-if (!function_exists('GuzzleHttp\Psr7\str')) {
- require __DIR__ . '/functions.php';
-}
+<?php
+
+// Don't redefine the functions if included multiple times.
+if (!function_exists('GuzzleHttp\Psr7\str')) {
+ require __DIR__ . '/functions.php';
+}