wp_remote_retrieve_headers() WordPress Function
The wp_remote_retrieve_headers() function is used to retrieve the headers of a remote request. This function is useful for retrieving information such as the content type or the status code of a request.
wp_remote_retrieve_headers( array|WP_Error $response ) #
Retrieve only the headers from the raw response.
Description
See also
Parameters
- $response
(array|WP_Error)(Required)HTTP response.
Return
(array|Requests_Utility_CaseInsensitiveDictionary) The headers of the response. Empty array if incorrect parameter given.
Source
File: wp-includes/http.php
function wp_remote_retrieve_headers( $response ) {
if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
return array();
}
return $response['headers'];
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Return value changed from an array to an Requests_Utility_CaseInsensitiveDictionary instance. |
| 2.7.0 | Introduced. |