WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp remote retrieve headers

Description

Retrieve only the headers from the raw response.

Usage

 <?php wp_remote_retrieve_headers$response ); ?> 

Parameters

$response
(array) (required) HTTP response.
Default: None

Return Values

(array) 
The headers of the response. Empty array if incorrect parameter given.

An example of returned values

[headers] => Array
        (
            [date] => Thu, 30 Sep 2010 15:16:36 GMT
            [server] => Apache
            [x-powered-by] => PHP/5.3.3
            [x-server] => 10.90.6.243
            [expires] => Thu, 30 Sep 2010 03:16:36 GMT
            [cache-control] => Array
                (
                    [0] => no-store, no-cache, must-revalidate
                    [1] => post-check=0, pre-check=0
                )

            [vary] => Accept-Encoding
            [content-length] => 1641
            [connection] => close
            [content-type] => application/php
        )

Examples

$response = wp_remote_get('http://www.foo.com/file.txt');
$headers = wp_remote_retrieve_headers( $response );

$headers will contain an array of the headers returned by the server


Change Log

Since: 2.7.0

Source File

wp_remote_retrieve_headers() is located in wp-includes/http.php