1KA_F2F/vendor/guzzlehttp/psr7/src/InflateStream.php
pero1203 4cec48f127 Merge branch 'master' into release/produkcija
# Conflicts:
#	.gitignore
#	vendor/autoload.php
#	vendor/composer/ClassLoader.php
#	vendor/composer/LICENSE
#	vendor/composer/autoload_classmap.php
#	vendor/composer/autoload_files.php
#	vendor/composer/autoload_psr4.php
#	vendor/composer/autoload_real.php
#	vendor/composer/autoload_static.php
#	vendor/composer/installed.json
#	vendor/fgrosse/phpasn1/CHANGELOG.md
#	vendor/fgrosse/phpasn1/composer.json
#	vendor/fgrosse/phpasn1/lib/Utility/BigInteger.php
#	vendor/geoip2/geoip2/CHANGELOG.md
#	vendor/geoip2/geoip2/composer.json
#	vendor/geoip2/geoip2/src/Database/Reader.php
#	vendor/geoip2/geoip2/src/Exception/AddressNotFoundException.php
#	vendor/geoip2/geoip2/src/Exception/AuthenticationException.php
#	vendor/geoip2/geoip2/src/Exception/GeoIp2Exception.php
#	vendor/geoip2/geoip2/src/Exception/HttpException.php
#	vendor/geoip2/geoip2/src/Exception/InvalidRequestException.php
#	vendor/geoip2/geoip2/src/Exception/OutOfQueriesException.php
#	vendor/geoip2/geoip2/src/Model/AbstractModel.php
#	vendor/geoip2/geoip2/src/Model/AnonymousIp.php
#	vendor/geoip2/geoip2/src/Model/Asn.php
#	vendor/geoip2/geoip2/src/Model/City.php
#	vendor/geoip2/geoip2/src/Model/ConnectionType.php
#	vendor/geoip2/geoip2/src/Model/Country.php
#	vendor/geoip2/geoip2/src/Model/Domain.php
#	vendor/geoip2/geoip2/src/Model/Enterprise.php
#	vendor/geoip2/geoip2/src/Model/Insights.php
#	vendor/geoip2/geoip2/src/Model/Isp.php
#	vendor/geoip2/geoip2/src/ProviderInterface.php
#	vendor/geoip2/geoip2/src/Record/AbstractPlaceRecord.php
#	vendor/geoip2/geoip2/src/Record/AbstractRecord.php
#	vendor/geoip2/geoip2/src/Record/City.php
#	vendor/geoip2/geoip2/src/Record/Continent.php
#	vendor/geoip2/geoip2/src/Record/Country.php
#	vendor/geoip2/geoip2/src/Record/Location.php
#	vendor/geoip2/geoip2/src/Record/MaxMind.php
#	vendor/geoip2/geoip2/src/Record/Postal.php
#	vendor/geoip2/geoip2/src/Record/RepresentedCountry.php
#	vendor/geoip2/geoip2/src/Record/Subdivision.php
#	vendor/geoip2/geoip2/src/Record/Traits.php
#	vendor/geoip2/geoip2/src/Util.php
#	vendor/geoip2/geoip2/src/WebService/Client.php
#	vendor/guzzlehttp/promises/CHANGELOG.md
#	vendor/guzzlehttp/promises/README.md
#	vendor/guzzlehttp/promises/composer.json
#	vendor/guzzlehttp/promises/src/AggregateException.php
#	vendor/guzzlehttp/promises/src/CancellationException.php
#	vendor/guzzlehttp/promises/src/Coroutine.php
#	vendor/guzzlehttp/promises/src/EachPromise.php
#	vendor/guzzlehttp/promises/src/FulfilledPromise.php
#	vendor/guzzlehttp/promises/src/Promise.php
#	vendor/guzzlehttp/promises/src/PromiseInterface.php
#	vendor/guzzlehttp/promises/src/PromisorInterface.php
#	vendor/guzzlehttp/promises/src/RejectedPromise.php
#	vendor/guzzlehttp/promises/src/RejectionException.php
#	vendor/guzzlehttp/promises/src/TaskQueue.php
#	vendor/guzzlehttp/promises/src/TaskQueueInterface.php
#	vendor/guzzlehttp/promises/src/functions.php
#	vendor/guzzlehttp/psr7/CHANGELOG.md
#	vendor/guzzlehttp/psr7/README.md
#	vendor/guzzlehttp/psr7/composer.json
#	vendor/guzzlehttp/psr7/src/AppendStream.php
#	vendor/guzzlehttp/psr7/src/BufferStream.php
#	vendor/guzzlehttp/psr7/src/CachingStream.php
#	vendor/guzzlehttp/psr7/src/DroppingStream.php
#	vendor/guzzlehttp/psr7/src/FnStream.php
#	vendor/guzzlehttp/psr7/src/InflateStream.php
#	vendor/guzzlehttp/psr7/src/LazyOpenStream.php
#	vendor/guzzlehttp/psr7/src/LimitStream.php
#	vendor/guzzlehttp/psr7/src/MessageTrait.php
#	vendor/guzzlehttp/psr7/src/MultipartStream.php
#	vendor/guzzlehttp/psr7/src/NoSeekStream.php
#	vendor/guzzlehttp/psr7/src/PumpStream.php
#	vendor/guzzlehttp/psr7/src/Request.php
#	vendor/guzzlehttp/psr7/src/Response.php
#	vendor/guzzlehttp/psr7/src/ServerRequest.php
#	vendor/guzzlehttp/psr7/src/Stream.php
#	vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php
#	vendor/guzzlehttp/psr7/src/StreamWrapper.php
#	vendor/guzzlehttp/psr7/src/UploadedFile.php
#	vendor/guzzlehttp/psr7/src/Uri.php
#	vendor/guzzlehttp/psr7/src/UriNormalizer.php
#	vendor/guzzlehttp/psr7/src/UriResolver.php
#	vendor/guzzlehttp/psr7/src/functions.php
#	vendor/maxmind-db/reader/CHANGELOG.md
#	vendor/maxmind-db/reader/composer.json
#	vendor/maxmind-db/reader/ext/maxminddb.c
#	vendor/maxmind-db/reader/ext/php_maxminddb.h
#	vendor/maxmind-db/reader/package.xml
#	vendor/maxmind/web-service-common/CHANGELOG.md
#	vendor/maxmind/web-service-common/README.md
#	vendor/maxmind/web-service-common/composer.json
#	vendor/maxmind/web-service-common/src/Exception/AuthenticationException.php
#	vendor/maxmind/web-service-common/src/Exception/HttpException.php
#	vendor/maxmind/web-service-common/src/Exception/InsufficientFundsException.php
#	vendor/maxmind/web-service-common/src/Exception/InvalidInputException.php
#	vendor/maxmind/web-service-common/src/Exception/InvalidRequestException.php
#	vendor/maxmind/web-service-common/src/Exception/IpAddressNotFoundException.php
#	vendor/maxmind/web-service-common/src/Exception/PermissionRequiredException.php
#	vendor/maxmind/web-service-common/src/Exception/WebServiceException.php
#	vendor/maxmind/web-service-common/src/WebService/Client.php
#	vendor/maxmind/web-service-common/src/WebService/Http/CurlRequest.php
#	vendor/maxmind/web-service-common/src/WebService/Http/Request.php
#	vendor/maxmind/web-service-common/src/WebService/Http/RequestFactory.php
#	vendor/paragonie/random_compat/composer.json
#	vendor/paragonie/sodium_compat/.gitignore
#	vendor/paragonie/sodium_compat/composer.json
#	vendor/paragonie/sodium_compat/psalm-above-3.xml
#	vendor/paragonie/sodium_compat/src/Core/Ed25519.php
#	vendor/paragonie/sodium_compat/src/Core/SipHash.php
#	vendor/paragonie/sodium_compat/src/Core/Util.php
#	vendor/paragonie/sodium_compat/src/Core32/Ed25519.php
#	vendor/paragonie/sodium_compat/src/File.php
#	vendor/paragonie/sodium_compat/src/PHP52/SplFixedArray.php
#	vendor/phpmailer/phpmailer/README.md
#	vendor/phpmailer/phpmailer/VERSION
#	vendor/phpmailer/phpmailer/composer.json
#	vendor/phpmailer/phpmailer/get_oauth_token.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-af.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ar.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-az.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ba.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-be.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-bg.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ca.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-cs.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-da.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-de.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-el.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-eo.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-es.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-et.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-fa.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-fi.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-fo.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-fr.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-gl.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-he.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-hi.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-hr.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-hu.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-hy.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-id.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-it.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ja.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ka.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ko.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-lt.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-lv.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-mg.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ms.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-nb.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-nl.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-pl.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-pt.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-pt_br.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ro.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-ru.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-sk.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-sl.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-sr.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-sv.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-tl.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-tr.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-uk.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-vi.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-zh.php
#	vendor/phpmailer/phpmailer/language/phpmailer.lang-zh_cn.php
#	vendor/phpmailer/phpmailer/src/Exception.php
#	vendor/phpmailer/phpmailer/src/OAuth.php
#	vendor/phpmailer/phpmailer/src/PHPMailer.php
#	vendor/phpmailer/phpmailer/src/POP3.php
#	vendor/phpmailer/phpmailer/src/SMTP.php
#	vendor/spomky-labs/base64url/composer.json
#	vendor/stripe/stripe-php/CHANGELOG.md
#	vendor/stripe/stripe-php/VERSION
#	vendor/stripe/stripe-php/composer.json
#	vendor/stripe/stripe-php/init.php
#	vendor/stripe/stripe-php/lib/Account.php
#	vendor/stripe/stripe-php/lib/ApiRequestor.php
#	vendor/stripe/stripe-php/lib/ApplicationFeeRefund.php
#	vendor/stripe/stripe-php/lib/Balance.php
#	vendor/stripe/stripe-php/lib/BalanceTransaction.php
#	vendor/stripe/stripe-php/lib/BaseStripeClient.php
#	vendor/stripe/stripe-php/lib/BitcoinReceiver.php
#	vendor/stripe/stripe-php/lib/Card.php
#	vendor/stripe/stripe-php/lib/Charge.php
#	vendor/stripe/stripe-php/lib/Checkout/Session.php
#	vendor/stripe/stripe-php/lib/Coupon.php
#	vendor/stripe/stripe-php/lib/CreditNote.php
#	vendor/stripe/stripe-php/lib/CreditNoteLineItem.php
#	vendor/stripe/stripe-php/lib/Customer.php
#	vendor/stripe/stripe-php/lib/ErrorObject.php
#	vendor/stripe/stripe-php/lib/Event.php
#	vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php
#	vendor/stripe/stripe-php/lib/Invoice.php
#	vendor/stripe/stripe-php/lib/InvoiceItem.php
#	vendor/stripe/stripe-php/lib/InvoiceLineItem.php
#	vendor/stripe/stripe-php/lib/Order.php
#	vendor/stripe/stripe-php/lib/PaymentIntent.php
#	vendor/stripe/stripe-php/lib/PaymentMethod.php
#	vendor/stripe/stripe-php/lib/Payout.php
#	vendor/stripe/stripe-php/lib/Plan.php
#	vendor/stripe/stripe-php/lib/PromotionCode.php
#	vendor/stripe/stripe-php/lib/Refund.php
#	vendor/stripe/stripe-php/lib/Service/CoreServiceFactory.php
#	vendor/stripe/stripe-php/lib/Service/CustomerService.php
#	vendor/stripe/stripe-php/lib/Service/InvoiceService.php
#	vendor/stripe/stripe-php/lib/Service/PayoutService.php
#	vendor/stripe/stripe-php/lib/Service/SubscriptionScheduleService.php
#	vendor/stripe/stripe-php/lib/Service/SubscriptionService.php
#	vendor/stripe/stripe-php/lib/SetupIntent.php
#	vendor/stripe/stripe-php/lib/Source.php
#	vendor/stripe/stripe-php/lib/Stripe.php
#	vendor/stripe/stripe-php/lib/StripeClient.php
#	vendor/stripe/stripe-php/lib/StripeObject.php
#	vendor/stripe/stripe-php/lib/Subscription.php
#	vendor/stripe/stripe-php/lib/TaxId.php
#	vendor/stripe/stripe-php/lib/TaxRate.php
#	vendor/stripe/stripe-php/lib/TransferReversal.php
#	vendor/stripe/stripe-php/lib/Util/ObjectTypes.php
#	vendor/stripe/stripe-php/lib/Util/Util.php
#	vendor/symfony/polyfill-intl-idn/Idn.php
#	vendor/symfony/polyfill-intl-idn/composer.json
#	vendor/symfony/polyfill-intl-normalizer/bootstrap.php
#	vendor/symfony/polyfill-intl-normalizer/composer.json
#	vendor/symfony/polyfill-php72/Php72.php
#	vendor/symfony/polyfill-php72/bootstrap.php
#	vendor/symfony/polyfill-php72/composer.json
2020-12-05 13:00:23 +01:00

57 lines
1.8 KiB
PHP

<?php
<<<<<<< HEAD
=======
>>>>>>> master
namespace GuzzleHttp\Psr7;
use Psr\Http\Message\StreamInterface;
/**
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
*
* This stream decorator skips the first 10 bytes of the given stream to remove
* the gzip header, converts the provided stream to a PHP stream resource,
* then appends the zlib.inflate filter. The stream is then converted back
* to a Guzzle stream resource to be used as a Guzzle stream.
*
* @link http://tools.ietf.org/html/rfc1952
* @link http://php.net/manual/en/filters.compression.php
*/
class InflateStream implements StreamInterface
{
use StreamDecoratorTrait;
public function __construct(StreamInterface $stream)
{
// read the first 10 bytes, ie. gzip header
$header = $stream->read(10);
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
$resource = StreamWrapper::getResource($stream);
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
}
/**
* @param StreamInterface $stream
* @param $header
* @return int
*/
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
{
$filename_header_length = 0;
if (substr(bin2hex($header), 6, 2) === '08') {
// we have a filename, read until nil
$filename_header_length = 1;
while ($stream->read(1) !== chr(0)) {
$filename_header_length++;
}
}
return $filename_header_length;
}
}