mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 04:59:49 +09:00
Update to laravel 7
This commit is contained in:
11
vendor/php-http/message/src/Authentication.php
vendored
11
vendor/php-http/message/src/Authentication.php
vendored
@@ -5,18 +5,21 @@ namespace Http\Message;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Authenticate a PSR-7 Request.
|
||||
* Add authentication information to a PSR-7 Request.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*/
|
||||
interface Authentication
|
||||
{
|
||||
/**
|
||||
* Authenticates a request.
|
||||
* Alter the request to add the authentication credentials.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* To do that, the implementation might use pre-stored credentials or do
|
||||
* separate HTTP requests to obtain a valid token.
|
||||
*
|
||||
* @return RequestInterface
|
||||
* @param RequestInterface $request The request without authentication information
|
||||
*
|
||||
* @return RequestInterface The request with added authentication information
|
||||
*/
|
||||
public function authenticate(RequestInterface $request);
|
||||
}
|
||||
|
||||
36
vendor/php-http/message/src/Authentication/Header.php
vendored
Normal file
36
vendor/php-http/message/src/Authentication/Header.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Http\Message\Authentication;
|
||||
|
||||
use Http\Message\Authentication;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
class Header implements Authentication
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string|string[]
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param string|string[] $value
|
||||
*/
|
||||
public function __construct(string $name, $value)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function authenticate(RequestInterface $request)
|
||||
{
|
||||
return $request->withHeader($this->name, $this->value);
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,6 @@ final class Matching implements Authentication
|
||||
*/
|
||||
private $matcher;
|
||||
|
||||
/**
|
||||
* @param Authentication $authentication
|
||||
* @param callable|null $matcher
|
||||
*/
|
||||
public function __construct(Authentication $authentication, callable $matcher = null)
|
||||
{
|
||||
if (is_null($matcher)) {
|
||||
@@ -58,8 +54,7 @@ final class Matching implements Authentication
|
||||
/**
|
||||
* Creates a matching authentication for an URL.
|
||||
*
|
||||
* @param Authentication $authentication
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -20,9 +20,6 @@ final class QueryParam implements Authentication
|
||||
*/
|
||||
private $params = [];
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*/
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->params = $params;
|
||||
@@ -41,7 +38,7 @@ final class QueryParam implements Authentication
|
||||
|
||||
$params = array_merge($params, $this->params);
|
||||
|
||||
$query = http_build_query($params, null, '&');
|
||||
$query = http_build_query($params, '', '&');
|
||||
|
||||
$uri = $uri->withQuery($query);
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ final class RequestConditional implements Authentication
|
||||
*/
|
||||
private $authentication;
|
||||
|
||||
/**
|
||||
* @param RequestMatcher $requestMatcher
|
||||
* @param Authentication $authentication
|
||||
*/
|
||||
public function __construct(RequestMatcher $requestMatcher, Authentication $authentication)
|
||||
{
|
||||
$this->requestMatcher = $requestMatcher;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Http\Message\Authentication;
|
||||
|
||||
use Http\Message\Authentication;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
@@ -22,14 +23,24 @@ final class Wsse implements Authentication
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $hashAlgorithm;
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param string $hashAlgorithm To use a better hashing algorithm than the weak sha1, pass the algorithm to use, e.g. "sha512"
|
||||
*/
|
||||
public function __construct($username, $password)
|
||||
public function __construct($username, $password, $hashAlgorithm = 'sha1')
|
||||
{
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
if (false === in_array($hashAlgorithm, hash_algos())) {
|
||||
throw new InvalidArgumentException(sprintf('Unaccepted hashing algorithm: %s', $hashAlgorithm));
|
||||
}
|
||||
$this->hashAlgorithm = $hashAlgorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,10 +48,9 @@ final class Wsse implements Authentication
|
||||
*/
|
||||
public function authenticate(RequestInterface $request)
|
||||
{
|
||||
// TODO: generate better nonce?
|
||||
$nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16);
|
||||
$created = date('c');
|
||||
$digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true));
|
||||
$digest = base64_encode(hash($this->hashAlgorithm, base64_decode($nonce).$created.$this->password, true));
|
||||
|
||||
$wsse = sprintf(
|
||||
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
|
||||
|
||||
@@ -18,8 +18,6 @@ class ResponseBuilder
|
||||
|
||||
/**
|
||||
* Create builder for the given response.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
*/
|
||||
public function __construct(ResponseInterface $response)
|
||||
{
|
||||
@@ -39,12 +37,12 @@ class ResponseBuilder
|
||||
/**
|
||||
* Add headers represented by an array of header lines.
|
||||
*
|
||||
* @param string[] $headers Response headers as array of header lines.
|
||||
* @param string[] $headers response headers as array of header lines
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \UnexpectedValueException For invalid header values.
|
||||
* @throws \InvalidArgumentException For invalid status code arguments.
|
||||
* @throws \UnexpectedValueException for invalid header values
|
||||
* @throws \InvalidArgumentException for invalid status code arguments
|
||||
*/
|
||||
public function setHeadersFromArray(array $headers)
|
||||
{
|
||||
@@ -66,12 +64,12 @@ class ResponseBuilder
|
||||
/**
|
||||
* Add headers represented by a single string.
|
||||
*
|
||||
* @param string $headers Response headers as single string.
|
||||
* @param string $headers response headers as single string
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException if $headers is not a string on object with __toString()
|
||||
* @throws \UnexpectedValueException For invalid header values.
|
||||
* @throws \UnexpectedValueException for invalid header values
|
||||
*/
|
||||
public function setHeadersFromString($headers)
|
||||
{
|
||||
@@ -95,11 +93,11 @@ class ResponseBuilder
|
||||
/**
|
||||
* Set response status from a status string.
|
||||
*
|
||||
* @param string $statusLine Response status as a string.
|
||||
* @param string $statusLine response status as a string
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException For invalid status line.
|
||||
* @throws \InvalidArgumentException for invalid status line
|
||||
*/
|
||||
public function setStatus($statusLine)
|
||||
{
|
||||
@@ -121,11 +119,11 @@ class ResponseBuilder
|
||||
/**
|
||||
* Add header represented by a string.
|
||||
*
|
||||
* @param string $headerLine Response header as a string.
|
||||
* @param string $headerLine response header as a string
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws \InvalidArgumentException For invalid header names or values.
|
||||
* @throws \InvalidArgumentException for invalid header names or values
|
||||
*/
|
||||
public function addHeader($headerLine)
|
||||
{
|
||||
|
||||
10
vendor/php-http/message/src/Cookie.php
vendored
10
vendor/php-http/message/src/Cookie.php
vendored
@@ -63,7 +63,7 @@ final class Cookie
|
||||
* @param bool $httpOnly
|
||||
* @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided.
|
||||
*
|
||||
* @throws \InvalidArgumentException If name, value or max age is not valid.
|
||||
* @throws \InvalidArgumentException if name, value or max age is not valid
|
||||
*/
|
||||
public function __construct(
|
||||
$name,
|
||||
@@ -226,8 +226,6 @@ final class Cookie
|
||||
/**
|
||||
* Sets the expires.
|
||||
*
|
||||
* @param \DateTime|null $expires
|
||||
*
|
||||
* @return Cookie
|
||||
*/
|
||||
public function withExpires(\DateTime $expires = null)
|
||||
@@ -435,7 +433,7 @@ final class Cookie
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @throws \InvalidArgumentException If the name is empty or contains invalid characters.
|
||||
* @throws \InvalidArgumentException if the name is empty or contains invalid characters
|
||||
*/
|
||||
private function validateName($name)
|
||||
{
|
||||
@@ -456,7 +454,7 @@ final class Cookie
|
||||
*
|
||||
* @param string|null $value
|
||||
*
|
||||
* @throws \InvalidArgumentException If the value contains invalid characters.
|
||||
* @throws \InvalidArgumentException if the value contains invalid characters
|
||||
*/
|
||||
private function validateValue($value)
|
||||
{
|
||||
@@ -472,7 +470,7 @@ final class Cookie
|
||||
*
|
||||
* @param int|null $maxAge
|
||||
*
|
||||
* @throws \InvalidArgumentException If the Max-Age is not an empty or integer value.
|
||||
* @throws \InvalidArgumentException if the Max-Age is not an empty or integer value
|
||||
*/
|
||||
private function validateMaxAge($maxAge)
|
||||
{
|
||||
|
||||
18
vendor/php-http/message/src/CookieJar.php
vendored
18
vendor/php-http/message/src/CookieJar.php
vendored
@@ -10,9 +10,9 @@ namespace Http\Message;
|
||||
final class CookieJar implements \Countable, \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var \SplObjectStorage
|
||||
* @var \SplObjectStorage<object, mixed>
|
||||
*/
|
||||
protected $cookies;
|
||||
private $cookies;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -22,8 +22,6 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Checks if there is a cookie.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCookie(Cookie $cookie)
|
||||
@@ -33,8 +31,6 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Adds a cookie.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
*/
|
||||
public function addCookie(Cookie $cookie)
|
||||
{
|
||||
@@ -57,8 +53,6 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Removes a cookie.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
*/
|
||||
public function removeCookie(Cookie $cookie)
|
||||
{
|
||||
@@ -82,8 +76,6 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Returns all matching cookies.
|
||||
*
|
||||
* @param Cookie $cookie
|
||||
*
|
||||
* @return Cookie[]
|
||||
*/
|
||||
public function getMatchingCookies(Cookie $cookie)
|
||||
@@ -98,11 +90,9 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* Finds matching cookies based on a callable.
|
||||
*
|
||||
* @param callable $match
|
||||
*
|
||||
* @return Cookie[]
|
||||
*/
|
||||
protected function findMatchingCookies(callable $match)
|
||||
private function findMatchingCookies(callable $match)
|
||||
{
|
||||
$cookies = [];
|
||||
|
||||
@@ -205,6 +195,7 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return $this->cookies->count();
|
||||
@@ -213,6 +204,7 @@ final class CookieJar implements \Countable, \IteratorAggregate
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return clone $this->cookies;
|
||||
|
||||
2
vendor/php-http/message/src/CookieUtil.php
vendored
2
vendor/php-http/message/src/CookieUtil.php
vendored
@@ -30,7 +30,7 @@ final class CookieUtil
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @throws UnexpectedValueException if we cannot parse the cookie date string.
|
||||
* @throws UnexpectedValueException if we cannot parse the cookie date string
|
||||
*/
|
||||
public static function parseDate($dateValue)
|
||||
{
|
||||
|
||||
@@ -17,8 +17,6 @@ trait RequestDecorator
|
||||
/**
|
||||
* Exchanges the underlying request with another.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function withRequest(RequestInterface $request)
|
||||
|
||||
@@ -16,8 +16,6 @@ trait ResponseDecorator
|
||||
/**
|
||||
* Exchanges the underlying response with another.
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function withResponse(ResponseInterface $response)
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class CompressStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class DecompressStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class DeflateStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ class Chunk extends \php_user_filter
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
{
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
|
||||
@@ -13,12 +13,11 @@ use Psr\Http\Message\StreamInterface;
|
||||
*/
|
||||
abstract class FilteredStream implements StreamInterface
|
||||
{
|
||||
const BUFFER_SIZE = 8192;
|
||||
|
||||
use StreamDecorator {
|
||||
rewind as private doRewind;
|
||||
seek as private doSeek;
|
||||
}
|
||||
const BUFFER_SIZE = 8192;
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
@@ -54,9 +53,8 @@ abstract class FilteredStream implements StreamInterface
|
||||
protected $buffer = '';
|
||||
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param mixed|null $readFilterOptions
|
||||
* @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0
|
||||
* @param mixed|null $readFilterOptions
|
||||
* @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class GzipDecodeStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class GzipEncodeStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
@@ -13,8 +13,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
class InflateStream extends FilteredStream
|
||||
{
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param int $level
|
||||
* @param int $level
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, $level = -1)
|
||||
{
|
||||
|
||||
11
vendor/php-http/message/src/Formatter.php
vendored
11
vendor/php-http/message/src/Formatter.php
vendored
@@ -9,22 +9,25 @@ use Psr\Http\Message\ResponseInterface;
|
||||
* Formats a request and/or a response as a string.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*
|
||||
* The formatResponseForRequest method will be added to this interface in the next major version, replacing the formatRequest method.
|
||||
* Meanwhile, callers SHOULD check the formatter for the existence of formatResponseForRequest and call that if available.
|
||||
*
|
||||
* @method string formatResponseForRequest(ResponseInterface $response, RequestInterface $request) Formats a response in context of its request.
|
||||
*/
|
||||
interface Formatter
|
||||
{
|
||||
/**
|
||||
* Formats a request.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatRequest(RequestInterface $request);
|
||||
|
||||
/**
|
||||
* Formats a response.
|
||||
* @deprecated since 1.13, use formatResponseForRequest() instead
|
||||
*
|
||||
* @param ResponseInterface $response
|
||||
* Formats a response.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -36,10 +36,14 @@ class CurlCommandFormatter implements Formatter
|
||||
|
||||
$body = $request->getBody();
|
||||
if ($body->getSize() > 0) {
|
||||
if ($body->isSeekable()) {
|
||||
// escapeshellarg argument max length on Windows, but longer body in curl command would be impractical anyways
|
||||
if ($body->getSize() > 8192) {
|
||||
$data = '[too long stream omitted]';
|
||||
} elseif ($body->isSeekable()) {
|
||||
$data = $body->__toString();
|
||||
$body->rewind();
|
||||
if (preg_match('/[\x00-\x1F\x7F]/', $data)) {
|
||||
// all non-printable ASCII characters and <DEL> except for \t, \r, \n
|
||||
if (preg_match('/([\x00-\x09\x0C\x0E-\x1F\x7F])/', $data)) {
|
||||
$data = '[binary stream omitted]';
|
||||
}
|
||||
} else {
|
||||
@@ -65,10 +69,18 @@ class CurlCommandFormatter implements Formatter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RequestInterface $request
|
||||
* Formats a response in context of its request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatResponseForRequest(ResponseInterface $response, RequestInterface $request)
|
||||
{
|
||||
return $this->formatResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function getHeadersAsCommandOptions(RequestInterface $request)
|
||||
{
|
||||
$command = '';
|
||||
|
||||
@@ -17,16 +17,23 @@ class FullHttpMessageFormatter implements Formatter
|
||||
/**
|
||||
* The maximum length of the body.
|
||||
*
|
||||
* @var int
|
||||
* @var int|null
|
||||
*/
|
||||
private $maxBodyLength;
|
||||
|
||||
/**
|
||||
* @param int $maxBodyLength
|
||||
* @var string
|
||||
*/
|
||||
public function __construct($maxBodyLength = 1000)
|
||||
private $binaryDetectionRegex;
|
||||
|
||||
/**
|
||||
* @param int|null $maxBodyLength
|
||||
* @param string $binaryDetectionRegex By default, this is all non-printable ASCII characters and <DEL> except for \t, \r, \n
|
||||
*/
|
||||
public function __construct($maxBodyLength = 1000, string $binaryDetectionRegex = '/([\x00-\x09\x0C\x0E-\x1F\x7F])/')
|
||||
{
|
||||
$this->maxBodyLength = $maxBodyLength;
|
||||
$this->binaryDetectionRegex = $binaryDetectionRegex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,25 +74,43 @@ class FullHttpMessageFormatter implements Formatter
|
||||
return $this->addBody($response, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a response in context of its request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatResponseForRequest(ResponseInterface $response, RequestInterface $request)
|
||||
{
|
||||
return $this->formatResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the message body if the stream is seekable.
|
||||
*
|
||||
* @param MessageInterface $request
|
||||
* @param string $message
|
||||
* @param string $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function addBody(MessageInterface $request, $message)
|
||||
{
|
||||
$message .= "\n";
|
||||
$stream = $request->getBody();
|
||||
if (!$stream->isSeekable() || 0 === $this->maxBodyLength) {
|
||||
// Do not read the stream
|
||||
$message .= "\n";
|
||||
} else {
|
||||
$message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength);
|
||||
$stream->rewind();
|
||||
return $message;
|
||||
}
|
||||
|
||||
return $message;
|
||||
$data = $stream->__toString();
|
||||
$stream->rewind();
|
||||
|
||||
if (preg_match($this->binaryDetectionRegex, $data)) {
|
||||
return $message.'[binary stream omitted]';
|
||||
}
|
||||
|
||||
if (null === $this->maxBodyLength) {
|
||||
return $message.$data;
|
||||
}
|
||||
|
||||
return $message.mb_substr($data, 0, $this->maxBodyLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,14 @@ class SimpleFormatter implements Formatter
|
||||
$response->getProtocolVersion()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a response in context of its request.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function formatResponseForRequest(ResponseInterface $response, RequestInterface $request)
|
||||
{
|
||||
return $this->formatResponse($response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
|
||||
namespace Http\Message\MessageFactory;
|
||||
|
||||
use Http\Message\StreamFactory\DiactorosStreamFactory;
|
||||
use Http\Message\MessageFactory;
|
||||
use Zend\Diactoros\Request;
|
||||
use Zend\Diactoros\Response;
|
||||
use Http\Message\StreamFactory\DiactorosStreamFactory;
|
||||
use Laminas\Diactoros\Request as LaminasRequest;
|
||||
use Laminas\Diactoros\Response as LaminasResponse;
|
||||
use Zend\Diactoros\Request as ZendRequest;
|
||||
use Zend\Diactoros\Response as ZendResponse;
|
||||
|
||||
/**
|
||||
* Creates Diactoros messages.
|
||||
*
|
||||
* @author GeLo <geloen.eric@gmail.com>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Diactoros PSR-17 factory
|
||||
*/
|
||||
final class DiactorosMessageFactory implements MessageFactory
|
||||
{
|
||||
@@ -34,7 +38,16 @@ final class DiactorosMessageFactory implements MessageFactory
|
||||
$body = null,
|
||||
$protocolVersion = '1.1'
|
||||
) {
|
||||
return (new Request(
|
||||
if (class_exists(LaminasRequest::class)) {
|
||||
return (new LaminasRequest(
|
||||
$uri,
|
||||
$method,
|
||||
$this->streamFactory->createStream($body),
|
||||
$headers
|
||||
))->withProtocolVersion($protocolVersion);
|
||||
}
|
||||
|
||||
return (new ZendRequest(
|
||||
$uri,
|
||||
$method,
|
||||
$this->streamFactory->createStream($body),
|
||||
@@ -52,7 +65,15 @@ final class DiactorosMessageFactory implements MessageFactory
|
||||
$body = null,
|
||||
$protocolVersion = '1.1'
|
||||
) {
|
||||
return (new Response(
|
||||
if (class_exists(LaminasResponse::class)) {
|
||||
return (new LaminasResponse(
|
||||
$this->streamFactory->createStream($body),
|
||||
$statusCode,
|
||||
$headers
|
||||
))->withProtocolVersion($protocolVersion);
|
||||
}
|
||||
|
||||
return (new ZendResponse(
|
||||
$this->streamFactory->createStream($body),
|
||||
$statusCode,
|
||||
$headers
|
||||
|
||||
@@ -10,6 +10,8 @@ use Http\Message\MessageFactory;
|
||||
* Creates Guzzle messages.
|
||||
*
|
||||
* @author Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Guzzle PSR-17 factory
|
||||
*/
|
||||
final class GuzzleMessageFactory implements MessageFactory
|
||||
{
|
||||
|
||||
@@ -2,17 +2,19 @@
|
||||
|
||||
namespace Http\Message\MessageFactory;
|
||||
|
||||
use Http\Message\MessageFactory;
|
||||
use Http\Message\StreamFactory\SlimStreamFactory;
|
||||
use Http\Message\UriFactory\SlimUriFactory;
|
||||
use Http\Message\MessageFactory;
|
||||
use Slim\Http\Headers;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use Slim\Http\Headers;
|
||||
|
||||
/**
|
||||
* Creates Slim 3 messages.
|
||||
*
|
||||
* @author Mika Tuupola <tuupola@appelsiini.net>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Slim PSR-17 factory
|
||||
*/
|
||||
final class SlimMessageFactory implements MessageFactory
|
||||
{
|
||||
|
||||
@@ -17,9 +17,6 @@ final class CallbackRequestMatcher implements RequestMatcher
|
||||
*/
|
||||
private $callback;
|
||||
|
||||
/**
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function __construct(callable $callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
@@ -203,6 +203,9 @@ class BufferedStream implements StreamInterface
|
||||
if (null === $this->resource) {
|
||||
throw new \RuntimeException('Cannot read on a detached stream');
|
||||
}
|
||||
if ($length < 0) {
|
||||
throw new \InvalidArgumentException('Can not read a negative amount of bytes');
|
||||
}
|
||||
|
||||
$read = '';
|
||||
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
namespace Http\Message\StreamFactory;
|
||||
|
||||
use Http\Message\StreamFactory;
|
||||
use Laminas\Diactoros\Stream as LaminasStream;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Zend\Diactoros\Stream;
|
||||
use Zend\Diactoros\Stream as ZendStream;
|
||||
|
||||
/**
|
||||
* Creates Diactoros streams.
|
||||
*
|
||||
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Diactoros PSR-17 factory
|
||||
*/
|
||||
final class DiactorosStreamFactory implements StreamFactory
|
||||
{
|
||||
@@ -23,10 +26,19 @@ final class DiactorosStreamFactory implements StreamFactory
|
||||
}
|
||||
|
||||
if (is_resource($body)) {
|
||||
return new Stream($body);
|
||||
if (class_exists(LaminasStream::class)) {
|
||||
return new LaminasStream($body);
|
||||
}
|
||||
|
||||
return new ZendStream($body);
|
||||
}
|
||||
|
||||
if (class_exists(LaminasStream::class)) {
|
||||
$stream = new LaminasStream('php://memory', 'rw');
|
||||
} else {
|
||||
$stream = new ZendStream('php://memory', 'rw');
|
||||
}
|
||||
|
||||
$stream = new Stream('php://memory', 'rw');
|
||||
if (null !== $body && '' !== $body) {
|
||||
$stream->write((string) $body);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace Http\Message\StreamFactory;
|
||||
|
||||
use GuzzleHttp\Psr7\Utils;
|
||||
use Http\Message\StreamFactory;
|
||||
|
||||
/**
|
||||
* Creates Guzzle streams.
|
||||
*
|
||||
* @author Михаил Красильников <m.krasilnikov@yandex.ru>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Guzzle PSR-17 factory
|
||||
*/
|
||||
final class GuzzleStreamFactory implements StreamFactory
|
||||
{
|
||||
@@ -16,6 +19,10 @@ final class GuzzleStreamFactory implements StreamFactory
|
||||
*/
|
||||
public function createStream($body = null)
|
||||
{
|
||||
if (class_exists(Utils::class)) {
|
||||
return Utils::streamFor($body);
|
||||
}
|
||||
|
||||
return \GuzzleHttp\Psr7\stream_for($body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ use Slim\Http\Stream;
|
||||
* Creates Slim 3 streams.
|
||||
*
|
||||
* @author Mika Tuupola <tuupola@appelsiini.net>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Slim PSR-17 factory
|
||||
*/
|
||||
final class SlimStreamFactory implements StreamFactory
|
||||
{
|
||||
|
||||
@@ -3,13 +3,16 @@
|
||||
namespace Http\Message\UriFactory;
|
||||
|
||||
use Http\Message\UriFactory;
|
||||
use Laminas\Diactoros\Uri as LaminasUri;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use Zend\Diactoros\Uri;
|
||||
use Zend\Diactoros\Uri as ZendUri;
|
||||
|
||||
/**
|
||||
* Creates Diactoros URI.
|
||||
*
|
||||
* @author David de Boer <david@ddeboer.nl>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Diactoros PSR-17 factory
|
||||
*/
|
||||
final class DiactorosUriFactory implements UriFactory
|
||||
{
|
||||
@@ -21,7 +24,11 @@ final class DiactorosUriFactory implements UriFactory
|
||||
if ($uri instanceof UriInterface) {
|
||||
return $uri;
|
||||
} elseif (is_string($uri)) {
|
||||
return new Uri($uri);
|
||||
if (class_exists(LaminasUri::class)) {
|
||||
return new LaminasUri($uri);
|
||||
}
|
||||
|
||||
return new ZendUri($uri);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('URI must be a string or UriInterface');
|
||||
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
namespace Http\Message\UriFactory;
|
||||
|
||||
use GuzzleHttp\Psr7;
|
||||
use function GuzzleHttp\Psr7\uri_for;
|
||||
use GuzzleHttp\Psr7\Utils;
|
||||
use Http\Message\UriFactory;
|
||||
|
||||
/**
|
||||
* Creates Guzzle URI.
|
||||
*
|
||||
* @author David de Boer <david@ddeboer.nl>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Guzzle PSR-17 factory
|
||||
*/
|
||||
final class GuzzleUriFactory implements UriFactory
|
||||
{
|
||||
@@ -17,6 +20,10 @@ final class GuzzleUriFactory implements UriFactory
|
||||
*/
|
||||
public function createUri($uri)
|
||||
{
|
||||
return Psr7\uri_for($uri);
|
||||
if (class_exists(Utils::class)) {
|
||||
return Utils::uriFor($uri);
|
||||
}
|
||||
|
||||
return uri_for($uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ use Slim\Http\Uri;
|
||||
* Creates Slim 3 URI.
|
||||
*
|
||||
* @author Mika Tuupola <tuupola@appelsiini.net>
|
||||
*
|
||||
* @deprecated This will be removed in php-http/message2.0. Consider using the official Slim PSR-17 factory
|
||||
*/
|
||||
final class SlimUriFactory implements UriFactory
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user