WP_Http::_dispatch_request
Устарела с версии 5.1.0. Больше не поддерживается и может быть удалена. Используйте WP_Http::request().
Dispatches a HTTP request to a supporting transport.
Tests each transport in order to find a transport which matches the request arguments. Also caches the transport instance to be used later.
The order for requests is cURL, and then PHP Streams.
Метод класса: WP_Http{}
Хуки из метода
Возвращает
Массив|WP_Error. Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error.
Использование
// private - только в коде основоного (родительского) класса $result = $this->_dispatch_request( $url, $args );
- $url(строка) (обязательный)
- URL to request.
- $args(массив) (обязательный)
- Request arguments.
Заметки
- Смотрите: WP_Http::request()
Список изменений
| С версии 3.2.0 | Введена. |
| Устарела с 5.1.0 | Use WP_Http::request() |
Код WP_Http::_dispatch_request() WP Http:: dispatch request WP 7.0.2
private function _dispatch_request( $url, $args ) {
static $transports = array();
$class = $this->_get_first_available_transport( $args, $url );
if ( ! $class ) {
return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
}
// Transport claims to support request, instantiate it and give it a whirl.
if ( empty( $transports[ $class ] ) ) {
$transports[ $class ] = new $class();
}
$response = $transports[ $class ]->request( $url, $args );
/** This action is documented in wp-includes/class-wp-http.php */
do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
if ( is_wp_error( $response ) ) {
return $response;
}
/** This filter is documented in wp-includes/class-wp-http.php */
return apply_filters( 'http_response', $response, $args, $url );
}