YoastSEO_Vendor\GuzzleHttp\Handler
CurlFactory::applyBody() private Yoast 1.0
{} Это метод класса: CurlFactory{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
// private - только в коде основоного (родительского) класса $result = $this->applyBody( \YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, $options, $conf );
Код CurlFactory::applyBody() CurlFactory::applyBody Yoast 15.6.2
private function applyBody(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request, array $options, array &$conf)
{
$size = $request->hasHeader('Content-Length') ? (int) $request->getHeaderLine('Content-Length') : null;
// Send the body as a string if the size is less than 1MB OR if the
// [curl][body_as_string] request value is set.
if ($size !== null && $size < 1000000 || !empty($options['_body_as_string'])) {
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
// Don't duplicate the Content-Length header
$this->removeHeader('Content-Length', $conf);
$this->removeHeader('Transfer-Encoding', $conf);
} else {
$conf[\CURLOPT_UPLOAD] = \true;
if ($size !== null) {
$conf[\CURLOPT_INFILESIZE] = $size;
$this->removeHeader('Content-Length', $conf);
}
$body = $request->getBody();
if ($body->isSeekable()) {
$body->rewind();
}
$conf[\CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use($body) {
return $body->read($length);
};
}
// If the Expect header is not present, prevent curl from adding it
if (!$request->hasHeader('Expect')) {
$conf[\CURLOPT_HTTPHEADER][] = 'Expect:';
}
// cURL sometimes adds a content-type by default. Prevent this.
if (!$request->hasHeader('Content-Type')) {
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Type:';
}
}