/** * {@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); }
private function _stringifyRequest(tubepress_api_http_message_RequestInterface $request) { return sprintf('<code>%s</code> to <code>%s</code>', $request->getMethod(), $request->getUrl()); }
/** * {@inheritdoc} */ public function wantsToAuthorizeRequest(tubepress_api_http_message_RequestInterface $request) { $url = $request->getUrl(); if ($url->getHost() !== 'api.vimeo.com') { return false; } $path = $url->getPath(); $oauthPath = $this->_stringUtils->startsWith($path, '/oauth'); return !$oauthPath; }