diff --git a/src/Unirest/Request.php b/src/Unirest/Request.php index ba8b8c0..b49780d 100755 --- a/src/Unirest/Request.php +++ b/src/Unirest/Request.php @@ -399,6 +399,9 @@ public static function send($method, $url, $body = null, $headers = array(), $us if ($method === Method::POST) { curl_setopt(self::$handle, CURLOPT_POST, true); } else { + if ($method === Method::HEAD) { + curl_setopt(self::$handle, CURLOPT_NOBODY, true); + } curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method); } diff --git a/tests/Unirest/RequestTest.php b/tests/Unirest/RequestTest.php index d9b5633..a46d5a6 100644 --- a/tests/Unirest/RequestTest.php +++ b/tests/Unirest/RequestTest.php @@ -251,6 +251,16 @@ public function testGetArray() $this->assertEquals('John', $response->body->queryString->name[1]); } + // HEAD + public function testHead() + { + $response = Request::head('http://mockbin.com/request?name=Mark', array( + 'Accept' => 'application/json' + )); + + $this->assertEquals(200, $response->code); + } + // POST public function testPost() {