Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../vendor_p.../guzzleht.../guzzle/src
File: PrepareBodyMiddleware.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace YoastSEO_Vendor\GuzzleHttp;
[2] Fix | Delete
[3] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface;
[4] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\RequestInterface;
[5] Fix | Delete
/**
[6] Fix | Delete
* Prepares requests that contain a body, adding the Content-Length,
[7] Fix | Delete
* Content-Type, and Expect headers.
[8] Fix | Delete
*
[9] Fix | Delete
* @final
[10] Fix | Delete
*/
[11] Fix | Delete
class PrepareBodyMiddleware
[12] Fix | Delete
{
[13] Fix | Delete
/**
[14] Fix | Delete
* @var callable(RequestInterface, array): PromiseInterface
[15] Fix | Delete
*/
[16] Fix | Delete
private $nextHandler;
[17] Fix | Delete
/**
[18] Fix | Delete
* @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
[19] Fix | Delete
*/
[20] Fix | Delete
public function __construct(callable $nextHandler)
[21] Fix | Delete
{
[22] Fix | Delete
$this->nextHandler = $nextHandler;
[23] Fix | Delete
}
[24] Fix | Delete
public function __invoke(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
[25] Fix | Delete
{
[26] Fix | Delete
$fn = $this->nextHandler;
[27] Fix | Delete
// Don't do anything if the request has no body.
[28] Fix | Delete
if ($request->getBody()->getSize() === 0) {
[29] Fix | Delete
return $fn($request, $options);
[30] Fix | Delete
}
[31] Fix | Delete
$modify = [];
[32] Fix | Delete
// Add a default content-type if possible.
[33] Fix | Delete
if (!$request->hasHeader('Content-Type')) {
[34] Fix | Delete
if ($uri = $request->getBody()->getMetadata('uri')) {
[35] Fix | Delete
if (\is_string($uri) && ($type = \YoastSEO_Vendor\GuzzleHttp\Psr7\MimeType::fromFilename($uri))) {
[36] Fix | Delete
$modify['set_headers']['Content-Type'] = $type;
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
// Add a default content-length or transfer-encoding header.
[41] Fix | Delete
if (!$request->hasHeader('Content-Length') && !$request->hasHeader('Transfer-Encoding')) {
[42] Fix | Delete
$size = $request->getBody()->getSize();
[43] Fix | Delete
if ($size !== null) {
[44] Fix | Delete
$modify['set_headers']['Content-Length'] = $size;
[45] Fix | Delete
} else {
[46] Fix | Delete
$modify['set_headers']['Transfer-Encoding'] = 'chunked';
[47] Fix | Delete
}
[48] Fix | Delete
}
[49] Fix | Delete
// Add the expect header if needed.
[50] Fix | Delete
$this->addExpectHeader($request, $options, $modify);
[51] Fix | Delete
return $fn(\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::modifyRequest($request, $modify), $options);
[52] Fix | Delete
}
[53] Fix | Delete
/**
[54] Fix | Delete
* Add expect header
[55] Fix | Delete
*/
[56] Fix | Delete
private function addExpectHeader(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options, array &$modify) : void
[57] Fix | Delete
{
[58] Fix | Delete
// Determine if the Expect header should be used
[59] Fix | Delete
if ($request->hasHeader('Expect')) {
[60] Fix | Delete
return;
[61] Fix | Delete
}
[62] Fix | Delete
$expect = $options['expect'] ?? null;
[63] Fix | Delete
// Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0
[64] Fix | Delete
if ($expect === \false || $request->getProtocolVersion() < 1.1) {
[65] Fix | Delete
return;
[66] Fix | Delete
}
[67] Fix | Delete
// The expect header is unconditionally enabled
[68] Fix | Delete
if ($expect === \true) {
[69] Fix | Delete
$modify['set_headers']['Expect'] = '100-Continue';
[70] Fix | Delete
return;
[71] Fix | Delete
}
[72] Fix | Delete
// By default, send the expect header when the payload is > 1mb
[73] Fix | Delete
if ($expect === null) {
[74] Fix | Delete
$expect = 1048576;
[75] Fix | Delete
}
[76] Fix | Delete
// Always add if the body cannot be rewound, the size cannot be
[77] Fix | Delete
// determined, or the size is greater than the cutoff threshold
[78] Fix | Delete
$body = $request->getBody();
[79] Fix | Delete
$size = $body->getSize();
[80] Fix | Delete
if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
[81] Fix | Delete
$modify['set_headers']['Expect'] = '100-Continue';
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function