wp_remote_retrieve_header

Retrieve a single header by name from the raw response.

Description

(string) wp_remote_retrieve_header( (array) $response, (string) $header ); 

Returns (string)

The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.

Parameters (2)

0. $response (array)
The response.
1. $header (string)
Header name to retrieve value from.

Usage

  1. if ( !function_exists( 'wp_remote_retrieve_header' ) ) { 
  2. require_once ABSPATH . WPINC . '/http.php'; 
  3.  
  4. // The response. 
  5. $response = array(); 
  6.  
  7. // Header name to retrieve value from. 
  8. $header = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_remote_retrieve_header($response, $header); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/http.php  
  1. function wp_remote_retrieve_header( $response, $header ) { 
  2. if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) { 
  3. return ''; 
  4.  
  5. if ( isset( $response['headers'][ $header ] ) ) { 
  6. return $response['headers'][$header]; 
  7.  
  8. return '';