wp-includes/class-wp-http.php:169Send an HTTP request to a URI.
$urlstring$argsstring|arrayoptionalarray()$methodstringdefault: 'GET'
$timeoutfloatdefault: 5
$redirectionintdefault: 5
$httpversionstringdefault: '1.0'
$userstringdefault: 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' )
$reject_unsafe_urlsbooldefault: false
$blockingbooldefault: true
$headersstring|arraydefault: empty array
$cookiesarraydefault: empty array
$bodystring|arraydefault: null
$compressbooldefault: false
$decompressbooldefault: true
$sslverifybooldefault: true
$sslcertificatesstringdefault: ABSPATH . WPINC . '/certificates/ca-bundle.crt'
$streambooldefault: false
$filenamestringdefault: null
$limit_response_sizeintdefault: null
array|WP_Error$headers\WpOrg\Requests\Utility\CaseInsensitiveDictionary
$bodystring
$responsearray
$codeint|false
$messagestring|false
$filenamestring|null
$http_responseWP_HTTP_Requests_Response|null
13 hooks fire while WP_Http::request() runs, in this order:
Filters the timeout value for an HTTP request.
Filters the number of redirects allowed during an HTTP request.
Filters the version of the HTTP protocol used in a request.
Filters the user agent value sent with an HTTP request.
Filters whether to pass URLs through wp_http_validate_url() in an HTTP request.
Filters the arguments used in an HTTP request.
Filters the preemptive return value of an HTTP request.
Fires after an HTTP API response is received and before the response is returned.
Fires after an HTTP API response is received and before the response is returned.
Fires after an HTTP API response is received and before the response is returned.
Filters whether SSL should be verified for non-local requests.
Fires after an HTTP API response is received and before the response is returned.
Filters a successful HTTP API response immediately before the response is returned.
public function request( $url, $args = array() ) { $defaults = array( 'method' => 'GET', /** * Filters the timeout value for an HTTP request. * * @since 2.7.0 * @since 5.1.0 The `$url` parameter was added. * * @param float $timeout_value Time in seconds until a request times out. Default 5. * @param string $url The request URL. */ 'timeout' => apply_filters( 'http_request_timeout', 5, $url ), /** * Filters the number of redirects allowed during an HTTP request. * * @since 2.7.0 * @since 5.1.0 The `$url` parameter was added. * * @param int $redirect_count Number of redirects allowed. Default 5. * @param string $url The request URL. */ 'redirection' => apply_filters( 'http_request_redirection_count', 5, $url ), /** * Filters the version of the HTTP protocol used in a request. * * @since 2.7.0 * @since 5.1.0 The `$url` parameter was added. * * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'. Default '1.0'. * @param string $url The request URL. */ 'httpversion' => apply_filters( 'http_request_version', '1.0', $url ), /** * Filters the user agent value sent with an HTTP request. * * @since 2.7.0 * @since 5.1.0 The `$url` parameter was added. * * @param string $user_agent WordPress user agent string. * @param string $url The request URL. */ 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $url ), /** * Filters whether to pass URLs through wp_http_validate_url() in an HTTP request. * * @since 3.6.0 * @since 5.1.0 The `$url` parameter was added. * * @param bool $pass_url Whether to pass URLs through wp_http_validate_url(). Default false. * @param string $url The request URL. */ 'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false, $url ), 'blocking' => true, 'headers' => array(), 'cookies' => array(), 'body' => null, 'compress' => false, 'decompress' => true, 'sslverify' => true, 'sslcertificates' => ABSPATH . WPINC . '/certificates/ca-bundle.crt', 'stream' => false, 'filename' => null, 'limit_response_size' => null, ); // Pre-parse for the HEAD checks. $args = wp_parse_args( $args ); // By default, HEAD requests do not cause redirections. if ( isset( $args['method'] ) && 'HEAD' === $args['method'] ) { $defaults['redirection'] = 0; } $parsed_args = wp_parse_args( $args, $defaults ); /** * Filters the arguments used in an HTTP request. * * @since 2.7.0 *Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-http.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.