예제 #1
0
 /**
  * test head request with querystring data
  *
  * @return void
  */
 public function testHeadQuerystring()
 {
     $response = new Response();
     $mock = $this->getMockBuilder('Cake\\Network\\Http\\Adapter\\Stream')->setMethods(['send'])->getMock();
     $mock->expects($this->once())->method('send')->with($this->logicalAnd($this->isInstanceOf('Cake\\Network\\Http\\Request'), $this->attributeEqualTo('_method', Request::METHOD_HEAD), $this->attributeEqualTo('_url', 'http://cakephp.org/search?q=hi+there')))->will($this->returnValue([$response]));
     $http = new Client(['host' => 'cakephp.org', 'adapter' => $mock]);
     $result = $http->head('/search', ['q' => 'hi there']);
     $this->assertSame($result, $response);
 }
예제 #2
0
 /**
  *  Head Request
  *
  *  Execute head request
  *
  * @param string  $url - url of the to send the request.
  * @param Array  $data - Array to data to send if not null.
  * @param string  $type - Type of data specified in request.
  * @param Array  $option -  Array of options to add into request as get variables.
  * @param Array  $header -  Array of header to add into request as http headers.
  * @param boolean  $entityAdmin -  flag to use either _api or _admin in request.
  *
  *
  * @return array $response - The response array.
  */
 public function head($url, $data = NULL, $type = NULL, $option = NULL, $header = NULL, $entityAdmin = false)
 {
     $entity = self::ENTRY_API;
     if ($entityAdmin) {
         $entity = self::ENTRY_ADMIN;
     }
     $uri = $this->protocol . '://' . $this->user . ':' . $this->pass . '@' . $this->host . ':' . $this->port . '/' . self::ENTRY_DB . '/' . $this->db . '/' . $entity . '/' . $url;
     if ($option != NULL) {
         $uri .= '?';
         foreach ($option as $key => $value) {
             # code...
             $uri .= $key . '=' . $value . '&';
         }
     }
     $http = new Client();
     $response = $http->head($uri, ['headers' => $header]);
     return $response;
 }