Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function request(array $params)
 {
     try {
         $headers = array();
         $url = new Url($params['url']);
         // Buzz cannot handle gziped content yet <@:(
         //$headers[] = 'Accept-Encoding: gzip,deflate';
         if ($params['config']->isAuthenticationPossible() === true && $this->option['keys']['public'] !== null && $this->option['keys']['private'] !== null) {
             /**
              * Note: DATE_RFC1123 my not be RFC 1123 compliant, depending on your platform.
              * @link http://www.php.net/manual/de/function.gmdate.php#25031
              */
             $date = gmdate('D, d M Y H:i:s \\G\\M\\T');
             $path = $url->getPath();
             $headers[] = 'Date: ' . $date;
             $headers[] = 'Authorization: ' . $this->signRequest('GET', $date, $path);
         }
         if (isset($params['lastmodified'])) {
             $headers[] = 'If-Modified-Since: ' . $params['lastmodified'];
         }
         $response = $this->client->get($url, $headers);
         $body = $response->getContent();
         $headers = null;
         if ($this->option['responseheader']) {
             $headers = array();
             $temp = $response->getHeaders();
             foreach ($temp as $header) {
                 if (substr($header, 0, 5) === 'HTTP/') {
                     continue;
                 }
                 list($key, $value) = explode(': ', $header);
                 $headers[$key] = $value;
             }
             $this->lastResponseHeaders = $headers;
         }
     } catch (\Exception $e) {
         throw new ClientException('Client exception catched, use getPrevious().', 0, $e);
     }
     return $this->createResponse($params['config']->isJson(), $response->getStatusCode(), $body, $headers);
 }