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: Client.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace YoastSEO_Vendor\GuzzleHttp;
[2] Fix | Delete
[3] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Cookie\CookieJar;
[4] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Exception\GuzzleException;
[5] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException;
[6] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Promise as P;
[7] Fix | Delete
use YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface;
[8] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\RequestInterface;
[9] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\ResponseInterface;
[10] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
[11] Fix | Delete
/**
[12] Fix | Delete
* @final
[13] Fix | Delete
*/
[14] Fix | Delete
class Client implements \YoastSEO_Vendor\GuzzleHttp\ClientInterface, \YoastSEO_Vendor\Psr\Http\Client\ClientInterface
[15] Fix | Delete
{
[16] Fix | Delete
use ClientTrait;
[17] Fix | Delete
/**
[18] Fix | Delete
* @var array Default request options
[19] Fix | Delete
*/
[20] Fix | Delete
private $config;
[21] Fix | Delete
/**
[22] Fix | Delete
* Clients accept an array of constructor parameters.
[23] Fix | Delete
*
[24] Fix | Delete
* Here's an example of creating a client using a base_uri and an array of
[25] Fix | Delete
* default request options to apply to each request:
[26] Fix | Delete
*
[27] Fix | Delete
* $client = new Client([
[28] Fix | Delete
* 'base_uri' => 'http://www.foo.com/1.0/',
[29] Fix | Delete
* 'timeout' => 0,
[30] Fix | Delete
* 'allow_redirects' => false,
[31] Fix | Delete
* 'proxy' => '192.168.16.1:10'
[32] Fix | Delete
* ]);
[33] Fix | Delete
*
[34] Fix | Delete
* Client configuration settings include the following options:
[35] Fix | Delete
*
[36] Fix | Delete
* - handler: (callable) Function that transfers HTTP requests over the
[37] Fix | Delete
* wire. The function is called with a Psr7\Http\Message\RequestInterface
[38] Fix | Delete
* and array of transfer options, and must return a
[39] Fix | Delete
* GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
[40] Fix | Delete
* Psr7\Http\Message\ResponseInterface on success.
[41] Fix | Delete
* If no handler is provided, a default handler will be created
[42] Fix | Delete
* that enables all of the request options below by attaching all of the
[43] Fix | Delete
* default middleware to the handler.
[44] Fix | Delete
* - base_uri: (string|UriInterface) Base URI of the client that is merged
[45] Fix | Delete
* into relative URIs. Can be a string or instance of UriInterface.
[46] Fix | Delete
* - **: any request option
[47] Fix | Delete
*
[48] Fix | Delete
* @param array $config Client configuration settings.
[49] Fix | Delete
*
[50] Fix | Delete
* @see \GuzzleHttp\RequestOptions for a list of available request options.
[51] Fix | Delete
*/
[52] Fix | Delete
public function __construct(array $config = [])
[53] Fix | Delete
{
[54] Fix | Delete
if (!isset($config['handler'])) {
[55] Fix | Delete
$config['handler'] = \YoastSEO_Vendor\GuzzleHttp\HandlerStack::create();
[56] Fix | Delete
} elseif (!\is_callable($config['handler'])) {
[57] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('handler must be a callable');
[58] Fix | Delete
}
[59] Fix | Delete
// Convert the base_uri to a UriInterface
[60] Fix | Delete
if (isset($config['base_uri'])) {
[61] Fix | Delete
$config['base_uri'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::uriFor($config['base_uri']);
[62] Fix | Delete
}
[63] Fix | Delete
$this->configureDefaults($config);
[64] Fix | Delete
}
[65] Fix | Delete
/**
[66] Fix | Delete
* @param string $method
[67] Fix | Delete
* @param array $args
[68] Fix | Delete
*
[69] Fix | Delete
* @return PromiseInterface|ResponseInterface
[70] Fix | Delete
*
[71] Fix | Delete
* @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0.
[72] Fix | Delete
*/
[73] Fix | Delete
public function __call($method, $args)
[74] Fix | Delete
{
[75] Fix | Delete
if (\count($args) < 1) {
[76] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('Magic request methods require a URI and optional options array');
[77] Fix | Delete
}
[78] Fix | Delete
$uri = $args[0];
[79] Fix | Delete
$opts = $args[1] ?? [];
[80] Fix | Delete
return \substr($method, -5) === 'Async' ? $this->requestAsync(\substr($method, 0, -5), $uri, $opts) : $this->request($method, $uri, $opts);
[81] Fix | Delete
}
[82] Fix | Delete
/**
[83] Fix | Delete
* Asynchronously send an HTTP request.
[84] Fix | Delete
*
[85] Fix | Delete
* @param array $options Request options to apply to the given
[86] Fix | Delete
* request and to the transfer. See \GuzzleHttp\RequestOptions.
[87] Fix | Delete
*/
[88] Fix | Delete
public function sendAsync(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options = []) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
[89] Fix | Delete
{
[90] Fix | Delete
// Merge the base URI into the request URI if needed.
[91] Fix | Delete
$options = $this->prepareDefaults($options);
[92] Fix | Delete
return $this->transfer($request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), $options);
[93] Fix | Delete
}
[94] Fix | Delete
/**
[95] Fix | Delete
* Send an HTTP request.
[96] Fix | Delete
*
[97] Fix | Delete
* @param array $options Request options to apply to the given
[98] Fix | Delete
* request and to the transfer. See \GuzzleHttp\RequestOptions.
[99] Fix | Delete
*
[100] Fix | Delete
* @throws GuzzleException
[101] Fix | Delete
*/
[102] Fix | Delete
public function send(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options = []) : \YoastSEO_Vendor\Psr\Http\Message\ResponseInterface
[103] Fix | Delete
{
[104] Fix | Delete
$options[\YoastSEO_Vendor\GuzzleHttp\RequestOptions::SYNCHRONOUS] = \true;
[105] Fix | Delete
return $this->sendAsync($request, $options)->wait();
[106] Fix | Delete
}
[107] Fix | Delete
/**
[108] Fix | Delete
* The HttpClient PSR (PSR-18) specify this method.
[109] Fix | Delete
*
[110] Fix | Delete
* {@inheritDoc}
[111] Fix | Delete
*/
[112] Fix | Delete
public function sendRequest(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request) : \YoastSEO_Vendor\Psr\Http\Message\ResponseInterface
[113] Fix | Delete
{
[114] Fix | Delete
$options[\YoastSEO_Vendor\GuzzleHttp\RequestOptions::SYNCHRONOUS] = \true;
[115] Fix | Delete
$options[\YoastSEO_Vendor\GuzzleHttp\RequestOptions::ALLOW_REDIRECTS] = \false;
[116] Fix | Delete
$options[\YoastSEO_Vendor\GuzzleHttp\RequestOptions::HTTP_ERRORS] = \false;
[117] Fix | Delete
return $this->sendAsync($request, $options)->wait();
[118] Fix | Delete
}
[119] Fix | Delete
/**
[120] Fix | Delete
* Create and send an asynchronous HTTP request.
[121] Fix | Delete
*
[122] Fix | Delete
* Use an absolute path to override the base path of the client, or a
[123] Fix | Delete
* relative path to append to the base path of the client. The URL can
[124] Fix | Delete
* contain the query string as well. Use an array to provide a URL
[125] Fix | Delete
* template and additional variables to use in the URL template expansion.
[126] Fix | Delete
*
[127] Fix | Delete
* @param string $method HTTP method
[128] Fix | Delete
* @param string|UriInterface $uri URI object or string.
[129] Fix | Delete
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
[130] Fix | Delete
*/
[131] Fix | Delete
public function requestAsync(string $method, $uri = '', array $options = []) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
[132] Fix | Delete
{
[133] Fix | Delete
$options = $this->prepareDefaults($options);
[134] Fix | Delete
// Remove request modifying parameter because it can be done up-front.
[135] Fix | Delete
$headers = $options['headers'] ?? [];
[136] Fix | Delete
$body = $options['body'] ?? null;
[137] Fix | Delete
$version = $options['version'] ?? '1.1';
[138] Fix | Delete
// Merge the URI into the base URI.
[139] Fix | Delete
$uri = $this->buildUri(\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::uriFor($uri), $options);
[140] Fix | Delete
if (\is_array($body)) {
[141] Fix | Delete
throw $this->invalidBody();
[142] Fix | Delete
}
[143] Fix | Delete
$request = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Request($method, $uri, $headers, $body, $version);
[144] Fix | Delete
// Remove the option so that they are not doubly-applied.
[145] Fix | Delete
unset($options['headers'], $options['body'], $options['version']);
[146] Fix | Delete
return $this->transfer($request, $options);
[147] Fix | Delete
}
[148] Fix | Delete
/**
[149] Fix | Delete
* Create and send an HTTP request.
[150] Fix | Delete
*
[151] Fix | Delete
* Use an absolute path to override the base path of the client, or a
[152] Fix | Delete
* relative path to append to the base path of the client. The URL can
[153] Fix | Delete
* contain the query string as well.
[154] Fix | Delete
*
[155] Fix | Delete
* @param string $method HTTP method.
[156] Fix | Delete
* @param string|UriInterface $uri URI object or string.
[157] Fix | Delete
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
[158] Fix | Delete
*
[159] Fix | Delete
* @throws GuzzleException
[160] Fix | Delete
*/
[161] Fix | Delete
public function request(string $method, $uri = '', array $options = []) : \YoastSEO_Vendor\Psr\Http\Message\ResponseInterface
[162] Fix | Delete
{
[163] Fix | Delete
$options[\YoastSEO_Vendor\GuzzleHttp\RequestOptions::SYNCHRONOUS] = \true;
[164] Fix | Delete
return $this->requestAsync($method, $uri, $options)->wait();
[165] Fix | Delete
}
[166] Fix | Delete
/**
[167] Fix | Delete
* Get a client configuration option.
[168] Fix | Delete
*
[169] Fix | Delete
* These options include default request options of the client, a "handler"
[170] Fix | Delete
* (if utilized by the concrete client), and a "base_uri" if utilized by
[171] Fix | Delete
* the concrete client.
[172] Fix | Delete
*
[173] Fix | Delete
* @param string|null $option The config option to retrieve.
[174] Fix | Delete
*
[175] Fix | Delete
* @return mixed
[176] Fix | Delete
*
[177] Fix | Delete
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
[178] Fix | Delete
*/
[179] Fix | Delete
public function getConfig(string $option = null)
[180] Fix | Delete
{
[181] Fix | Delete
return $option === null ? $this->config : $this->config[$option] ?? null;
[182] Fix | Delete
}
[183] Fix | Delete
private function buildUri(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, array $config) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[184] Fix | Delete
{
[185] Fix | Delete
if (isset($config['base_uri'])) {
[186] Fix | Delete
$uri = \YoastSEO_Vendor\GuzzleHttp\Psr7\UriResolver::resolve(\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::uriFor($config['base_uri']), $uri);
[187] Fix | Delete
}
[188] Fix | Delete
if (isset($config['idn_conversion']) && $config['idn_conversion'] !== \false) {
[189] Fix | Delete
$idnOptions = $config['idn_conversion'] === \true ? \IDNA_DEFAULT : $config['idn_conversion'];
[190] Fix | Delete
$uri = \YoastSEO_Vendor\GuzzleHttp\Utils::idnUriConvert($uri, $idnOptions);
[191] Fix | Delete
}
[192] Fix | Delete
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
[193] Fix | Delete
}
[194] Fix | Delete
/**
[195] Fix | Delete
* Configures the default options for a client.
[196] Fix | Delete
*/
[197] Fix | Delete
private function configureDefaults(array $config) : void
[198] Fix | Delete
{
[199] Fix | Delete
$defaults = ['allow_redirects' => \YoastSEO_Vendor\GuzzleHttp\RedirectMiddleware::$defaultSettings, 'http_errors' => \true, 'decode_content' => \true, 'verify' => \true, 'cookies' => \false, 'idn_conversion' => \false];
[200] Fix | Delete
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
[201] Fix | Delete
// We can only trust the HTTP_PROXY environment variable in a CLI
[202] Fix | Delete
// process due to the fact that PHP has no reliable mechanism to
[203] Fix | Delete
// get environment variables that start with "HTTP_".
[204] Fix | Delete
if (\PHP_SAPI === 'cli' && ($proxy = \YoastSEO_Vendor\GuzzleHttp\Utils::getenv('HTTP_PROXY'))) {
[205] Fix | Delete
$defaults['proxy']['http'] = $proxy;
[206] Fix | Delete
}
[207] Fix | Delete
if ($proxy = \YoastSEO_Vendor\GuzzleHttp\Utils::getenv('HTTPS_PROXY')) {
[208] Fix | Delete
$defaults['proxy']['https'] = $proxy;
[209] Fix | Delete
}
[210] Fix | Delete
if ($noProxy = \YoastSEO_Vendor\GuzzleHttp\Utils::getenv('NO_PROXY')) {
[211] Fix | Delete
$cleanedNoProxy = \str_replace(' ', '', $noProxy);
[212] Fix | Delete
$defaults['proxy']['no'] = \explode(',', $cleanedNoProxy);
[213] Fix | Delete
}
[214] Fix | Delete
$this->config = $config + $defaults;
[215] Fix | Delete
if (!empty($config['cookies']) && $config['cookies'] === \true) {
[216] Fix | Delete
$this->config['cookies'] = new \YoastSEO_Vendor\GuzzleHttp\Cookie\CookieJar();
[217] Fix | Delete
}
[218] Fix | Delete
// Add the default user-agent header.
[219] Fix | Delete
if (!isset($this->config['headers'])) {
[220] Fix | Delete
$this->config['headers'] = ['User-Agent' => \YoastSEO_Vendor\GuzzleHttp\Utils::defaultUserAgent()];
[221] Fix | Delete
} else {
[222] Fix | Delete
// Add the User-Agent header if one was not already set.
[223] Fix | Delete
foreach (\array_keys($this->config['headers']) as $name) {
[224] Fix | Delete
if (\strtolower($name) === 'user-agent') {
[225] Fix | Delete
return;
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
$this->config['headers']['User-Agent'] = \YoastSEO_Vendor\GuzzleHttp\Utils::defaultUserAgent();
[229] Fix | Delete
}
[230] Fix | Delete
}
[231] Fix | Delete
/**
[232] Fix | Delete
* Merges default options into the array.
[233] Fix | Delete
*
[234] Fix | Delete
* @param array $options Options to modify by reference
[235] Fix | Delete
*/
[236] Fix | Delete
private function prepareDefaults(array $options) : array
[237] Fix | Delete
{
[238] Fix | Delete
$defaults = $this->config;
[239] Fix | Delete
if (!empty($defaults['headers'])) {
[240] Fix | Delete
// Default headers are only added if they are not present.
[241] Fix | Delete
$defaults['_conditional'] = $defaults['headers'];
[242] Fix | Delete
unset($defaults['headers']);
[243] Fix | Delete
}
[244] Fix | Delete
// Special handling for headers is required as they are added as
[245] Fix | Delete
// conditional headers and as headers passed to a request ctor.
[246] Fix | Delete
if (\array_key_exists('headers', $options)) {
[247] Fix | Delete
// Allows default headers to be unset.
[248] Fix | Delete
if ($options['headers'] === null) {
[249] Fix | Delete
$defaults['_conditional'] = [];
[250] Fix | Delete
unset($options['headers']);
[251] Fix | Delete
} elseif (!\is_array($options['headers'])) {
[252] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('headers must be an array');
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
// Shallow merge defaults underneath options.
[256] Fix | Delete
$result = $options + $defaults;
[257] Fix | Delete
// Remove null values.
[258] Fix | Delete
foreach ($result as $k => $v) {
[259] Fix | Delete
if ($v === null) {
[260] Fix | Delete
unset($result[$k]);
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
return $result;
[264] Fix | Delete
}
[265] Fix | Delete
/**
[266] Fix | Delete
* Transfers the given request and applies request options.
[267] Fix | Delete
*
[268] Fix | Delete
* The URI of the request is not modified and the request options are used
[269] Fix | Delete
* as-is without merging in default options.
[270] Fix | Delete
*
[271] Fix | Delete
* @param array $options See \GuzzleHttp\RequestOptions.
[272] Fix | Delete
*/
[273] Fix | Delete
private function transfer(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
[274] Fix | Delete
{
[275] Fix | Delete
$request = $this->applyOptions($request, $options);
[276] Fix | Delete
/** @var HandlerStack $handler */
[277] Fix | Delete
$handler = $options['handler'];
[278] Fix | Delete
try {
[279] Fix | Delete
return \YoastSEO_Vendor\GuzzleHttp\Promise\Create::promiseFor($handler($request, $options));
[280] Fix | Delete
} catch (\Exception $e) {
[281] Fix | Delete
return \YoastSEO_Vendor\GuzzleHttp\Promise\Create::rejectionFor($e);
[282] Fix | Delete
}
[283] Fix | Delete
}
[284] Fix | Delete
/**
[285] Fix | Delete
* Applies the array of request options to a request.
[286] Fix | Delete
*/
[287] Fix | Delete
private function applyOptions(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array &$options) : \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
[288] Fix | Delete
{
[289] Fix | Delete
$modify = ['set_headers' => []];
[290] Fix | Delete
if (isset($options['headers'])) {
[291] Fix | Delete
if (\array_keys($options['headers']) === \range(0, \count($options['headers']) - 1)) {
[292] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('The headers array must have header name as keys.');
[293] Fix | Delete
}
[294] Fix | Delete
$modify['set_headers'] = $options['headers'];
[295] Fix | Delete
unset($options['headers']);
[296] Fix | Delete
}
[297] Fix | Delete
if (isset($options['form_params'])) {
[298] Fix | Delete
if (isset($options['multipart'])) {
[299] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('You cannot use ' . 'form_params and multipart at the same time. Use the ' . 'form_params option if you want to send application/' . 'x-www-form-urlencoded requests, and the multipart ' . 'option to send multipart/form-data requests.');
[300] Fix | Delete
}
[301] Fix | Delete
$options['body'] = \http_build_query($options['form_params'], '', '&');
[302] Fix | Delete
unset($options['form_params']);
[303] Fix | Delete
// Ensure that we don't have the header in different case and set the new value.
[304] Fix | Delete
$options['_conditional'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
[305] Fix | Delete
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
[306] Fix | Delete
}
[307] Fix | Delete
if (isset($options['multipart'])) {
[308] Fix | Delete
$options['body'] = new \YoastSEO_Vendor\GuzzleHttp\Psr7\MultipartStream($options['multipart']);
[309] Fix | Delete
unset($options['multipart']);
[310] Fix | Delete
}
[311] Fix | Delete
if (isset($options['json'])) {
[312] Fix | Delete
$options['body'] = \YoastSEO_Vendor\GuzzleHttp\Utils::jsonEncode($options['json']);
[313] Fix | Delete
unset($options['json']);
[314] Fix | Delete
// Ensure that we don't have the header in different case and set the new value.
[315] Fix | Delete
$options['_conditional'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
[316] Fix | Delete
$options['_conditional']['Content-Type'] = 'application/json';
[317] Fix | Delete
}
[318] Fix | Delete
if (!empty($options['decode_content']) && $options['decode_content'] !== \true) {
[319] Fix | Delete
// Ensure that we don't have the header in different case and set the new value.
[320] Fix | Delete
$options['_conditional'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']);
[321] Fix | Delete
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
[322] Fix | Delete
}
[323] Fix | Delete
if (isset($options['body'])) {
[324] Fix | Delete
if (\is_array($options['body'])) {
[325] Fix | Delete
throw $this->invalidBody();
[326] Fix | Delete
}
[327] Fix | Delete
$modify['body'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::streamFor($options['body']);
[328] Fix | Delete
unset($options['body']);
[329] Fix | Delete
}
[330] Fix | Delete
if (!empty($options['auth']) && \is_array($options['auth'])) {
[331] Fix | Delete
$value = $options['auth'];
[332] Fix | Delete
$type = isset($value[2]) ? \strtolower($value[2]) : 'basic';
[333] Fix | Delete
switch ($type) {
[334] Fix | Delete
case 'basic':
[335] Fix | Delete
// Ensure that we don't have the header in different case and set the new value.
[336] Fix | Delete
$modify['set_headers'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']);
[337] Fix | Delete
$modify['set_headers']['Authorization'] = 'Basic ' . \base64_encode("{$value[0]}:{$value[1]}");
[338] Fix | Delete
break;
[339] Fix | Delete
case 'digest':
[340] Fix | Delete
// @todo: Do not rely on curl
[341] Fix | Delete
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST;
[342] Fix | Delete
$options['curl'][\CURLOPT_USERPWD] = "{$value[0]}:{$value[1]}";
[343] Fix | Delete
break;
[344] Fix | Delete
case 'ntlm':
[345] Fix | Delete
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM;
[346] Fix | Delete
$options['curl'][\CURLOPT_USERPWD] = "{$value[0]}:{$value[1]}";
[347] Fix | Delete
break;
[348] Fix | Delete
}
[349] Fix | Delete
}
[350] Fix | Delete
if (isset($options['query'])) {
[351] Fix | Delete
$value = $options['query'];
[352] Fix | Delete
if (\is_array($value)) {
[353] Fix | Delete
$value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986);
[354] Fix | Delete
}
[355] Fix | Delete
if (!\is_string($value)) {
[356] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('query must be a string or array');
[357] Fix | Delete
}
[358] Fix | Delete
$modify['query'] = $value;
[359] Fix | Delete
unset($options['query']);
[360] Fix | Delete
}
[361] Fix | Delete
// Ensure that sink is not an invalid value.
[362] Fix | Delete
if (isset($options['sink'])) {
[363] Fix | Delete
// TODO: Add more sink validation?
[364] Fix | Delete
if (\is_bool($options['sink'])) {
[365] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('sink must not be a boolean');
[366] Fix | Delete
}
[367] Fix | Delete
}
[368] Fix | Delete
if (isset($options['version'])) {
[369] Fix | Delete
$modify['version'] = $options['version'];
[370] Fix | Delete
}
[371] Fix | Delete
$request = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::modifyRequest($request, $modify);
[372] Fix | Delete
if ($request->getBody() instanceof \YoastSEO_Vendor\GuzzleHttp\Psr7\MultipartStream) {
[373] Fix | Delete
// Use a multipart/form-data POST if a Content-Type is not set.
[374] Fix | Delete
// Ensure that we don't have the header in different case and set the new value.
[375] Fix | Delete
$options['_conditional'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
[376] Fix | Delete
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' . $request->getBody()->getBoundary();
[377] Fix | Delete
}
[378] Fix | Delete
// Merge in conditional headers if they are not present.
[379] Fix | Delete
if (isset($options['_conditional'])) {
[380] Fix | Delete
// Build up the changes so it's in a single clone of the message.
[381] Fix | Delete
$modify = [];
[382] Fix | Delete
foreach ($options['_conditional'] as $k => $v) {
[383] Fix | Delete
if (!$request->hasHeader($k)) {
[384] Fix | Delete
$modify['set_headers'][$k] = $v;
[385] Fix | Delete
}
[386] Fix | Delete
}
[387] Fix | Delete
$request = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::modifyRequest($request, $modify);
[388] Fix | Delete
// Don't pass this internal value along to middleware/handlers.
[389] Fix | Delete
unset($options['_conditional']);
[390] Fix | Delete
}
[391] Fix | Delete
return $request;
[392] Fix | Delete
}
[393] Fix | Delete
/**
[394] Fix | Delete
* Return an InvalidArgumentException with pre-set message.
[395] Fix | Delete
*/
[396] Fix | Delete
private function invalidBody() : \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException
[397] Fix | Delete
{
[398] Fix | Delete
return new \YoastSEO_Vendor\GuzzleHttp\Exception\InvalidArgumentException('Passing in the "body" request ' . 'option as an array to send a request is not supported. ' . 'Please use the "form_params" request option to send a ' . 'application/x-www-form-urlencoded request, or the "multipart" ' . 'request option to send a multipart/form-data request.');
[399] Fix | Delete
}
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function