Server IP : 104.21.14.103 / Your IP : 52.15.130.113 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/home/giankuin/sieuthiweb.com.vn/wp-content/plugins/duplicator-pro/aws/Guzzle/Service/Command/LocationVisitor/Request/ |
Upload File : |
<?php namespace DuplicatorPro\Guzzle\Service\Command\LocationVisitor\Request; use DuplicatorPro\Guzzle\Http\EntityBody; use DuplicatorPro\Guzzle\Http\Message\EntityEnclosingRequestInterface; use DuplicatorPro\Guzzle\Http\Message\RequestInterface; use DuplicatorPro\Guzzle\Http\EntityBodyInterface; use DuplicatorPro\Guzzle\Service\Command\CommandInterface; use DuplicatorPro\Guzzle\Service\Description\Parameter; /** * Visitor used to apply a body to a request * * This visitor can use a data parameter of 'expect' to control the Expect header. Set the expect data parameter to * false to disable the expect header, or set the value to an integer so that the expect 100-continue header is only * added if the Content-Length of the entity body is greater than the value. */ class BodyVisitor extends AbstractRequestVisitor { public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value) { $value = $param->filter($value); $entityBody = EntityBody::factory($value); $request->setBody($entityBody); $this->addExpectHeader($request, $entityBody, $param->getData('expect_header')); // Add the Content-Encoding header if one is set on the EntityBody if ($encoding = $entityBody->getContentEncoding()) { $request->setHeader('Content-Encoding', $encoding); } } /** * Add the appropriate expect header to a request * * @param EntityEnclosingRequestInterface $request Request to update * @param EntityBodyInterface $body Entity body of the request * @param string|int $expect Expect header setting */ protected function addExpectHeader(EntityEnclosingRequestInterface $request, EntityBodyInterface $body, $expect) { // Allow the `expect` data parameter to be set to remove the Expect header from the request if ($expect === false) { $request->removeHeader('Expect'); } elseif ($expect !== true) { // Default to using a MB as the point in which to start using the expect header $expect = $expect ?: 1048576; // If the expect_header value is numeric then only add if the size is greater than the cutoff if (is_numeric($expect) && $body->getSize()) { if ($body->getSize() < $expect) { $request->removeHeader('Expect'); } else { $request->setHeader('Expect', '100-Continue'); } } } } }