Title: http_response
Published: April 25, 2014
Last modified: April 28, 2025

---

# apply_filters( ‘http_response’, array $response, array $parsed_args, string $url )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#parameters)󠁿

 `$response`array

HTTP response.

`$parsed_args`array

HTTP request arguments.

`$url`string

The request URL.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#source)󠁿

    ```php
    return apply_filters( 'http_response', $response, $parsed_args, $url );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-http.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-http.php#L467)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-http.php#L467-L467)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Http::_dispatch_request()](https://developer.wordpress.org/reference/classes/wp_http/_dispatch_request/)`wp-includes/class-wp-http.php` |

Dispatches a HTTP request to a supporting transport.

  | 
| [WP_Http::request()](https://developer.wordpress.org/reference/classes/wp_http/request/)`wp-includes/class-wp-http.php` |

Send an HTTP request to a URI.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/hooks/http_response/?output_format=md#comment-content-21)
 2.   [Drew Jaynes](https://profiles.wordpress.org/drewapicture/)  [  12 years ago  ](https://developer.wordpress.org/reference/hooks/http_response/#comment-21)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhttp_response%2F%23comment-21)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhttp_response%2F%23comment-21)
 4.     ```php
        /**
         * Return canned body content for invalid HTTP requests.
         *
         * In this example, "invalid" would be defined as any status code other than
         * 200, 301, or 302.
         *
         * @see WP_Http::request()
         *
         * @param array  $response The HTTP response.
         * @param array  $args     Request arguments. 
         * @param string $url      Request URL.
         *
         * @return array The filtered HTTP response.
        */
        function wpdocs_invalid_request_response( $response, $args, $url ) {
        	if ( ! in_array( $response['response']['code'], array( 200, 301, 302 ) ) ) {
        		$response['body'] = __( 'No content found', 'yourtextdomain' );
        	}
        	return $response;
        }
        add_filter( 'http_response', 'wpdocs_invalid_request_response', 10, 3 );
        ```
    
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhttp_response%2F%3Freplytocom%3D21%23feedback-editor-21)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fhttp_response%2F)
before being able to contribute a note or feedback.