http_response

Filters the HTTP API response immediately before the response is returned.

Description

apply_filters( 'http_response', (array) $response, (array) $r, (string) $url ); 

Parameters (3)

0. $response (array)
HTTP response.
1. $r (array)
HTTP request arguments.
2. $url (string)
The request URL.

Usage

To run the hook, copy the example below.
  1. $response = apply_filters( 'http_response', $response, $r, $url ); 
  2.  
  3. if ( !empty( $response ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the http_response callback 
  2. function filter_http_response( $response, $r, $url ) { 
  3. // make filter magic happen here... 
  4. return $response
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'http_response', 'filter_http_response', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'http_response', 'filter_http_response', 10, 3 ); 

Defined (2)

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

/wp-includes/class-http.php  
  1. return apply_filters( 'http_response', $response, $r, $url ); 
  1. return apply_filters( 'http_response', $response, $args, $url );