wp_remote_head()WP 2.7.0

Retrieve the raw response from the HTTP request using the HEAD method.

No Hooks.

Return

Array|WP_Error. The response or WP_Error on failure.

Usage

wp_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

Examples

0

#1 Get the HTTP API response headers

$response = wp_remote_head( 'https://api.github.com/users/erusev' );
print_r( $response );

/* will output:
Array
(
	[headers] => Array
		(
			[server] => GitHub.com
			[date] => Thu, 10 Dec 2015 10:53:23 GMT
			[content-type] => application/json; charset=utf-8
			[connection] => close
			[status] => 200 OK
			[x-ratelimit-limit] => 60
			[x-ratelimit-remaining] => 54
			[x-ratelimit-reset] => 1449746444
			[cache-control] => public, max-age=60, s-maxage=60
			[last-modified] => Mon, 23 Nov 2015 13:19:37 GMT
			[etag] => W/"c8dad0c81351ce6451a9b7de7f7f0d8b"
			[vary] => Array
				(
					[0] => Accept
					[1] => Accept-Encoding
				)

			[x-github-media-type] => github.v3
			[x-xss-protection] => 1; mode=block
			[x-frame-options] => deny
			[content-security-policy] => default-src 'none'
			[access-control-allow-credentials] => true
			[access-control-expose-headers] => ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
			[access-control-allow-origin] => *
			[strict-transport-security] => max-age=31536000; includeSubdomains; preload
			[x-content-type-options] => nosniff
			[x-served-by] => 139317cebd6caf9cd03889139437f00b
			[content-encoding] => gzip
			[x-github-request-id] => 05659C50:A398:252770C:566959A3
		)

	[body] => (always empty)
	[response] => Array
		(
			[code] => 200
			[message] => OK
		)

	[cookies] => Array
		(
		)

	[filename] => 
)
*/

Notes

Changelog

Since 2.7.0 Introduced.

wp_remote_head() code WP 6.5.2

function wp_remote_head( $url, $args = array() ) {
	$http = _wp_http_get_object();
	return $http->head( $url, $args );
}