Retrieves HTTP Headers from URL.
Parameters
$url
stringrequired- URL to retrieve HTTP headers from.
$deprecated
booloptional- Not Used.
Default:
false
Source
function wp_get_http_headers( $url, $deprecated = false ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.7.0' );
}
$response = wp_safe_remote_head( $url );
if ( is_wp_error( $response ) ) {
return false;
}
return wp_remote_retrieve_headers( $response );
}
Changelog
Version | Description |
---|---|
1.5.1 | Introduced. |
Use the returned class’ (WpOrgRequestsUtilityCaseInsensitiveDictionary) methods to get usable data:
Array
(
[server] => nginx
[date] => Sat, 09 Sep 2023 04:27:52 GMT
[content-type] => text/html; charset=UTF-8
[vary] => Accept-Encoding
[strict-transport-security] => max-age=3600
[x-olaf] => ⛄[link] => Array
(
[0] => ; rel=”https://api.w.org/”
[1] => ; rel=”alternate”; type=”application/json”
[2] => ; rel=shortlink
)
[x-frame-options] => SAMEORIGIN
[content-encoding] => gzip
[x-nc] => EXPIRED ord 1
)
nginx