function system_test_page_cache_headers

Menu callback to test headers stored in the page cache.

1 string reference to 'system_test_page_cache_headers'
system_test_menu in modules/simpletest/tests/system_test.module
Implements hook_menu().

File

modules/simpletest/tests/system_test.module, line 252

Code

function system_test_page_cache_headers() {
    if (!isset($_GET['return_headers'])) {
        return t('Content to store in the page cache if it is enabled.');
    }
    global $base_root;
    // Remove the test query param but try to preserve any remaining query string.
    $url = parse_url($base_root . request_uri());
    $query_parts = explode('&', $url['query']);
    $query_string = implode('&', array_diff($query_parts, array(
        'return_headers=TRUE',
    )));
    $request_uri = $url['path'] . '?' . $query_string;
    $cache = cache_get($base_root . $request_uri, 'cache_page');
    // If there are any headers stored in the cache, output them.
    if (isset($cache->data['headers'])) {
        drupal_add_http_header('Page-Cache-Headers', json_encode($cache->data['headers']));
        return 'Headers from cache_page returned in the Page-Cache-Headers http response header.';
    }
    return 'No headers retrieved from cache_page.';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.