From 13b452504b1f2ee07d03296d5afd127df1848a13 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Mon, 21 Mar 2016 09:16:18 +0000
Subject: [PATCH] Issue #2274153 by dixon_, Wim Leers: Make
 RESTTestBase::httpRequest() work with HEAD requests

(cherry picked from commit ac0150a36aba7c0e01c4bcfe47ca266eded89592)
(cherry picked from commit 5971c4bd74d83b837763613387a800affbe72909)
---
 core/modules/rest/src/Tests/RESTTestBase.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php
index db7d1236e2ed..185a7e834bc1 100644
--- a/core/modules/rest/src/Tests/RESTTestBase.php
+++ b/core/modules/rest/src/Tests/RESTTestBase.php
@@ -93,6 +93,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) {
 
     $url = $this->buildUrl($url);
 
+    $curl_options = array();
     switch ($method) {
       case 'GET':
         // Set query if there are additional GET parameters.
@@ -105,6 +106,16 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) {
         );
         break;
 
+        case 'HEAD':
+          $curl_options = array(
+            CURLOPT_HTTPGET => FALSE,
+            CURLOPT_CUSTOMREQUEST => 'HEAD',
+            CURLOPT_URL => $url,
+            CURLOPT_NOBODY => TRUE,
+            CURLOPT_HTTPHEADER => array('Accept: ' . $mime_type),
+          );
+          break;
+
       case 'POST':
         $curl_options = array(
           CURLOPT_HTTPGET => FALSE,
-- 
GitLab