function DrupalHTTPRequestTestCase::testDrupalHTTPRequestHeaders

Tests Content-language headers generated by Drupal.

File

modules/simpletest/tests/common.test, line 1274

Class

DrupalHTTPRequestTestCase
Test drupal_http_request().

Code

function testDrupalHTTPRequestHeaders() {
    // Check the default header.
    $request = drupal_http_request(url('<front>', array(
        'absolute' => TRUE,
    )));
    $this->assertEqual($request->headers['content-language'], 'en', 'Content-Language HTTP header is English.');
    // Add German language and set as default.
    locale_add_language('de', 'German', 'Deutsch', LANGUAGE_LTR, '', '', TRUE, TRUE);
    // Request front page and check for matching Content-Language.
    $request = drupal_http_request(url('<front>', array(
        'absolute' => TRUE,
    )));
    $this->assertEqual($request->headers['content-language'], 'de', 'Content-Language HTTP header is German.');
}

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