function drupal_generate_test_ua

Generates a user agent string with a HMAC and timestamp for simpletest.

4 calls to drupal_generate_test_ua()
drupal_http_request in drupal/core/includes/common.inc
Performs an HTTP request.
SimpletestHttpRequestSubscriber::onBeforeSendRequest in drupal/core/lib/Drupal/Core/Http/Plugin/SimpletestHttpRequestSubscriber.php
Event callback for request.before_send
SimpleTestTest::testUserAgentValidation in drupal/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
Test validation of the User-Agent header we use to perform test requests.
WebTestBase::curlInitialize in drupal/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
Initializes the cURL connection.

File

drupal/core/includes/bootstrap.inc, line 2536
Functions that need to be loaded on every Drupal request.

Code

function drupal_generate_test_ua($prefix) {
  static $key;
  if (!isset($key)) {

    // Use the salt from settings.php to create the HMAC key, since no services
    // are available yet. The file properties add more entropy not easily
    // accessible to others.
    $key = drupal_get_hash_salt() . filectime(__FILE__) . fileinode(__FILE__);
  }

  // Generate a moderately secure HMAC based on the database credentials.
  $salt = uniqid('', TRUE);
  $check_string = $prefix . ';' . time() . ';' . $salt;
  return $check_string . ';' . drupal_hmac_base64($check_string, $key);
}