diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 8e149f8d573b98823273f8320af7c75e643ad8d7..905fb3ead89d3b5b73113f619f3186eac82ebc59 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -2223,7 +2223,7 @@ protected function checkForMetaRefresh() {
    */
   protected function drupalHead($path, array $options = array(), array $headers = array()) {
     $options['absolute'] = TRUE;
-    $url = $this->container->get('url_generator')->generateFromPath($path, $options);
+    $url = $this->buildUrl($path, $options);
     $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers));
     // Ensure that any changes to variables in the other thread are picked up.
     $this->refreshVariables();