WP_Http::head() WordPress Method
The WP_Http::head() method is used to send a HEAD request to a specified URL. This is useful for checking if a certain resource exists without having to download the entire file.
WP_Http::head( string $url, string|array $args = array() ) #
Uses the HEAD HTTP method.
Description
Used for sending data that is expected to be in the body.
Parameters
- $url
(string)(Required)The request URL.
- $args
(string|array)(Optional) Override the defaults.
Default value: array()
Return
(array|WP_Error) Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error.
Source
File: wp-includes/class-wp-http.php
public function head( $url, $args = array() ) { $defaults = array( 'method' => 'HEAD' ); $parsed_args = wp_parse_args( $args, $defaults ); return $this->request( $url, $parsed_args ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |