wp_safe_remote_head()
Retrieves the raw response from a safe HTTP request using the HEAD method.
This function is ideal when the HTTP request is being made to an arbitrary URL. The URL, and every URL it redirects to, are validated with wp_http_validate_url() to avoid Server Side Request Forgery attacks (SSRF).
No Hooks.
Return
Array|WP_Error
. The response or WP_Error on failure. See WP_Http::request() for information on return value.
Usage
wp_safe_remote_head( $url, $args );
- $url(string) (required)
- URL to retrieve.
- $args(array)
- Request arguments. See WP_Http::request() for information on accepted arguments.
Default: empty array
Notes
- See: wp_remote_request() For more information on the response array format.
- See: WP_Http::request() For default arguments information.
- See: wp_http_validate_url() For more information about how the URL is validated.
Changelog
Since 3.6.0 | Introduced. |
wp_safe_remote_head() wp safe remote head code WP 6.7.1
function wp_safe_remote_head( $url, $args = array() ) { $args['reject_unsafe_urls'] = true; $http = _wp_http_get_object(); return $http->head( $url, $args ); }