/**
  * Execute the command.
  *
  * @param array $context An array of context elements (may be empty).
  *
  * @return boolean True if this command was able to handle the execution. False otherwise.
  */
 function execute($context)
 {
     $response = $context->response;
     $encoding = $response->getHeaderValue(org_tubepress_api_http_HttpResponse::HTTP_HEADER_CONTENT_ENCODING);
     if (strcasecmp($encoding, $this->getExpectedContentEncodingHeaderValue()) !== 0) {
         org_tubepress_impl_log_Log::log($this->logPrefix(), 'Content is not encoded with %s', $this->getExpectedContentEncodingHeaderValue());
         return false;
     }
     if (!$this->isAvailiable()) {
         org_tubepress_impl_log_Log::log($this->logPrefix(), 'Not available on this installation.');
         return false;
     }
     $compressed = $response->getEntity()->getContent();
     if (!is_string($compressed)) {
         throw new Exception('Can only decompress string data');
     }
     org_tubepress_impl_log_Log::log($this->logPrefix(), 'Attempting to decompress data...');
     /* this will throw an exception if we couldn't decompress it. */
     $uncompressed = $this->getUncompressed($compressed);
     /* do some logging. */
     if (org_tubepress_impl_log_Log::isEnabled()) {
         $this->_logSuccess(strlen($compressed), strlen($uncompressed));
     }
     $context->decoded = $uncompressed;
     /* signal that we've handled execution. */
     return true;
 }
 private function _assignHeadersToResponse($headerArray, org_tubepress_api_http_HttpResponse $response, org_tubepress_api_http_HttpRequest $request)
 {
     if (!is_array($headerArray) || empty($headerArray)) {
         throw new Exception(sprintf('No headers in response from %s', $request));
     }
     foreach ($headerArray as $name => $value) {
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         $response->setHeader($name, $value);
     }
     /* do some logging */
     if (org_tubepress_impl_log_Log::isEnabled()) {
         $headerArray = $response->getAllHeaders();
         org_tubepress_impl_log_Log::log($this->logPrefix(), 'Here are the ' . count($headerArray) . ' headers in the response for %s', $request);
         foreach ($headerArray as $name => $value) {
             org_tubepress_impl_log_Log::log($this->logPrefix(), "<tt>{$name}: {$value}</tt>");
         }
     }
 }
 private function _logRequest(org_tubepress_api_http_HttpRequest $request)
 {
     $headerArray = $request->getAllHeaders();
     /* do some logging */
     if (org_tubepress_impl_log_Log::isEnabled()) {
         org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Here are the ' . count($headerArray) . ' headers in the request for %s', $request);
         foreach ($headerArray as $name => $value) {
             org_tubepress_impl_log_Log::log(self::$_logPrefix, "<tt>{$name}: {$value}</tt>");
         }
     }
 }