WpOrg\Requests\Transport
Fsockopen::request_multiple()
Send multiple requests simultaneously
Метод класса: Fsockopen{}
Хуков нет.
Возвращает
Массив
. Array of \WpOrg\Requests\Response objects (may contain \WpOrg\Requests\Exception or string responses as well)
Использование
$Fsockopen = new Fsockopen(); $Fsockopen->request_multiple( $requests, $options );
- $requests(массив) (обязательный)
- Request data (array of 'url', 'headers', 'data', 'options') as per \WpOrg\Requests\Transport::request()
- $options(массив) (обязательный)
- Global options, see {@see \WpOrg\Requests\Requests::response()} for documentation
Код Fsockopen::request_multiple() Fsockopen::request multiple WP 6.6.2
public function request_multiple($requests, $options) { // If you're not requesting, we can't get any responses ¯\_(ツ)_/¯ if (empty($requests)) { return []; } if (InputValidator::has_array_access($requests) === false || InputValidator::is_iterable($requests) === false) { throw InvalidArgument::create(1, '$requests', 'array|ArrayAccess&Traversable', gettype($requests)); } if (is_array($options) === false) { throw InvalidArgument::create(2, '$options', 'array', gettype($options)); } $responses = []; $class = get_class($this); foreach ($requests as $id => $request) { try { $handler = new $class(); $responses[$id] = $handler->request($request['url'], $request['headers'], $request['data'], $request['options']); $request['options']['hooks']->dispatch('transport.internal.parse_response', [&$responses[$id], $request]); } catch (Exception $e) { $responses[$id] = $e; } if (!is_string($responses[$id])) { $request['options']['hooks']->dispatch('multiple.request.complete', [&$responses[$id], $id]); } } return $responses; }