Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 protected function doSend(tubepress_api_http_message_RequestInterface $request)
 {
     $tubePressBody = $request->getBody();
     $puzzleBody = null;
     if ($tubePressBody) {
         if ($tubePressBody instanceof tubepress_http_impl_puzzle_streams_PuzzleBasedStream) {
             $puzzleBody = $tubePressBody->getUnderlyingPuzzleStream();
         } else {
             $puzzleBody = new tubepress_http_impl_puzzle_streams_PuzzleStream($tubePressBody);
         }
     }
     $requestConfig = $request->getConfig();
     $requestConfig['emitter'] = $this->_delegate->getEmitter();
     $puzzleRequest = new puzzle_message_Request($request->getMethod(), $request->getUrl()->toString(), $request->getHeaders(), $puzzleBody, $requestConfig);
     $puzzleResponse = null;
     try {
         $puzzleResponse = $this->_delegate->send($puzzleRequest);
     } catch (puzzle_exception_RequestException $e) {
         throw new tubepress_http_impl_puzzle_RequestException($e);
     }
     return new tubepress_http_impl_puzzle_PuzzleBasedResponse($puzzleResponse);
 }
Esempio n. 2
0
 private function _shouldExecute(tubepress_api_http_message_RequestInterface $request)
 {
     $cacheEnabled = $this->_context->get(tubepress_api_options_Names::CACHE_ENABLED);
     $isDebugEnabled = $this->_logger->isEnabled();
     if ($isDebugEnabled && !$cacheEnabled) {
         $this->_logDebug('Skip API cache for debugging.');
         return false;
     }
     $config = $request->getConfig();
     if (!isset($config['tubepress-remote-api-call'])) {
         return false;
     }
     return true;
 }